As a long time shell user I’ve spent a lot of time using bash as my default shell. In most of the hosting environments I regularly use bash is the default shell. Because of this bash is what I’ve been using on my local development machine until I recently switched to Zsh and oh-my-zsh. This post outlines why I prefer Zsh and how I made the switch.
Why I Prefer Zsh
There are a few reasons that Zsh has really popped for me.
- In the image above you can see my current Zsh config in action. This theme allows me to see details about my system and the current working directory. oh-my-zsh ships with a bunch of themes and you can create your own.
- I love plugins. My CMS of choice has them. My text editor has them. Why shouldn’t my terminal. Zsh has them and oh-my-zsh ships with a bunch of useful ones like git integration, github, osx, and so much more.
- Because of it’s compatibility with bash commands I only had to learn the new stuff such as how to use the plugins.
My development systems are Macs. The default terminal shipped with the operating system is nothing special. Instead of using the default terminal I use iTerm2. iTerm2 has tabs, multiple panes, and you can even configure it to operate like visor.
Installing oh-my-zsh and Customizing
Zsh is already installed on most modern operating systems and is already on OS X. Installing oh-my-zsh and setting zsh as the default shell is a simple one line install script in the readme documentationn.
Out of the box it won’t look like the image of the shell above. I’ve switched themes from the default one.
The first step I did was to migrate my current bash customizations from my .bashrc and .bash_profile files to the new .zshrc file in my home directory.
The next step is to customize to your liking. First, there are a number of plugins, some of which are documented on the wiki. Plugins are enabled in the .zshrc.
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) plugins=(git git-flow osx github)
To make the display look the way you want you can choose or create a theme. A number of the themes that come with oh-my-zsh are pictured on the theme wiki. The one pictured above is the dstufft theme.
# Set name of the theme to load. # Look in ~/.oh-my-zsh/themes/ # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. ZSH_THEME="dstufft"
In getting started I read a number of useful posts. Here are some I found useful.