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.
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.
sudo apt-get install zsh
- For Fedora:
sudo yum install zsh
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh
chsh -s /bin/zsh
Note: For some OSes, you may need to restart your computer for this to take effect.
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
In this tutorial, I use vim text editor, you can use other text editor if you like. Next, locate this line in the file
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.
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 :) .
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:
- Type doc and press Tab the first time
- Press Tab the second time, then press Tab for Up, Down, Left, Right to cycle through
It will update automatically, but if you want to do so manually just simply type this command in Terminal
For more information about oh-my-zsh, you can have a look at this website.
Note: this post's origin is from my similar post on Medium with slight modification to update with latest changes of oh-my-zsh: https://dienbui.medium.com/using-oh-my-zsh-f65be6460d3f