LINUX: "zsh" Theme I use

LINUX: "zsh" Theme I use

While trying to setup RHEL with WSL 2, I stumbled upon this very helpful blog https://wsl.dev/mobyrhel8/

While doing the setup, I found this zsh theme very nice, and I have been using it since then. The above mentioned blog already has the steps, but it has a lot of other info about setting up RHEL in WSL2 as well. So here is the extract of setting up the zsh theme (steps are for RHEL8, might differ for other Linux dists).

1. Setup ZShell

If the zsh is not already installed, then install zsh.

dnf install -y sudo zsh cracklib-dicts

2. Install "Oh My Zsh"

Oh My Zsh is the configuration manager being used for this

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

3. Update user to use zsh as the default shell

Find the location of zsh installation

cat /etc/shells

Use vi editor to update the default shell of the user to zsh by replacing the path (example: ec2-user is the user we are working with)

sudo vi /etc/passwd

4. Update zsh config file

As written in the installation message, we can now change the zsh config file. For now, we will only change the theme to Fino Theme.

vi $HOME/.zshrc

In the opened vi editor, look for the key ZSH_THEME and update it as below:

ZSH_THEME="fino-time"

Check if the config file got updated, and then load the new config file.

# [Optional] Check if the theme value has been correctly saved
grep ZSH_THEME $HOME/.zshrc

# Reload the zsh configuration file
source $HOME/.zshrc

5. Update theme settings

Open the theme settings in vi editor

vi $HOME/.oh-my-zsh/themes/fino-time.zsh-theme

Look for the PROMPT variable and modify it to add the variables

PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name) (WSL: $WSL_DISTRO_NAME | kernel: $(uname -r))%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}\$(git_prompt_info)\$(ruby_prompt_info)
╰─ %* \$(virtualenv_info)\$(prompt_char) "

Reload the zsh configuration file, it will also reload the oh my zsh theme

source $HOME/.zshrc

That's it, now we have a nice-looking theme that gives a lot more information without being too overwhelming. It has a nice clock in the prompt too.