Principal Software Engineer Works at Oath: (which acquired Millennial Media) (which acquired Nexage) Lives in Atlanta, GA
Java developer, currently into Scala, likes to tinker, tries to solve all problems in life by writing code and loves the great indoors!
[ Blog ]
Oh my God. How did I not find out about oh-my-zsh till now? Here is a 10 minute installation guide to pimp out your shell. You are already on zsh, right?
Use curl
to install automatically in one step. Run the following from the home folder. This clones the oh-my-zsh git repo to the default location ~/.oh-my-zsh
.
If this is the first time installing using oh-my-zsh, the install script creates a ~/.zshrc
file and copies over some information (path and aliases) to it. If it did not, copy an existing template to your home folder.
It is time to change your shell to zsh
if you haven’t done it already
Open a new terminal window/tab and your prompt should look like this. Now change to a git directory and see the prompt change automatically.
The above prompt is made possible by the default theme “robbyrussell” that is loaded at the start of each session. This can be customized a lot to make it look any way you want.
Choose ZSH_THEME="random"
in your ~/.zshrc
(usually at the top of the file) and a different theme is loaded each time a new terminal session is loaded. You can look at all the existing themes this way till you find the one you like.
To customize your prompt and not use an existing theme, create a file name ending in .zsh-theme
under ~/.oh-my-zsh/custom/themes
and it will be sourced each time a new session is started.
For example create a file ~/.oh-my-zsh/custom/themes/[name-of-theme].zsh-theme
then add an entry ZSH_THEME="[name-of-theme]"
to ~/.zshrc
and comment out the default theme. The following are the contents of my personal theme (95% of which is taken from an existing theme called ‘ys’)
This makes my prompt look like this:
There are number of plugins available. I have added the following to my ~/.zshrc
. My favorite ones are sublime
, sudo
and web-search
(git
comes with the default installation)
I prefer to have all my aliases and functions in separate files so that they can be sourced by both bash
and zsh
(in case I decide to fall back to bash
).
For aliases, I just source all my aliases at the end of my ~/.zshrc
.
For functions however, I had to add a new file to ~/.oh-my-zsh/lib
folder. The name did not really matter, but it has to have an extenstion of .zsh
. All files with that extension are sourced automatically. Once this file is added, I added this entry to ~/.oh-my-zsh/.gitignore
to keep the repo clean.
By default you will be prompted to check for upgrades. If you would like oh-my-zsh
to automatically upgrade itself without prompting you, set the following in your ~/.zshrc:
DISABLE_UPDATE_PROMPT=true
To disable upgrades entirely, set the following in your ~/.zshrc
:
DISABLE_AUTO_UPDATE=true
To upgrade directly from the command-line, just run upgrade_oh_my_zsh
.
Run uninstall_oh_my_zsh
, (which is conveniently in your path) from the command-line and it’ll remove itself and revert you to bash
(or your previous zsh
configuration). You might have to run chsh
to change your shell back to bash
.