In the good old days, when there were no such things like “Graphical User Interfaces”, a computer could only be used with a command-line interface. This system was thoroughly refined to perfection and still can be used really efficiently even today. One of the major shells was the Bourne-Shell
that uses the short abbreviation sh
. It was used widely and at one point received an update called Bourne-Again Shell
- bash
. Bash is the standard on many operating systems today. Although it is so popular there have been some other contestants which have even more features. One of them is zsh
the Z-Shell
.
Problem:
It is not always simple to tinker around with these shells, set them up correctly, and customize to your very own needs.
Oh-My-ZSH
oh-my-zsh which was written by Robby Russell tries to solve this problem and in my opinion, succeeds in doing so. It is easy to install, use and customize and makes everyday working with zsh a charm. Check out the official website.
Installation
Installation is as simple as a one-liner:
Hopefully you will get to see this awesome piece of ASCII art at one point:
At one point this script will ask you for your admin password: It needs it to change your default shell to zsh
. If you have a Homebrew version of zsh
installed this will not succeed since the chsh
(change shell) command only allows system shells. (At least it did so for me.) If you run into the same problem just quickly type this into your current shell.
And voilà! The next time you start a terminal or open a new tab you are good to go.
Customization
In your home-folder you will now find your brand-new .zshrc
configuration file.
This file is pretty self explanatory. Two of the most important customization options are themes and plugins. The creator’s theme is the default when first installed and only one plugin is active.
For plugins I suggest you walk through the plugin directory or the plugin wiki and check out what is available and just add whatever you think is needed to your configuration file.
Extending Oh My ZSH
Go to your ~/.oh-my-zsh
directory. Create a new directory inside of the custom
directory called plugins
. Here we can create any custom plugins we want. Create a new folder called test
and inside of it touch
a new file called test.plugin.zsh
.
This will add the c
command that can quickly cd
into an important directory. The second line even makes auto completion possible, it will list all the files and directories that are so important to you.
Theming your ZSHELL
For now lets look at Robby Russell’s default theme.
It is pretty basic:
Looks pretty complicated? It is not that bad once you get a grasp of it.
This would prompt PLACE HOLDER
in red.
With the %c
option you can display the current directory. Loot at some of the Prompt Options that are available.
These variables are for the git_prompt_info
customization. They work exactly like the rest of the Prompt.
Last but not least you can reset everything.
Make sure to check out my post about ANSI Escape Codes if you want to learn more about coloring and formatting your terminal!
And now?
In the end you can customize your shell however you want. If you need some inspiration and help look at both the themes wiki and the themes directory. You can get some ideas of what you want to do and of how to add some other information. Look at some of the Prompt Options to add more system info.
Usage
A quick list of features:
- Auto completion everywhere thanks to the many plugins:
- Just press tab!
- Double Asterix for deeply nested search
ls ~/**/*.py
all python files in your home directory
- Filtered History for quicker history searching
$ l
pressing the up button now will only result in elements starting with l
- Multiple directory auto complete
- This
cd /on{tab}/tw{tab}/thr{tab}
is just this/on/tw/thr{tab}
- This
- Renaming working directory
cd boring fun
replaces all occurences ofboring
withfun
in the path to the current directory and switches your session into the new path
End Note
This is a call to every shell user:
Change now! Because ZSH will make your life a lot easier.