Installing Zsh and Oh-my-zsh on Windows 11 with WSL2Tech by Sunny Srinidhi - October 27, 2021October 27, 20211 Before we begin, you might ask, why am I writing on something this trivial? I sold off my old MacBook Pro because I’m super excited about the new M1 Pro MacBook Pros. I have pre-ordered one of those and am waiting for it to come. Till then, I’m left with my gaming PC which is an Asus Zephyrus. So I thought I’ll make the best of it till I get my Mac. This will be series of posts in which I show to setup a Windows 11 PC to work with big data tools and technologies, mostly Hadoop. So let’s get into it.Now that Windows 11 is officially available to the public, and given that Windows is the most popular operating system used by developers (according to stackoverflow, refer screenshot below), I thought it would be fun to install a new WSL system on my Windows 11 PC and try to set it up for big data tools. But before I could do that, I had to install Zsh and oh-my-zsh on it. I switched to using Zsh over half a decade ago and haven’t used Bash or any other shell ever. I just love how zsh look, the ability to theme it, and the community surrounding it. So, I started with zsh, and here is how you can install it too. Source: stackoverflowInstalling WSL2 on Windows 11The process of installing WSL on Windows 11 is not different than that on Windows 10. And if you are upgrading from a Windows 10 PC which already had WSL installed, you don’t even have to do anything extra. I already had mine setup on Windows 10 with Ubuntu 20.04 LTS. So that was readily available for me. But I wanted to setup everything fresh just to see if anything has changed (spoiler, it hasn’t). So I installed Debian this time.To install any distro of Linux on Windows 11, just open up the Microsoft Store and search for your favorite Linux distro. In the screenshot below, you can see that if I search for Ubuntu, I get multiple versions of Ubuntu listed in the store.Just select the version that you want to the install and click the Get button. After the installation is complete, the shell should open up automatically to complete the installation.Soon after the installation is complete, you’ll see the bash shell something like the screenshot below. As you can see, the prompt is pretty ugly, at least to me. I know I can customize it, but not to the extent of what’s already built into Zsh. Now that we have Debian installed, let’s start updating the packages and installing Zsh and oh-my-zsh.Installing Zsh and Oh-my-zshUpdating package list and upgrade packagesBefore we start installing any packages, we first to have to update the package list so that we can then upgrade all the packages that we have already installed, and also fetch the references to the latest version of all the dependencies. This is pretty simple and will take just a few seconds. Run the following command in the terminal to update the references:sudo apt updateOnce you update the package list, if you find any updates available, most probably you will, you can run the following command to upgrade all packages already installed. But let me also mention that this step is optional.sudo apt upgradeInstalling dependenciesNow that we have updated the package list, we have to install the dependencies that we’ll need to install Zsh and oh-my-zsh. The dependency list isn’t really exhaustive, it’s just two packages. If I’m not mistaken, these two packages must come pre-installed if you install a full fat version of Linux, but because this is a WSL version, I think it’s pretty stripped down.Anyway, the two packages that we need to install are wget and git. And just to be clear, these are not required for installing Zsh, but for oh-my-zsh. And to be completely honest, you can technically install oh-my-zsh without these packages as well, but there are benefits if you do install this way. For instance, oh-my-zsh will automatically check for updates if you install it using git.To install these two packages, run the following two commands one after another in your terminal: sudo apt install wget sudo apt install gitTogether, it shouldn’t take more than a minute to install. These are pretty small packages. Once you’re done with these two, we can finally move on to installing Zsh.Installing ZshIn some cases, Zsh should already be installed even in the WSL version of Ubuntu or Debian. But I’m not 100% sure because I already had Ubuntu installed on WSL, as I mentioned. But if it’s not installed, it’s just one little command:sudo apt install zshAnd that’s it, you have Zsh installed on your Windows 11 PC using WSL. This excites me very much for some reason. But we’re not yet done. Let’s install oh-my-zsh.Installing oh-my-zshIf you don’t know what oh-my-zsh is, you can read all about it here. Installing this is another simple command. But it’s not using the apt package manager, but we’ll use wget and git to basically download the install script from the Git repo and run that on our machine. To install oh-my-zsh, run the following command in your terminal:sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"Because it’s an open source package, you can just to the link in that command and look at what the script is doing yourself. The whole process should look similar to what you see in the screenshot below.Soon after the install, you can see the prompt change in your terminal. The default theme is applied. You can explore on how to get more themes and change it or customize it to your heart’s content. Adding Useful AliasesIf you’re a developer and use Git a lot for your projects, there are some commands that you’ll be typing everyday. This shouldn’t come as a surprise, but most developers have handy aliases for these commands to make life a bit easier in the terminal. To add aliases, you’ll have to edit the .zshrc file in your home directory. For this, run the following command to open up the file:vi ~/.zshrcThis will open the file in the vi editor. Scroll to the end of the file and the following lines:alias ll="ls -ltra" alias gd="git diff" alias gcmsg="git commit -m" alias gitc="git checkout" alias gitm="git checkout master"As you can see, these are pretty simple aliases. But also, they reduce typing a lot everyday when you add up the number of keystrokes at the end of the day. So, that’s pretty much it.And if you like what you see here, or on my Medium blog and Dev.To blog, and would like to see more of such helpful technical posts in the future, consider supporting me on Patreon and Github. Become a Patron! Share this:ShareTwitterFacebookPrintEmailLinkedInRedditPinterestPocketTelegramThreadsWhatsAppMastodonNextdoorXLike this:Like Loading...Related