Gaining efficiency with iTerm Prompt customization on MacOS

Beatriz Martínez Rubio
Jan 3 · 6 min read

iTerm and Zsh

1. Install iTerm

$ brew install iterm2

2. Install ZSH and ZSH completions

$ brew install zsh zsh-completions

3. Install Oh My Zsh on top of ZSH

curl -L | sh

4. Configure the scheme theme

iTerm → Profiles → Open profiles → Select Default → Edit Profile → Select Default → Other actions → Duplicate profile → In the new created profile, general tab menu you can change the name 
General tab in Custom profile
In the Colors tab → Color presets... → Import → Select the downloaded scheme file
Import color scheme for Custom profile
Now, Color presets... → select you-color-scheme-name
Choose the new recently added color scheme
iTerm → Profiles → Custom

5. Configure fonts

Install the two downloaded fonts
iTerm2 → Profiles → Open Profiles... → Select previously created Custom Profile → Edit profiles → Text tab → Change Font
Add the new Meslo font to iTerm

6. Getting Powerlevel9k Zsh configured

$ git clone ~/.oh-my-zsh/custom/themes/powerlevel9k
Clone powerlevel9k from GitHub
Edit .zshrc configuration file
powerlevel9k example configuration style

7. Go further with the customization

A shorter prompt

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
Shorter prompt removing <usersame>@<user>s-mbp

Oh My Zsh auto-suggestions

$ git clone $ZSH_CUSTOM/plugins/zsh-autosuggestions

iTerm2 → Profiles → Open Profiles... → Select Custom → Edit Profiles...→ In the Colors tab → Check Black Bright
Customize suggestions colour
Suggestion example

kubectl completion

source <(kubectl completion zsh)  # setup autocomplete in zsh into the current shell
echo "if [ $commands[kubectl] ]; then source <(kubectl completion zsh); fi" >> ~/.zshrc

Set vertical cursor

Default cursor configuration
Custom vertical cursor
iTerm2 → Profiles → Open profiles... → Select Custom → Edit profiles... → Text tab → Set Vertical Bar for Cursor → Click Blinking cursor
Configuring vertical cursor

Syntax highlighting

$ brew install zsh-syntax-highlighting
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Command highlight example

Text navigation

iTerm2 → Profiles → Open profiles... → Select Custom → Edit profiles... → Keys tab → Load Preset… → Natural Text Editing
Keys menu: Natural Text Editing

Keep path when opening new tab

iTerm2 → Profiles → Open profiles... → Select Custom → Edit profile → General tab → Reuse previous session's directory
Keep path in new tabs

8. Set your custom theme as default

iTerm2 → Profiles → Open profiles... → Select Custom → Other actions → Set as Default
Set Custom profile as default

Used sources and posts:

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade