Syed Umar AnisCommand LineEnhance the zsh terminal experience with plugins, themes and auto-completions
Syed Umar AnisCommand LineEnhance the zsh terminal experience with plugins, themes and auto-completions

I use a Mac, but the instructions provided should also be applicable to the Zsh terminal on Linux.

Terminal Emulator

The default terminal application on Mac OS is good, but there are more feature-rich terminals out there. Personally, I use WezTerm as I found it more performant in certain multiplexer scenarios. You can choose from the following:

Terminal NameGithub StarsDeveloped InComments
WezTerm10.9 KRustFeature-rich (built-in multiplexer) and cross-platform
Alacritty49.4 KRustMinimal and fast
Kitty20.3 KC & Python
iTerm214 KObjective-CFeels a bit dated, MacOS only

To install Wezterm, you can download the package from the WezTerm website.

Custom Prompt

When customising the prompt there are a few different ways to go about it.

  • oh-my-zsh is a framework for managing zsh configuration including theme and plugins. It offers over 140+ themes.
  • Starship is a cross-shell customisable prompt.
  • powerlevel10k is a Zsh theme. I use powerlevel10k as it is fast, looks pretty good and is easy to configure using a wizard.

Let’s start by customising the prompt using the powerlevel10k theme.

Install powerlevel10k. I use Homebrew as a package manager, you find the installation instructions specific to your OS on the powerlevel10k GitHub page.

brew install powerlevel10k
echo "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc

Restart the terminal to get into the Powerlevel10k configuration wizard.

This is how my prompt looks after going through the wizard.

And here is the prompt when I am in a git repo.

Ok. The prompt looks good now.

Auto Suggestion

Now we are going to the configure auto-suggestion. It suggests a completion as we type on the prompt based on history. zsh-autosuggestions is widely used (27.9 K Github stars) to achieve this.

You can find the detailed installation instructions here.

brew install zsh-autosuggestions
echo "source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" >>~/.zshrc

Restart the terminal to start getting suggestions. Suggestions can be completed using the right arrow.

Syntax Highlighting

The popular plugin for syntax highlighting is zsh-syntax-highlighting (18K Github stars) but I have found fast-syntax-highlighting (826 Github stars) to be faster and nicer.

brew install zsh-fast-syntax-highlighting
echo "source /opt/homebrew/opt/zsh-fast-syntax-highlighting/share/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" >>~/.zshrc

It looks so much better now with syntax highlighting.

Auto-Completion

Auto Completion is a very powerful plugin that provides real-time typeahead completion for popular commands.

Let’s install zsh-autocomplete (4K Github stars).

brew install zsh-autocomplete
echo "source /opt/homebrew/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh" >>~/.zshrc

It can suggest relevant git command options with the explanation.

You can choose directories using arrow keys based on the context.

It can suggest available branches to checkout.

If completion is not working for your favourite command, you can often download and install it from the web.

Homebrew completions can be set up by adding the following to your ~/.zshrc

# add homebrew completions
if type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"

  autoload -Uz compinit
  compinit
fi

Check out zsh-completions, it has a lot of additional completions. If you want to install both zsh-completions and Homebrew completions, then follow the instructions here.

zsh-autocomplete (don’t mix with zsh-completions) also provides useful enhancements for working with history.

  • Press Ctrl + R to perform a fuzzy history search listing multiple results
  • Press the Up arrow to bring up a recent history menu

Hi, I’m Umar

2 Comments

    1. Hi Roshin,
      I have used WARP and like it a lot – its text editing support with OS-like keyboard shortcuts, a touch of AI (like you said) and just all-around great features out-of-the-box.

      But I didn’t include it here on purpose because it doesn’t follow the Unix philosophy of `do one thing and do it well`. WARP tries to do everything itself and doesn’t play nice with other tools like multiplexers. Moreover, it is not open source.

Leave a Reply

Your email address will not be published. Required fields are marked *