Getting started with oh-my-zsh

Dien Bui
3 min readJan 2, 2018

--

Oh-my-zsh is an open source, community-driven framework for managing zsh and it is FREE. It has more than 180 optional plugin (rails, git, …), more than 120 theme and an auto-update tool to keep oh-my-zsh up-to-date.

In this tutorial, I will guide you to install it on your PC/laptop. The great thing about this is that you can customize your Shell and add plugins. Unlike the old Bash shell, which does not look attractive and can make it difficult for you to use when working with command-line a lot.

Pre-requisites

  • Linux and macOS because oh-my-zsh works best on Unix-based OS
  • UPDATE: WSL (Windows Subsystem for Linux) works with oh-my-zsh too.
  • zsh must be pre-installed. In OSX, it is already pre-installed. On Linux, you will need to type command in the Terminal to install:
  • curl or wget must be installed.
  • For Debian/Ubuntu:
$ sudo apt-get install zsh
  • For Fedora:
$ sudo yum install zsh

Install oh-my-zsh

  • via curl
$ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
  • via wget
=$ wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh

Change default shell

$ chsh -s /bin/zsh

For some OSes, you may need to restart your computer for this to take effect.

Change Terminal theme

Now you have successfully installed oh-my-zsh. You will need to change the theme that is suitable for you, instead of using the default one. To change it, you will need to modify the .zshrc file:

$ vim ~/.zshrc

In this tutorial, I use vim text editor, you can use other text editor if you like. Next, locate this line in the file:

ZSH_THEME="robbyrussell"

Change the name “robbyrussell” to another name of another theme. You can have a look of all the available themes on this website.

Finally, just restart the Terminal and you will see the difference.

Add plugins

In the .zshrc file, you need edit the line starting with “plugins” word:

plugins=(git bundler osx rake ruby)

You can add more or remove plugins if you like. To use the plugins, most of them have README file, which documents how to use them.

Auto-completion with Up

In Bash shell, you can use Ctrl + R and type keyword to auto-fill the most recent and matching command.

With oh-my-zsh, there is another way: you can type the starting words of the command you want and press Up button to cycle through the history.

For example, I am a Docker guy and use Docker daily and I want to view log of a container, I just simple type docker logs then press up, I will cycle me through:

$ docker logs -f --tail=1 cocoon-rest (first click)
$ docker logs -f --tail=1 cocoon-webapp (second click)

After the second click, it shows the command I want, I hit Enter and then I can view the log of it.

I won’t explain about Docker in this post as it’s out of scope, but intend to write a Docker 101 post soon :) .

Auto-completion with Tab

In Bash shell, you can type keyword and press Tab to show list of matching commands, however you need to cycle through the list and remember the name you want and manually type further to complete

With oh-my-zsh, things will get better, after pressing Tab the first time, you can press the second time to allow cycling through the list and choose the command you want, then it will automatically fill the rest of the words and finally just hit Enter and you are good to go. For example:

  1. Type doc and press Tab the first time

2. Press Tab the second time, then press Tab for Up, Down, Left, Right to cycle through

Updating oh-my-zsh

It will update automatically, but if you want to do so manually just simply type this command in Terminal:

$ omz update

Read more

For more information about oh-my-zsh, you can have a look at this website.

--

--

Dien Bui

Backend, data and cloud computing enthusiast | Power of open-source and sharing believer | GitHub: https://github.com/joebui