Tales of configuring ZSH on Mac

Kendall
Weavik
Published in
3 min readOct 7, 2020

Once upon a time, a developer joined a small company and was given a machine with which to unlock the mighty powers of coding and productivity… Known as “Mac,” this machine promised the world, with only one seeming obstacle…the terrifying beast known as “configuration”!

There are several things I will always do when configuring a new machine. Caps Lock is the first to go, a perfectly useless function that is infinitely better as an extra Escape key. Thankfully Apple makes this extremely easy, with a dedicated path to follow to painlessly remap the keys. This is followed shortly by installing Vim and its keybindings everywhere that supports them (VSCode, iTerm, etc), as I have really grown to appreciate the productivity boost this brings. The final and most dreaded step is selecting and configuring a terminal, as something always seems to go haywire around this point.

Replacing Caps Lock with Escape is a must! Think about how often you use both…now go ahead and disable Caps Lock!

The adventure begins

My terminal of choice has always been iTerm2 (in a Mac environment), harkening back to my first days as a fledgling developer in an unfamiliar environment (read: copying everyone else’s setup). However, I soon adopted iTerm as my own, and have been enjoying the journey ever since! The only speedbump in the road is configuration; specifically, configuring oh-my-ZSH and the dreaded Powerline fonts.

Default iTerm2 installation…rather uninspiring, no?

After installing iTerm2, the relatively bland interface reminds me why configuration is so vital. Installing oh-my-ZSH itself is quite painless (Installation Guide), and cleans up the terminal quite a bit…but we’re just getting started!

With this behind us, we can jump immediately to “the beast”!

Slaying the Beast of Configuration?

Selecting a ZSH theme can be an onerous task, given the vast quanity of delectable options available. My first exposure to Vim plugins was through powerline configuration, so it is no surprise that I choose powerlevel10k.

This spiritual successor of powerlevel9k has supremely revamped the configuration process, enabling a much smoother setup experience! After installing powerlevel10k and adding the theme to my ~/.zshrc (ie.ZSH_THEME="powerlevel10k/powerlevel10k ), configuration is a breeze! Simply source ~/.zshrc and the configuration editor will appear!

It is important to allow powerlevel10k to install the recommended Meslo fonts! Refusing will negate all the hard work so far, as the pretty colors/icons/whatever will simply not work (well/at all). After the fonts have been installed, it may wish to restart. Upon reopening, it will either pick up again or can be started with p10k configure.

Any configuration from here is subjective, but I have included my configuration steps. After answering several questions to ensure the fonts loaded correctly, I launched into the remaining options:

  • Prompt style: Rainbox (easier to theme, etc)
    Character set: Unicode (enables pretty decorations)
  • Show current time: No
  • Prompt separators: Angled
    Prompt heads: Sharp
    Prompt tails: Flat
  • Prompt height: 2 lines
    Prompt connection: Dotted
    Prompt frame: None
    Connection color: Darkest
  • Prompt spacing: Sparse
  • Icons: Many icons
  • Prompt flow: Concise
  • Enable transient prompt: Yes (cleanly removes prompts from previous lines)
  • Instant prompt mode: Verbose
  • Overwrite file: Yes

And just like that, the terminal has been drastically improved (still more to go though)

The resulting configuration (~/.p10k.zsh) can still be completely customized, with a relatively easy-to-follow format.

Just how much easier this is than previous iterations of the tool cannot be stressed enough!

Basking in the glow of victory

As it turns out, the bulk of the work was actually done by the amazing devs behind powerlevel10k! The rest of the configuration battle was melodramatic… I downloaded the (patched) Solarized color scheme, enabled the vi-mode plugin mode, installed ZSH autosuggestions and syntax highlighting, modified my .vimrc, and then rode off into the sunset!

A great Gist by kevin-smets that goes through some of these!

--

--