My Zsh Setup

Quick notes on installing and customizing Zsh on Ubuntu 22.04 (or any Linux machine).

sudo apt install zsh

Oh My Zsh

Let’s improve its look and functionality via Oh My Zsh

Open BASH:

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

Not

Please install git before the curl if it is not installed, sudo apt install git

Keep default shell to BASH (my preference for other tools, just in case, like PetaLinux)

powerlevel10k

Do you want to change your default shell to zsh? [Y/n] n

Now let’s install powerlevel10k.

Not

If you, like me, are not planning to use Unicode in the subsequent steps of configuring powerlevel10k, you might not need this font. However, I’m not 100% sure as I haven’t conducted a well-controlled experiment.

First install the recommended font: Meslo Nerd Font patched for Powerlevel10k Link

Download all 4 .ttf files.

Install fonts locally:

mkdir -p ~/.fonts
cp *.ttf ~/.fonts/
fc-cache

For GNOME terminal, verbatim from powerlevel10k documentation:

GNOME Terminal (the default Ubuntu terminal): Open Terminal → Preferences and click on the selected profile under Profiles. Check Custom font under Text Appearance and select MesloLGS NF Regular.

If you are not able to see that font in preferences, you might need to close all GNOME Terminal instances and relaunch a terminal window.

Then download the theme for Oh My Zsh:

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc. The default one was ZSH_THEME="robbyrussell" in my case.

Then open zsh.

When we first open zsh after installation, we will see powerlevel10k installation wizard like that:

../../_images/zsh-1.png

powerlevel10k installation wizard

You can modify the shell’s appearance to suit your taste, but here are my choices:

diamond y
lock y
upwards arrow y
fit between the crosses y
-
prompt style: 1 lean
character set: 2 ascii
prompt colors: 1 256 colors
Show current time?: 2 24-hour format.
Prompt Height: 1 one line
Prompt Spacing: 1 compact
Prompt Flow: 1 concise
Enable Transient Prompt?: n no
Instant Prompt Mode: 3 off
Apply changes: y yes

Run p10k configure anytime to reconfigure it.

Now we can use our new theme. Let’s add some plugins!

plugins

We can use Oh My Zsh plugins to enrich our shell experience:

My .zshrc:

ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git git-prompt sudo zsh-autosuggestions you-should-use zsh-syntax-highlighting)

In action

My theme and plugins in action:

Published on: 2024-01-27