Yay! So I switched job and got a new MacBook Pro. Good excuse to refresh my development (and terminal) setup. I have been using bash along with completion and git-prompt for as long as I can remember, this time I decided to cast my net wider and see what that world has been up to since I last spend time on this.

zsh, prezto

I’m sticking to iTerm2 as my preferred terminal application. As for the shell, I decided to take a look at zsh, seeing that it’s now the default shell with MacOS Catalina. I also wanted capabilities such as auto-completion, git integration - without a lot of effort ;-). After a bit of googling and reading, I picked prezto as my zsh configuration framework.

installing the tools

Installing iterm2 is simple with homebrew:

brew cask install iterm2

Zsh that comes with MacOS Catalina is quite current (v5.7.1), so I’ll just use the OS supplied version.

Next, install prezto with the following commands:

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

Alternatively, you can install from my fork which contains my modified theme:

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

followed by

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

tinkering

First, edit the modules section of ~/.zpreztorc to enable the desired modules. I’ve added a couple of modules as highlighted below:

# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'ssh' \ (1)
  'completion' \
  'git' \ (2)
  'syntax-highlighting' \ (3)
  'history-substring-search' \ (4)
  'prompt'
1 useful if you have passphrase protected your keys and/or often ssh over a bastion hosts
2 shows git information on your prompt
3 eh…​ syntax highlighting? Well, actually this also does syntax checking as you type
4 enable searching through command history using ctrl-r

themes

Tbh, this is a key motivation for me to explore prezto…​ The fancy prompt don’t make me a better developer, but it sure makes me look the part ;-)

This is how my prompt looks like:

prompt

It’s based on the paradox theme that comes with the prezto distribution, and available on my fork here

To use this theme, copy it to ~/zprezto/modules/prompt/functions/prompt_doxxed_setup, and edit ~/.zpreztorc like so:

# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'doxxed'

nerd fonts and glyphs

Notice the branch and chevron symbols in the screenshot above? Those are not in the standard character set, we need a patched/nerd font so that they display properly. You can find patched fonts here or here. I use the MesloLGS font from here. Just download and install the .ttf files.

If you’re only using zsh from iTerm2 exclusively, you can skip the fonts and just enable built-in Powerline glyphs in iTerm2, like so:

iterm2 glyphs

And while you’re at it, you can change the colour presets as well. I’m using 'Tango Dark' for the screenshot above.

iterm2 colorpreset

I use iTerm2’s built-in glyphs in iTerm2 as I feel they render better, and patched/nerd font in Visual Studio Code terminals. Overall, I’m pretty satisfied with this setup. Hope you find it useful too.