My switch to Zsh with Antigen

I have long preferred Bash over Zsh for one simple reason. Speed. Zsh, with all its awesome features is just the tiniest amount slower than Bash. And with some good dotfiles, you can pimp out your bash to work great. I have used Paul Irish’s dotfiles for my Mac for the last couple of years.

Paul Irish has dotfiles that are tailor-made for a mac. Apart from the obvious goodies like syntax highlight, z jumps, and the obvious aliases, they also include script files to install common packages, and some seriously funny aliases, and useful little functions.

Two of my favourites:

But one feature pushed me over the edge — autosuggestions. Here’s a demo:


If there is one thing faster than quick keyboard shortcuts, its not typing at all. Once I saw this, I had to have it. I looked and looked, but couldn’t find anything similar for Bash.

Now, in Zsh land I immediately looked for a way to pimp out my terminal. My initial searches led me to oh-my-zsh, this awesome project full of themes and plug-ins that made me laugh at my earlier self for sticking to bash.

I almost pulled the trigger but then, I found Antigen. Antigen is amazing. Think of it like brew or npm for your terminal.

Once you have antigen installed, all you need to do is type…

$ antigen bundle common-aliases

…And you immediately have the common-aliases bundle available for use in your terminal. The best part? Your favourite oh-my-zsh bundles come along for the ride. Antigen defaults to oh-my-zsh for the locations of all bundles.

Using a custom theme is just as easy:

$ antigen theme gnzh

You can obviously, also pass github URLs and file-paths for bundles and themes outside the oh-my-zsh collection.

Just list these commands down in your .zshrc file and you’re done. Antigen manages everything else.

zsh-autosuggesions, however is a little more complicated to be just a simple bundle. But thankfully, it comes with its own installer that handles everything. There was one small error in its installer, that put the incorrect folder path in the .zshrc file, but that was easy enough to fix.

And just like that, in under 10 minutes, I was able to set-up my terminal to save me precious seconds every minute I’m at my machine.

Just to drive the point home, here is my entire .zshrc file:

source /Users/nmn/antigen/antigen.zsh

# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle pip
antigen bundle lein
antigen bundle command-not-found
antigen bundle autojump
antigen bundle brew
antigen bundle common-aliases
antigen bundle compleat
antigen bundle git-extras
antigen bundle git-flow
antigen bundle npm
antigen bundle osx
antigen bundle web-search
antigen bundle z
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search ./zsh-history-substring-search.zsh

# Load the theme.
antigen theme gnzh

# Tell antigen that you're done.
antigen apply

# Setup zsh-autosuggestions
source /Users/nmn/.zsh-autosuggestions/autosuggestions.zsh

# Enable autosuggestions automatically
zle-line-init() {
    zle autosuggest-start

zle -N zle-line-init

There are still a few awesome things missing from the Paul Irish dotfiles, but I’m working to bring them back. Hopefully, I can package them up in my own zsh bundles, so I can just drop a few more lines into my .zshrc file.

If you haven’t tried zsh yet, or have always thought that terminal configuration was too hard/geeky, go give antigen a try. If you use the terminal on a daily basis, this will literally change your life.


Now read this

A Re-Introduction to Gulp

Forget everything you know about Gulp. Welcome to Gulp 4. If you’re a front-end developer you surely have a build process in place. You maybe using Grunt, Gulp, Broccoli, NPM scripts etc. If everything works for you and you understand... Continue →