In this post, we will see how can change our default shell from bash to zsh. Zsh is a shell designed for interactive use, and can offer features that bash does not have, or it is difficult to implement and add.

Some of these features are: Auto Correction, Syntax Highlighting, Autosuggestions, and many more.

These features can be come even more easier to add, if we use a framework for zsh, like Oh My Zsh. Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. Oh My Zsh makes it easier to add new features with the bundled plugins that you can enable by editing a single line. You can also easily install external plugins that are provided by the community. Also, Oh My Zsh comes with over 150 available themes, that can change the way you look at your terminal.

Install ZSH

Install zsh:

First, we need to install the zsh shell:

sudo apt install zsh

Verify installation by running:

zsh --version

Change default shell:

chsh -s $(which zsh)

Log out and Log in to change shell:

Type: Ctrl+Alt+Delete

Verify results:

echo $SHELL

Install Oh My Zsh:

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

Configure ZSH

Open zsh configuration file .zshrc:

vim .zshrc

Theme

Find this value and change it:

ZSH_THEME="agnoster"

A preview of agnoster:

agnoster-theme

Find all available themes at: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

Other interesting themes:

  • robbyrussell
agnoster-theme
  • af-magic
agnoster-theme
  • alanpeabody
agnoster-theme

Powerline Fonts

Many themes require installing the Powerline Fonts in order to render properly.

To install them for a Debian or Ubuntu based Linux distribution, run:

sudo apt-get install fonts-powerline

Auto Correction

Find this value and uncomment it:

ENABLE_CORRECTION="true"

Neofetch

To run neofetch in every new shell, add to the bottom of .zshrc file:

neofetch

Plugins

Add each plugin at the end of plugins=() variable:

This plugin adds colors to man pages:

plugins=(... colored-man-pages)

This plugin adds completion for pip, the Python package manager:

plugins=(... pip)

This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found:

plugins=(... command-not-found)

Easily prefix your current or previous commands with sudo by pressing esc twice:

plugins=(... sudo)

Find all available plugins at: https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

zsh-autosuggestions

  1. Clone this repository in oh-my-zsh’s plugins directory:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  1. Activate the plugin in ~/.zshrc:
plugins=( [plugins...] zsh-autosuggestions)
  1. Restart zsh (such as by opening a new instance of your terminal emulator).

zsh-syntax-highlighting

  1. Clone this repository in oh-my-zsh’s plugins directory:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. Activate the plugin in ~/.zshrc:
plugins=( [plugins...] zsh-syntax-highlighting)
  1. Restart zsh (such as by opening a new instance of your terminal emulator).