How to Install Oh My Zsh for WSL 2 on Windows 10
The Z shell (zsh) is a popular alternative to the default Bourne-again shell (bash) in Unix-like systems. The popularity of zsh -- especially among developers -- may be attributed to “Oh My Zsh."
Oh My Zsh is an open-source and community-based platform which provides useful plugins, functions and themes for personalizing your Z shell experience.
In this guide, we are going to install zsh and oh my zsh on Linux running on WSL 2.
On Ubuntu Linux and other Debian-based distributions, run sudo apt-get install zsh
shx@DESKTOP-P6O4TPP:~$ sudo apt-get install zsh
On Redhat-based systems; including CentOS and Fedora, run yum install zsh
shx@DESKTOP-P6O4TPP:~$ yum install zsh
Set zsh as Default Shell
After you have successfully installed zsh, you can set it as your default shell by running chsh -s /bin/zsh
shx@DESKTOP-P6O4TPP:~$ chsh -s /bin/zsh
You may now close the terminal and launch it again for the change to take effect.
Upon launching the terminal again, you should see the Z Shell configuration function message. Press 0 to create the zsh startup file.
At the new prompt that appears, type echo $SHELL to verify that you are now using zsh.
DESKTOP-P6O4TPP% echo $SHELL /bin/zsh
Install oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
DESKTOP-P6O4TPP% sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" Cloning Oh My Zsh... Cloning into '/home/shx/.oh-my-zsh'...
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
DESKTOP-P6O4TPP% sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
Install Themes and Plugins
As earlier mentioned, Oh My Zsh allows you to customize your zsh experience using themes and plugins. You can check out the Github links below to find what you like.
Install a new theme
For example, I am going to change my theme from the default "robbyrussel" to "amuse" by modifying the .zshrc file in my home directory. You can use your favourite text editor. I am using nano in this example.
➜ ~ nano ~/.zshrc
I would simply update the value of ZSH_THEME to "amuse" and then press CTRL + O on the keyboard; and hit enter to confirm the change.
Closing the terminal and launching it again allows the change to take effect. Here is what my new theme looks like.
To completely disable themes, you can set ZSH_THEME to an empty string as follows: ZSH_THEME=""
Install a new plugin
To install a plugin, modify the .zshrc file and update the value of the plugins array as desired. In the example below, I have installed the adb plugin alongside the default git plugin.
Once done, close and launch the terminal again to allow the changes to take effect.
Now you may scream, "Oh My Zsh!" We hope that you explore and enjoy your new zsh experience. If you have any questions or comments regarding this article, do let us know in the comments section below.
* You will receive the latest news and updates directly to your inbox !