Setup your beautiful and powerful terminal with ZSH + Oh My Zsh + Powerlevel10k

03 October 2021

Final results of this setup.
The final results of this setup.

This is the terminal setup I’ve been using for a while. In this post, I’ll provide the instruction to replicate my setup.

1. Install ZSH (if not installed)

sudo apt-get install zsh

2. Set ZSH as the Default shell

whereis zsh
# You should see something similar to below:
# zsh: /usr/bin/zsh /usr/lib/x86_64-linux-gnu/zsh /bin/zsh /etc/zsh /usr/share/zsh /usr/share/man/man1/zsh.1.gz

We can see that the ZSH shell is /usr/bin/zsh.

Then we set the deault shell to this path.

chsh -s /usr/bin/zsh

Note that sudo is not needed here as we only change the default shell for our current user. If you don’t have the proper permission to do this, ask the server administrator to change it for you.

Administrators may use the following command to change the default shell for a specific user:

sudo chsh -s /user/bin/zsh username

Close the session and start again. You should see the Z shell configuration pops up.

Select 0 to exit and create an empty .zshrc file which we will be modifying later.

3. Install oh-my-zsh

Here we use the basic installation method from official tutorial https://github.com/ohmyzsh/ohmyzsh#basic-installation. Feel free to checkout the official repo for other methods.

Option 1: via curl

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

Option 2: via wget (if curl is not available)

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

4. Install powerlevel-10k

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

Then set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc

5. Final configuration.

Restart the session, you should see a powerlevel10k configuration interface. You can explore the configuration and change whatever you like. Finish the basic setting then download my config:

wget https://raw.githubusercontent.com/xwying/p10kconfig/master/.p10k.zsh

Restart the session and you are all set.

6. Appendix: Anaconda/Miniconda init ZSH:

If you see zsh: command not found: conda error, use the following command to initialize conda in zsh.

source miniconda3/bin/activate
conda init zsh