by danduran on Development 2 min read, Comments: 0 (Add Your Comment!)

Installing and Using Zsh Instead of Bash on Debian-Based Systems

TL;DR:

Zsh offers a superior shell experience with powerful autocompletion, plugins, and customization, making workflows faster and more efficient. This tutorial guides users through installing and configuring Zsh, replacing Bash for a more intuitive, feature-rich terminal.

1. Install Zsh

Run the following command:

sudo apt update && sudo apt install zsh -y

2. Set Zsh as Your Default Shell

To make Zsh your default shell, use:

chsh -s $(which zsh)

Then log out and log back in, or reboot for the change to take effect.

To confirm Zsh is now your default shell, run:

echo $SHELL

It should output:

/usr/bin/zsh

Zsh will launch an interactive configuration menu the first time you start it. Alternatively, you can install Oh My Zsh for better customization:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

After installation, restart the terminal or run:

exec zsh

Advantages of Using Zsh Over Bash

Better Autocompletion & Suggestions
- Zsh offers fuzzy matching, autosuggestions, and spell correction.
- You can type part of a command and use Tab completion to cycle through possible options.

Plugins & Customization
- With Oh My Zsh, you can install plugins like:
- zsh-autosuggestions (autocomplete previous commands)
- zsh-syntax-highlighting (color-coding syntax)
- git (enhanced Git support)

Powerful Prompt Customization
- Zsh allows using themes like Powerlevel10k, which provides an informative and highly customizable shell prompt.

Improved Globbing & File Matching
- More flexible wildcard support, e.g.:

ls **/*.txt

searches for all .txt files in subdirectories.

Enhanced History Search
- Use Ctrl+R to search command history with incremental search.

Better Path Expansion
- If you type:

cd /u/l/d

Zsh expands it to /usr/local/bin/ if it matches existing directories.


Notes

📝 Not Installed by Default
- Bash is the default on almost all Linux systems. You need to install Zsh manually.

📝 Some Scripts May Require Bash
- If a script is specifically written for Bash (#!/bin/bash), running it in Zsh (#!/bin/zsh) may cause errors.
- Solution: Run such scripts in Bash manually:

bash script.sh

📝 More Setup Required for Full Features
- To get the full experience (plugins, themes, etc.), you need to install Oh My Zsh or manually configure .zshrc.


Zsh is an excellent choice if you want a more modern, powerful, and customizable shell experience. Since you already have a customized KDE setup, Zsh will complement it well. 🚀

No comments yet. Be the first to comment!