DEV Community

Cover image for Setup Zsh on Ubuntu (How and Why)
Kanak Tanwar
Kanak Tanwar

Posted on

Setup Zsh on Ubuntu (How and Why)

I have been using Zsh for a really long time. Why? I don't know just because. And, it is pretty cool. You can get a ton of customizations make your terminal look better and feel help yourself feel like a better developer (you r not).

Well, anyways I sort of fked up my graphic drivers and has to reinstall Ubuntu and set up everything (including Zsh) so I thought I'd write article while I am at it.

Psh, this setup is for Ubuntu only, incase u didn't read the title ;)


What is Zsh?

Zsh(short for Z shell) is a shell...

Ok so on a serious note, Zsh is a program that lets you interact with your computer using commands instead of clicking around with a mouse. So... it is a shell.
That's it.

The great thing about Zsh however is that it has a ton of options for customizations unlike Bash which is the default shell in Ubuntu.


Why is Zsh better than Bash?

  • Rich customization
  • Better plugins
  • Stronger autosuggestions and tab completions
  • Cooler

Zsh
(isn't this so much better that out of the box bash?)


Setting up Zsh

1) Make sure your system is up to date before starting.

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode



2) Install Zsh

sudo apt install zsh -y
Enter fullscreen mode Exit fullscreen mode



3) Change default shell to Zsh

chsh -s /usr/bin/zsh
Enter fullscreen mode Exit fullscreen mode

You may need to restart the terminal for this to take place.



4) Install Oh My Zsh

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

Oh My Zsh allows you to easily manage your Zsh configuration.
Oh My Zsh



5) Install powerline fonts

sudo apt-get install fonts-powerline
Enter fullscreen mode Exit fullscreen mode

Helps improve prompt visuals



6) Install powerlevel10k

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

Powerlevel10k is a custom theme for Zsh. Like dark/light themes, but more powerful



7) Install dconf-cli

sudo apt-get install dconf-cli
Enter fullscreen mode Exit fullscreen mode



8) Install Zsh Plugins

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
Enter fullscreen mode Exit fullscreen mode

Zsh has a lot of plugins. These 2 will give syntax highlighting and autosuggestion based on history.



9) Update ~/.zshrc

Now we need to update the ~/.zshrc file so that all the changes we have made can take effect.

nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Find a line which says ZSH_THEME="<theme_name>" and replace it with ZSH_THEME="powerlevel10k/powerlevel10k"

Find a line which says plugins=(git) and replace it with plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Now exit the editor and apply the changes you made using

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode



10) Customize using powerlevel10k

You can now use the powerlevel10k (p10k) theme to customize your terminal. It will ask you some questions which you just have to answer and you will be done.

It is possible that the configuration will run automatically after you source the .zshrc file. If it does not then you can run it with the following command. This can be repeated anytime in the future.

p10k configure
Enter fullscreen mode Exit fullscreen mode

And you are done.

If at any point some effects do not seem to take place close and reopen the terminal.

Thanks. Bye.

Top comments (1)

Collapse
 
aarushi_bhatia_578922f673 profile image
Aarushi Bhatia

Cool!