Configuring iTerm2 with Zsh and Powerlevel9k Theme for a Modern Terminal

Prerequisites

Ensure Git, curl, and wget are installed on your system before proceeding. On macOS, these are typically available through Xcode command line tools.

Installation Overview

  1. Install iTerm2
  2. Configure color scheme
  3. Set up zsh
  4. Install oh-my-zsh framework
  5. Configure powerlevel9k theme
  6. Install Powerline fonts

Installing iTerm2

Download iTerm2 from the official website at https://iterm2.com/ and install it by double-clicking the downloaded package.

Applying Color Scheme

Download the Solarized Dark Higher Contrast color scheme and save it as SolarizedDarkHigherContrast.itermcolors (macOS may automatically append .xml, so rename the file after saving to remove the extansion).

Double-click the file to import it into iTerm2. Then navigate to: iTerm2 → Preferences → Profiles → Colors → Color Presets → SolarizedDarkHigherContrast.

Setting Up Zsh

Checking Zsh Installation

zsh --version

macOS ships with zsh pre-installed. If you see version output like zsh 5.3, it's already available.

Switching Default Shell

echo $SHELL

To set zsh as your default shell:

chsh -s /bin/zsh

On some systems, this may fail. An alternative approach:

export SHELL=/bin/zsh
exec /bin/zsh -l

Installing Oh-My-Zsh

Using curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Using wget

sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Configuring Powerlevel9k Theme

Cloning the Theme

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

Activating the Theme

Open ~/.zshrc and add:

ZSH_THEME="powerlevel9k/powerlevel9k"

Customizing Prompt Appearance

Simplifying the Username Display

Default prompts often show user@hostname, which can be redundant with powerlevel9k. Add this to ~/.zshrc:

DEFAULT_USER="your_username"

Replace your_username with your actual system username for this to function correctly.

Adjusting Prompt Elements

Modify the left and right prompt segments in ~/.zshrc:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs time)

Adding Syntax Highlighting

Installing the Plugin

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

Configuring the Plugin

Edit ~/.zshrc and ensure the plugin loads last:

plugins=(
  git
  extract
  z
  zsh-syntax-highlighting
)

Activating Changes

source ~/.zshrc

Installing Powerline Fonts

The question marks appearing in your prompt indicate missing font support. Install Powerline-compatible fonts:

git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
cd ..
rm -rf fonts

Configuring Font in iTerm2

Navigate to iTerm2 → Preferences → Profiles → Text → Font. Click Change Font and select a font containing "for Powerline" in its name. Enable the checkbox for Use a different font for non-ASCII text and select the same Powerline-compatible font for that option as well.

Restart iTerm2 for the changes to take effect.

Essential Oh-My-Zsh Plugins

The framework includes numerous plugins installed by default:

  • git: Version control shortcuts (enabled by default)
  • extract: Unpacks any archive format with x filename
  • z: Navigates to previous visited directories using fuzzy matching

Managing Custom Plugins

Plugins can be placed in two directories:

  • ~/.oh-my-zsh/plugins: Official plugins directory
  • ~/.oh-my-zsh/custom/plugins: Third-party plugins

Place plugin files in either directory and add the plugin name to the plugins array in ~/.zshrc.

Ensuring Configuration Loads

If plugins or theme changes don't appear to work, verify your ~/.zshrc contains:

export ZSH="$HOME/.oh-my-zsh"
source $ZSH/oh-my-zsh.sh

Then reload the configuration:

source ~/.zshrc

Tags: macOS iTerm2 Zsh oh-my-zsh powerlevel9k

Posted on Tue, 27 Oct 2026 16:53:08 +0000 by Zephyr_Pure