Software

It’s Over 9000 – ZSH Theme installation

What is ZSH

ZSH is an interactive shell, although it can also used as a powerful scripting language. Many of the useful features of bash, ksh, and tcsh were incorporated into zsh and many new features were added. It is basically just another shell so if you already have an expansive bashrc you will have to do a bit of rewriting…

Powerlevel9k

Powerlevel9k is used to create a theme for ZSH shell. It is used to create both very useful and beautiful terminal environments. This will allow you to get more out of your terminal and impress everyone.

Reference info: Powerlevel9k Github

Mac iTerm2

iTerm2 is a replacement for the native mac terminal app. It is fully open source and can be extensively configured to your personal preferences.

Reference info: iTerm2 Download

Fonts

Fonts are needed to display the custom icons that Powerlevel9k uses to display information in a graphical way. Examples of this are the Git icons, Check marks, OS icons, WiFi signal, and power indicators.

Reference info:Nerd Fonts

Installation and Setup

This is a Mac only set up but powerlevel9k and the fonts can be installed on linux as well. For this installation you will need git and Homebrew installed on your mac. First open the native terminal app to use brew and git.

Install the zsh shell

brew install zsh

Install Powerlevel9k

brew install powerlevel9k

Install your desired font (I use meslo)

brew tap caskroom/fonts 
brew cask install font-meslo-nerd-font

Now use git to clone the material design git repo. This contains the color profile for the iTerm2 application that we will be using as a replacement for the native terminal app.

git clone https://github.com/MartinSeeler/iterm2-material-design

Next you will need to download iTerm2 using this link: iTerm2

To set up the color profile open iTerm2 and navigate to iTerm2 > Preferences > Profiles > Colors Tab

Then Click Color Presets… and then Import…

Now select material-design-colors.itermcolors from the folder you just cloned.

Next we will select the Font for iTerm2, that we installed with brew, so that powerlevel9k will display the icons correctly. Otherwise the banners will just look like a bunch of gobbledygook. Navigate to iTerm2 > Preferences > Profiles > Text

Click Change Font and select the font corresponding to the one you installed with brew.

Next we want to set up iTerm2 to go directly into zsh when we open it. This can be done by navigating to the iTerm2 > Preferences > Profiles > General Tab

Then either select Login shell and Send text at start: zsh, or select Command and /usr/local/bin/zsh in the text box.

ZSH Setup

Now for the fun part! You need to configure your .zshrc file to set up powerlevel9k and define your desired theme. This can get complicated but there are a lot of .zshrc files that you can find on the powerlevel9k Show off your config. I based mine off the Sudhindra’s config on the “Show off your config” page and is available for you to copy below!

source /usr/local/opt/powerlevel9k/powerlevel9k.zsh-theme
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="yellow"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="black"

zsh_wifi_signal(){
        local output=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I)
        local airport=$(echo $output | grep 'AirPort' | awk -F': ' '{print $2}')

        if [ "$airport" = "Off" ]; then
                local color='%F{black}'
                echo -n "%{$color%}Wifi Off"
        else
                local ssid=$(echo $output | grep ' SSID' | awk -F': ' '{print $2}')
                local speed=$(echo $output | grep 'lastTxRate' | awk -F': ' '{print $2}')
                local color='%F{black}'

                [[ $speed -gt 100 ]] && color='%F{black}'
                [[ $speed -lt 50 ]] && color='%F{red}'

                echo -n "%{$color%}$speed Mbps \uf1eb%{%f%}" # removed char not in my PowerLine font
        fi
}

POWERLEVEL9K_CONTEXT_TEMPLATE='%n'
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND='white'
POWERLEVEL9K_BATTERY_CHARGING='yellow'
POWERLEVEL9K_BATTERY_CHARGED='green'
POWERLEVEL9K_BATTERY_DISCONNECTED='$DEFAULT_COLOR'
POWERLEVEL9K_BATTERY_LOW_THRESHOLD='10'
POWERLEVEL9K_BATTERY_LOW_COLOR='red'
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=''
POWERLEVEL9K_BATTERY_ICON='\uf1e6 '
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{014}\u2570%F{cyan}\uF460%F{073}\uF460%F{109}\uF460%f "
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
POWERLEVEL9K_VCS_UNTRACKED_ICON='?'

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon context battery vi_mode dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time dir_writable ip custom_wifi_signal)

POWERLEVEL9K_SHORTEN_DIR_LENGTH=1

POWERLEVEL9K_TIME_FORMAT="%D{\ue005 %H:%M}" #\uf073 %d/%m/%y}"
POWERLEVEL9K_TIME_BACKGROUND='white'
POWERLEVEL9K_RAM_BACKGROUND='yellow'
POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND="white"
POWERLEVEL9K_LOAD_WARNING_BACKGROUND="white"
POWERLEVEL9K_LOAD_NORMAL_BACKGROUND="white"
POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND="red"
POWERLEVEL9K_LOAD_WARNING_FOREGROUND="yellow"
POWERLEVEL9K_LOAD_NORMAL_FOREGROUND="black"
POWERLEVEL9K_LOAD_CRITICAL_VISUAL_IDENTIFIER_COLOR="red"
POWERLEVEL9K_LOAD_WARNING_VISUAL_IDENTIFIER_COLOR="yellow"
POWERLEVEL9K_LOAD_NORMAL_VISUAL_IDENTIFIER_COLOR="green"
POWERLEVEL9K_HOME_ICON=''
POWERLEVEL9K_HOME_SUB_ICON=''
POWERLEVEL9K_FOLDER_ICON=''
POWERLEVEL9K_STATUS_VERBOSE=true
POWERLEVEL9K_STATUS_CROSS=true

Update to PowerLevel 10k

I created an update post based on the new powerlevel10k check it out here