Eric Banisadr my blog

Setting up my macOS Terminal: Zsh, Prezto, Solarized, vim

I recently got a new Macbook, and decided to set up my terminal the proper way, and how I wish I’d done it last time. It turns out that the process can be decently confusing, so I figured I’d write it down.

Ingredients

Zsh

Zsh, or Z shell, is an alternate shell (it replaces bash). It has some pretty cool features, like better tab completion and more customizability.

Prezto

Prezto is where a lot of the customizability of Zsh happens. I prefer it over Oh-my-zsh, because it’s faster, and gives better options for prompts, in my opinion.

Solarized

Solarized is a color scheme intended to be easily readable, and good looking. I think, it does a great job of both.

Solarized Example

The Process

  1. Install homebrew
  2. Use homebrew to install an updated version of zsh
  3. Install prezto
  4. Configure Solarized colors for the terminal
  5. Configure Solarized for use with vim

Installing homebrew

Homebrew is a package manager for macOS. It makes installing zsh easy.

Homebrew’s setup is also really simple: run the command to download and run its install script.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Installing an updated version of Zsh

First, get the new version via homebrew.

brew install zsh

Next, add it to /etc/shells so that you can set it as the default shell via chsh.

echo "/usr/local/bin/zsh" | sudo tee -a  /etc/shells

Make the new Zsh the default

chsh -s /usr/local/bin/zsh

Installing Prezto

Open a new terminal window, or manually launch zsh. (Zsh will probably run you through the first time setup, which you can configure, but the defaults aren’t bad.) Then, clone Prezto directly to ~/.zprezto.

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

Then, create the .zpreztorc and other config files by running the following, from zsh:

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

Optionally, change the prompt theme. I use steef, but you can pick from a list of the default zprezto themes (and a few others).

Setting up Solarized

Clone the solarized repo somewhere (I put it in ~/Documents)

cd ~/Documents;\
git clone https://github.com/altercation/solarized

Next, use Terminal.app’s native method of setting colors: from the menu bar, select Terminal > Preferences. Then, choose profiles and find the option to import a profile.

Import profile

Look in the repo you cloned for /solarized/osx-terminal.app-colors-solarized/xterm-256color/, then select the either the light or dark version. Make sure to get the xterm-256color version, which is one level deeper than the regular version. Click the button to the right of the options gear to make it your default colorscheme. Then, make sure that the Terminfo field under Advanced declares the terminal as xterm-256color.

Open a new session to check out your new color profile.

Setting up Solarized in vim

This is the trickiest part, and I didn’t find a perfect way to do it. The default version of the Solarized vim colorscheme doesn’t quite work properly, and the background setting conflicts with Terminal.app’s default. Thus, I hacked my own solution together, but please let me know if you find a better one.