iTerm2 with Zsh Shell
An alternative to the default terminal and bash
If you use a terminal frequently it’s worth trying to make that very experience the best possible to be productive.
On OSX you have the Terminal application which by default uses the bash shell. If you are using Git and want a custom bash prompt, the setup is quite cumbersome. I actually blogged about one solution back in 2009. Doing this setup whenever you get a new computer or update the OS turns out to be quite a pain in the ass.
About a year ago I noticed that more and more people switch to iTerm2 and also switch to another shell called Zsh in combination with Oh my ZSH. It’s a powerful combination and the setup couldn’t be any easier.
Here are the steps to get things running:
- Download and open iTerm2 and change the default shell to Zsh:
chsh -s /bin/zsh
- Install oh-my-zsh (you gotta trust that script so make sure you want to do that):
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
Done, that’s it. Open a new iTerm2 window and `cd` into a directory with a git repository. It shows you on which branch you are and if your current working tree is dirty. You are welcome!
Of course you can customize the hell out of your shell, having aliases for everything. However, I think you should weigh the convenience against the pain to set up things on a new system. Being more default makes a new setup easier and maybe more importantly you can switch to a laptop of a co-worker and be productive right away.
However, a little customization is just fine ;)
Edit ~/zshrc. I like the default theme but set ZSH_THEME=”random” and open some new shells to explore some other themes you might like better.
Oh-my-zsh comes with a bunch of plugins and only a few are set up by default. Here is my plugin list:
plugins=(cake git sublime osx git-flow git-extras npm node theme web-search battery)
I use the Sublime Text 3 plugin which just creates a `st` alias. That’s probably the alias I use the most and it’s nice that I don’t have to set it up manually.
The web-search plugin is quite nice since now you can google or bing from the command line:
$ google bing
$ bing google
Explore all the plugins in ~/.oh-my-zsh/plugins to enable what fits your workflow. I discovered git-extras doing this which is really awesome.
So you wonder what’s the big deal about iTerm2? Well, the feature I use the most is splitting the window into multiple shells. Have a look at the Shell menu and try to learn/remember the keyboard shortcuts which are CMD-D and CMD-SHIFT-D to split horizontally or vertically with the current profile. That’s pretty much all you need. Usually I have one tab open per project I am working on. And then in each tab I split for as many processes as I am running. Usually it’s about 2-4. One is to run the gulp or grunt script with watchers. Others are for running a node.js webserver, MongoDB etc. and at least one shell to run git commands.
Follow us at @SalesforceUX.
Want to work with us? Contact uxcareers@salesforce.com
Check out the Salesforce Lightning Design System