Watch on YouTube: youtu.be/1S3MUVIAieE

Prerequisits

What is ZSH and why would I want it?

Also check out this vid from UTOSC 2012 by Seth House: Zsh: A high-level overview of shell-use and scripting

zsh is an improvement upon bash. It makes Terminal easier to use for beginners (and experts).

oh-my-zsh is a set configurations for zsh. It's meant for people who want to use zsh, but don't want to learn a lot about it and set it up themselves.

  • It detects many typos
  • It autocompletes better than bash
  • You can push a directory (move into it) just by typing the directory's name (look ma, no pushd!)
  • It's very polite (asks you what you mean to do)
  • It will tell you which git branch you're on and if your git status is dirty
  • You can use ., .., ..., etc up to n dots to go to an ancestor directory.

Note: Most of the programs that end in sh are shells (i.e. sh, ash, dash, bash, zsh). They're all nearly identical, but each succeeds the previous by being easier to use and having more features.

Installing ZSH

Before you can use ZSH, you'll have to install it.

Although you only need to install zsh to have a working zsh, curl and git are needed to install oh-my-zsh in the following step.

vim is needed because... well, it's vim!

Open Terminal by searching for it in Dash (the upper left-most button in Launcher) and then copy and paste all of these lines (all at once) into Terminal.

sudo apt-get update && \
sudo apt-get install -y \
  curl \
  vim \
  git \
  zsh

Once you've pasted that, hit the <enter> key. If you're asked for your password, type it in (you won't see any *'s, but that's okay, it's working)

Installing Oh-My-ZSH

The default installation of ZSH requires a fair number of steps before it's all set up and working optimally.

By installing Oh My Zshell, we can skip the configuration step.

Run this command in Terminal the same way you ran the install command above.

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | bash

Once it completes, go ahead and run the command zsh. You should see some colors change. Congratulations, you're running zsh!

A note to experts: On the zsh website they list | sh, but the script is, in fact, meant for bash and it won't run on dash, which is what Ubuntu links sh to. See for yourself: ls -l /bin/sh.

Setting ZSH as the default shell (instead of bash)

As of right now, Terminal will always run BASH by default. Now we'll change it to run ZSH instead.

(I'm assuming you've copied and pasted enough commands at this point that I don't need to tell you to do that with this one)

sudo chsh -s $(which zsh) $(whoami)

Note to the experts: You should check in your ~/.bashrc for any configuration that you may have unwittingly added and need to be copied over. For example, it's quite common to forget rvm's loader.

tail .bashrc

For example, you might see output that looks like this (to be clear, I'm not asking you to run these, so don't type them - although it won't hurt if you do)

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "/home/`whoami`/.rvm/scripts/rvm" ]] && source "/home/`whoami`/.rvm/scripts/rvm" >> ~/.zshrc

Theming

You'll probably want to choose a theme to use. You can take a look at many of the ones available here:

https://github.com/robbyrussell/oh-my-zsh/wiki/themes

Make sure that it's in ~/.oh-my-zsh/themes/. For example, if I want to make sure the theme bira exists I would do this (but you should substitute bira for the theme you're interested in)

ls ~/.oh-my-zsh/themes/ | grep 'bira'

If you're not sure which to pick, I highly suggest random - so that you get a chance to preview a different one each time you open terminal and then you can decide which to stick with later.

To set the theme you'll need to change ZSH_THEME in ~/.zshrc.

vim ~/.zshrc

If you just can't decide, my current favorite is intheclear. Maybe you'll like it too!


By AJ ONeal

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )