The Z shell

Tags: shell linux

What it is

The shell is what seats between the user and the core of the operating system, usually in a form of a command line interface (CLI). The most popular shell on Linux distributions is bash. In 2019, Apple started releasing the MacOS with Zsh (Z shell) by default. I believe that is one the reasons that made zsh so popular.

Installing it on Ubuntu

Ubuntu, one of the most popular Linux distributions, comes with bash pre-installed. To install Zsh on it, just run the following commands:

$ sudo apt install zsh
$ exec zsh

When running it for the first time, it will ask you to create a default configuration file ~/.zshrc and set it as the default shell. You can make it default shell manually by running:

$ chsh -s $(which zsh)

The same command can be used to bring bash back. The chsh command stands for: change shell. The option -s is to set is as default during the login for the current user.

Oh My Zsh

By default, the Z shell is not very “pleasant”. It is, how ever, very extensible. Thanks to that, there is an open source project called Oh My Zsh, which makes it look super cool and productive. The project has a collection of free plugins and themes that can be easily installed using the following command.

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

Changing the default theme is as easy as updating the variable ZSH_THEME on the ~/.zshrc file. The default is robbyrussel; a good alternative is agnoster. There a complete list of themes on a wiki page from their Github repository.

$ vi ~/.zshrc
$ source ~/.zshrc