I’m a big fan of the command line interface on my Ubuntu machine… I hate using my computer mouse! This motivated me to search for great tools to enhance my user experience on the CLI. I came across Oh-My-Zsh during my internship. Some friends convinced me to use the Zshell because of its simplicity and adjustability. As a bonus, the CLI is extendable with many plugins.
This is a list of its capabilities:
I’m performing this installation guide on my Ubuntu 16.04 Virtual Machine. To show you the underlying power of Oh-My-Zsh, I will install the Git plugin (Git-core). This plugin gives visual feedback about the Git status of a project.
ZSH_THEMEvariable and change it:
build_prompt(). Just comment out this line or remove it. At last, change the
To actually see the theme, you have to source your
.zshrc file like this:
source ~/.zshrc. If everything worked out fine, you should see something like the cover image!
Extra: Set zsh as our default shell. Execute this in your default shell, in most cases this will be bash. If you execute this command in zsh, it won’t change anything:
$ chsh -s $(which zsh)
Note: If you use
sudo it will change the shell for root, but not for your working user.
All plugins listed on the plugins Github page are pre-installed with Oh-My-Zsh at
~/.oh-my-zsh/plugins. Custom plugins can be installed at
~/.oh-my-zsh/custom/plugins. To use a plugin, you can simply add it to the plugins list in your
~/.zshrc file. Add wisely, as too many plugins slow down shell startup. Leave a blank between each plugin.
In this example, I’ve installed a useful plugin to give color highlighting to your
man pages . To be able to use the plugin, source your
$ source ~/.zshrc
Another great plugin is syntax highlighting for your shell. Besides that, this plugin has the capability to verify the correctness of your command.
This plugin isn’t installed with Oh-My-Zsh. Navigate to
~/.oh-my-zsh/custom/plugins and clone the code from Github into this folder:
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting
You will see a folder named
zsh-syntax-highlighting. This is the name that needs to be added to the plugins list.
You can also use
zsh-autosuggestions for command completion. It suggests commands based on your command history. Very useful! To select the proposed command, press the right arrow key.
Installation is the same as with
$ git clone https://github.com/zsh-users/zsh-autosuggestions
zsh-autosuggestions to the plugins list.
Oh-My-Zsh automatically remembers the 20 last directories you have visited. You can list the history chronologically with
dirs -v or just
Normally, you can use
cd +1 to go to the previous directory and so on. Oh-My-Zsh made this even more straightforward, now you can use the number of the entry in the directory history you want to visit…
alias: List all aliases. You can pipe the output to
grepto search for a particular alias.
cd ../../../..I think you get it, right?
take test_folder: Creates a folder named
test_folderand changes to it
x: Extract archive of types
tar, bz2, rar, gz, tbz2, tgz, zip, Z, 7z
upgrade_oh_my_zsh: Easy commando for upgrading your installation
It can happen the history file gets corrupt. Don’t ask me the specific details. Each time you launch a new terminal, you get this message:
zsh: corrupt history file /home/myusername/.zsh_history
Let’s fix it with the following commands. Make sure you are in the root of homefolder. The fc command lists, edits, or re-executes commands previously entered to a shell. The history command allows you to use words from previous command lines in the command line you are typing.
mv .zsh_history .zsh_history_bad
strings .zsh_history_bad > .zsh_history
fc -R .zsh_history
Oh-My-Zsh is just awesome!
This article was made with the help of TheLedger.
Level up your reading game by joining Hacker Noon now!