Menu

richardtape.com

A WordPress Guy

ZSH or Oh-My-ZSH on Ubuntu

I’ve used Oh My ZSH on my mac for about 18 months ever since I read an article by Andrew Burgess on Tuts+ about customizing your command prompt. Now that I run my own VPS on DigitalOcean it’s significantly easier for me to interact with the shell if I have Oh My ZSH running. Honestly, I found it fairly tricky to install. I genuinely think that was down to my own misunderstanding oh shells in general more than anything else.

Before installing ZSH or Oh My ZSH

Important: Have two SSH sessions open to your VPS. The second one is simply there in case something goes horribly wrong. You’re able to still change stuff back. Before you do anything, SSH into your VPS and

echo $0

This will tell you what your current shell is. If everything below goes horribly wrong, then simply chsh back to this path.

Installing ZSH on Ubuntu

Here are the steps I took to get Oh My ZSH working on my Ubuntu 14.04 (x64) VPS on DigitalOcean:

  1. Install ZSH
    sudo apt-get install zsh
  2. (If you haven’t installed git, install git…)
    sudo apt-get install git-core
  3. Install Oh My ZSH
    # If you have curl: 
    curl -L http://install.ohmyz.sh | sh
    
    # If you don't have curl:
    wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

This may be enough for you. At this point, if you open a new SSH session, you may see the new Oh My ZSH prompt (which is, by default a lime green arrow with the name of the directory you log in to). If it hasn’t worked (it didn’t for me), try the following:

Extra steps required on some setups

  1. Find where ZSH has just been installed to
    # This will give you a path, similar to /bin/zsh
    which zsh
  2. Change shell
    chsh
    # Enter your sudo password
    # Now type the path you found above, i.e. /bin/zsh

That worked for me – you can test by simply creating a new SSH sessions. Do not forget to always have open another SSH session so you always have something to switch to should it all go horribly wrong.

I’ve also made a gist of all of these instructions: https://gist.github.com/269b3c1500fc46049a5d.git

Comments

reddit/u/blewsyboy says:

Or, if you want to just keep using bash and have the choice to use zshell, you can skip the chsh process, and simply enter zsh at prompt when you need it, and bash when you want to go back to bourne again shell. I prefer to have bash as my regular prompt, as i’m still learning to navigate zsh…

Michael Lee says:

This was just what I needed to get Oh My ZSH on Ubuntu. I’ve also been using it on my Mac for a while now and love it.

The bit about chsh was handy!

Thanks and cheers!

Rich says:

Glad I could help, Michael. Oh My ZSH has been a great find for me and having it on my hosting was brilliant 🙂

tjfwalker says:

Just what I was looking for. Very helpful post/article. Thanks.

Rich says:

No worries! Glad it helped.

Commented on the gist too, but your ‘Extra steps required’ can be truncated a bit to: `chsh -s $(which zsh)`

Leave a Reply