Improve the way your terminal looks and feels

By: Abheek Dhawan


This is a simple tutorial on how to improve the look and feel of your terminal with these three things:

  • ZSH: A robust alternative to traditional BASH
  • Oh-My-ZSH: An amazing framework for ZSH with many plugins and themes
  • zsh-autosuggestions: An advanced plugin that makes command completion suggestions based on previous commands.
The finished product

Step 1:

The first thing to do is to install ZSH. This is default on macOS now, and the shell is located at /bin/zsh. If you're using Linux, however, you'll need to install it through the package manager and run the command:

zsh

in order to go through the first time user setup. Now that ZSH is installed, we have to set it as the default. To do this, run:

chsh -s /path/to/zsh

with /path/to/zsh being either /usr/bin/zsh or /bin/zsh depending on your system.

Step 2:

This step involves installing Oh-My-ZSH and defining plugins and themes. The first thing to do is of course installing Oh-My-ZSH. This is extremely easy and involves running one command:

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

Once it's installed, it selects a theme called robby russell. To change that, we just need to edit the ~/.zshrc file with something like vim or nano, and edit the line that says:

ZSH_THEME = "robbyrussell"

and change robby russell to whatever theme you want. You can find all themes and plugins on the Oh-My-ZSH GitHub page. However, many themes require Powerline Fonts. Luckily, these fonts are really easy to install. Simply clone the repository and run the install script.

git clone https://github.com/powerline/fonts
cd fonts
./install.sh

Once you've installed the Powerline Fonts, here are a few theme suggestions:

  • Powerlevel10K (requires external installation)
  • agnoster
  • bira

Installing plugins is a very similar story. However, instead of editing:

ZSH_THEME = "robbyrussell"

you have to edit:

plugins = ()

There are hundreds of plugins to choose from, from ones for your OS to things like Git and Vim.

Step 3:

Now that we've installed both ZSH and Oh-My-ZSH, there's just one last thing to do: installing zsh-autosuggestions. I find these to be extremely helpful because they recommend commands that I've used previously. To install it as an Oh-My-ZSH custom plugin, you just have to run this script:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Once that's done, simply add it as a plugin in the ~/.zshrc file.

Conclusion

Now, you should have an awesome looking terminal in which you can navigate completions with your arrow keys, get suggestions based of your previous commands, and it's super customizable! You can take your terminal even further by installing an analytics tool like screenfetch or archey and adding it to the end of your ~/.zshrc file. A fun alternative would be adding fortune | cowsay to the end of your ~/zshrc file.

Sources and Helpful Links: