The Linux shell can be replaced with zsh to open up a world of extra plugins, features and themes. And it’s a pretty nice UX/UI upgrade from bash tbh.
My zsh shown below, has been complimented with oh-my-zsh and the p10k theme with customised prompt elements.
The left-side prompt elements are: battery (86%), os_icon (ElementaryOS), dir, disk_usage (8%).
The right-side prompt elements are: status (exit status 0), load (load average 1.11), time (11:02:59).
There are other prompt elements available and they are listed at the end of this post. Have fun!
Your mileage may vary between different terminals, e.g. blackbox, gnome-terminal etc. Try opening alternative terminal emulators once zsh is set up to see the differences if any, and just stick with the one that works best for you.
Installation
sudo apt-get update && sudo apt-get install zsh git
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts
curl -fLo "MesloLGS NF Regular.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
curl -fLo "MesloLGS NF Bold.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
curl -fLo "MesloLGS NF Italic.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
curl -fLo "MesloLGS NF Bold Italic.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
fc-cache -fv
In your terminal of choice, replace the default font with "MesloLGS NF"
You could also try Cascadia Code Nerd Font or some of the others listed here
Install oh-my-zsh
Install oh-my-zsh to enable a framework that allows easy customisation of zsh.
sudo apt install curl wget
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Use the omz command to administer oh-my-zsh
More on using omz here
Install Powerlevel10K Theme for Zsh
Powerlevel10k or p10k is the coolest theme for zsh/oh-my-zsh and is an evolution of a fork of the famous powerlevel9k project.
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Edit your ~/.zshrc file and change the theme to
ZSH_THEME="powerlevel10k/powerlevel10k"
After modification to the ~/.zshrc file, reload the config with,
source ~/.zshrc
When you first run the shell with the p10k theme installed, there is no config file set up, so a convenient wizard will automatically ask you some questions. More on the wizard here, but it’s fairly self-explanatory.
p10k has a number of customisable prompt elements. You will be prompted by a wizard upon first execution of the theme and it will run through various options/choices to create the .p10k.zsh config file sourced by your .zshrc file.
vi ~/.p10k.zsh and edit the left and right prompt elements contained in the following two sections.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
os_icon
dir
vcs
...
)
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
status
command_execution_time
background_jobs
...
)
After any changes,
source ~/.p10k.zsh
Add syntax-highlighting, auto-suggestion and auto-correction
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Auto-correction exemptions
If you make a mistake, zsh will offer a correction. If you have certain commands or words that are repeatedly prompted with autocorrection options, you can add them to the exemption list in ~/.oh-my-zsh/lib/correction so those words will be ignored.
Find and edit the load plugins line in ~/.zshrc
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
source ~/.zshrc
If you're happy everything works, change your default shell in /etc/passwd for your user to /usr/bin/zsh permanently. This will not affect the root user when you sudo su - to elevate your privs to change to the root user for your system.
Prompt Elements
- os_icon: Operating system icon.
- dir: Current directory.
- vcs: Version control system (e.g., Git status).
- prompt_char: Prompt character.
- status: Exit status of the last command.
- command_execution_time: Duration of the last command.
- background_jobs: Indicator for background jobs.
- history: Command history number.
- time: Current time.
- date: Current date.
- battery: Battery status.
- user: Current user.
- hostname: Hostname of the machine.
- ip: IP address.
- load: System load.
- disk_usage: Disk usage.
- ram: RAM usage.
- swap: Swap usage.
- cpu: CPU usage.
- kubecontext: Kubernetes context.
- node_version: Node.js version.
- python_version: Python version.
- ruby_version: Ruby version.
- go_version: Go version.
- php_version: PHP version.
- java_version: Java version.
- aws: AWS profile.
- azure: Azure account.
- gcloud: Google Cloud account.
- terraform: Terraform workspace.
- nix_shell: Nix shell.
- context: Context (e.g., user@hostname).