Pimp up iTerm with Zsh and prezto on Mac OS X

2016-09-12

Follow this simple steps to setup zsh and prezto on Mac OS X (El Capitan) and you command line will look like:



Install Zsh

Install Zsh and Zsh Completions

1
$ brew install zsh zsh-completions

Then try to run zsh:

1
$ zsh

When zsh opens for the first time, choose option 0.

OPTIONAL:

At this stage I ran into some errors similar to dyld: Library not loaded: /usr/local/lib/libgdbm.4.dylib.

Follow these steps to fix:

  • First change the ownership of /usr/local
1
2
$ cd /usr/local
$ sudo chown -R <uid>:<gid> *

Retrieve the values of <uid> and <gid> by running id in your terminal.

  • Reinstall gdbm and pcre
1
2
$ brew install gdbm
$ brew reinstall pcre

And you should be ready to go

Install Prezto

Install with

1
$ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

Create a zsh config with the files from prezto

1
2
3
4
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

Make Zsh the default shell

1
$ chsh -s $(which zsh)

If you are using iTerm, go to

1
Preferences > Profiles > General > Command

and put /bin/zsh --login as the Command (instead of Login Shell)

Improve the default theme

Install the Menlo Font

Download the Menlo font

Double click the font file to install it.

Set it as the default font in iTerm by going to

1
Preferences > Profiles > Text > Change Font

Use 14pt for the font size.

Set the theme to Solarized Dark

In iTerm, go to Preferences > Profiles > Color and in the Color Presets Dropdown, choose Solarized Dark.

Change the prezto theme to powerline

First go to your zsh command line, type prompt powerline and doublecheck that everything displays properly. This command is to preview the theme.

Then set the powerline theme as default in .zpreztorc:

Look for the line that looks like zstyle ':prezto:module:prompt' theme and replace the current theme with powerline

You should end up with:

1
zstyle ':prezto:module:prompt' theme 'powerline'

Now, try restarting iTerm and doublecheck that powerline is the default theme

Word jump

Let’s finish with one more tweak, word jump with alt + → and alt + ← like in a normal editor.

In iTerm, go to Preferences > Profiles > Keys and Add the following

1
2
3
⌥ →
Send Escape Sequence
f

and

1
2
3
⌥ ←
Send Escape Sequence
b

Word Delete

Do the same thing to allow the deletion of a word on alt + backspace

1
2
3
⌥⌫
Send Hex Code
0x17

That’s it, you are good to go. Let me know if you enjoy it and if you have awesome tweaks I should add to this list.