Setting up Zsh with Oh-My-Zsh
Set up beautiful terminal using Zsh with Oh-My-Zsh and install custom theme and plugins
Before Starting
Links
- Official site of Zsh
- Official site of Oh My Zsh
- Official repository of Powerlevel10k
- Unofficial installation guide
Supported Installation
This installation procedure is tested on Ubuntu 22.04.x LTS
with x86_64 architecture
, but should be compatible with other Linux distributions and macOS.
Installation
Install dependencies
It's recommended to install Nerd Font in this step to avoid display problems.
If Nerd Font isn't properly installed, you will not be able to experience the full functionality of Powerlevel10k.
- Install dependencies:
sudo apt install fontconfig
- Download and install one of the nerd font:
- Install fonts:
- Move all fonts to
/usr/local/share/fonts/TTF
- If the directory doesn't exist, create one
- Rebuild the font cache with
fc-cache -f -v
- Move all fonts to
Install Zsh
Set Zsh as default shell
Install On My Zsh
Install Powerlevel10k
Switch the theme to Powerlevel10k by editing the config file which located in /home/$USER/.zshrc
(~/.zshrc
).
Change the line ZSH_THEME="robbyrussell"
to ZSH_THEME="powerlevel10k/powerlevel10k"
.
Apply the changes by executing source /home/$USER/.zshrc
(source ~/.zshrc
).
The Powerlevel10k configuration wizard should be started automatically.
If it doesn't, execute p10k configure
to start the configuration wizard.
Choose your favorites configuration!
My personal favorite configs are: 3121132342221y1y
(Start from "Prompt Style")
Install plugins (Optional)
Zsh-Completions
Additional completion definitions for Zsh.
Zsh-Autosuggestions
It suggests commands as you type based on history and completions.
Zsh-Syntax-Highlighting
It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal.
Finally, add the following configuration to .zshrc
:
Apply the changes by executing source /home/$USER/.zshrc
(source ~/.zshrc
).
Finishing
Enjoy your perfect terminal with fantastic looking, autosuggestions and syntax-highlighting~
Little tip
Fix prompt at the bottom
Add the following lines to the end of .zshrc
file to anchor the prompt to the bottom of the terminal window.
The original "clear" command is now called
_clear
.
Warp terminal patch
If you are using Warp terminal with powerlevel10k multi-line prompt, you may face the issue of the prompt and input on different lines.
To fix the issue, create a seperate configuration file that uses powerlevel10k one-line prompt at home directory and name it .p10k-warp.zsh
.
Finally, replace the line [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
in .zshrc
with the following one.
Don't forget to run source ~/.zshrc
to apply the changes.