The Windows Vs Mac war has been raging on for decades. I'm happy to admit I like both. Yes, I can hear you silently judging me... I just don't care. If you ever hear a mac fan evangelize why the MAC is better suited for coding, you will quickly hear how bash and the Linux terminal kicks the Windows command line ass. It's all true it does. The command line sucks when comparing it to bash. Thankfully, Microsoft has been working on something sneaky. You can now run a Linux kernel directly on windows
In this tutorial, you will learn how to run Linux natively on Windows using WSL2. The really cool thing about WSL2 is that it will allow you to run bash natively on Windows, meaning WSL2 gives us new super-powers. We can finally ditch the built-in Windows command line and instead use something a little more productive. We can now install ZSH and Oh My Zsh on Windows!
For those of you new to Z/Zsh you are in for a treat! Zsh is a new and improved shell that is based on bash. With the Zsh shell, you can install Oh My Zsh. Oh My Zsh can be used to customize your shell with themes and plug-ins. You no longer need to make do with having a dull and boring terminal! Oh My Zsh has some tricks up its sleeves that will make you more efficient. Sounds good right?
This whole process should take you around 30 minutes in total. The first step is to install WSL and Ubuntu. Next, we will install Zsh and Oh My Zsh. Finally, we will pimp up the terminal, installing some cool themes and plug-ins using Oh My Zsh. With Zsh and its plug-ins installed you become a Windows terminal productivity ninja. So buckle up... it's going to be one hell of a ride
Installing WSL
The steps to install WSL2 are well documented on the Microsoft site and can be found here. An overview of the important things (some of which are not covered in the MS tutorial) is shown below:
- Have docker desktop for Windows installed
- Have SVN enabled in your BIOS settings. On my laptop is was disabled and stopped WSL2 from installing!
- Within 'turn windows feature on and off' ensure:
- Windows Hyper-vision Platform is enabled
- Windows Subsystem for Linux is enabled
After you have WSL2 installed, you can install a Linux distribution, like Ubuntu. This is how we can run bash on Windows. To install Ubuntu. open up the Windows Store and search for:
- Ubuntu
If you are at work and the MS stories blocked then you can manually download Ubuntu from this page.
While you are in the Windows store you will also want to install:
- Windows Terminal
If the store is blocked on your PC, you can manually download it here. If everything goes to plan then you should be able to open the new Windows Terminal program and you should have an option to open a bash Ubuntu shell!
Installing And Configuring Z and Oh My Zsh
You can install both Z and Oh My Zsh from your new bash shell. Type in these two commands (remember to run the terminal as an admin 😊):
After both of these great tools have been installed we can customize things! Oh My Zsh can be configured via its settings file, called .zshrc
:
First, we will change the theme from the default which will be set to 'robbyrussle'. From within .zshrc
, find the line that says Theme=robbyrussell
. Update this to use a different theme. A full list of all the themes can be found here. Two themes that I like and recommend are agnoster and powerlevel9k. The configure to change .zshrc
to use the powerlevel9k
theme is shown below, simples!
Next, let us install some plug-ins. Within .zshrc
find this line:
To install a new plug-in simply add a reference to it from within this list. For example, to install zsh-syntax-highlighting
, clone this repository from the command line like this:
Add a reference to zsh-syntax-highlighting
within your plug-in options like this:
Another plug-in that I recommend is called Z. Z
ships with Oh My ZSH, however, it is not enabled by default. To enable it, simply add a reference to it within your plugin's options:
For reference, the plug-ins that I use are git
, node
, npm
, bower
, brew
, extract
, z
, zsh-syntax-highlighting
. Hopefully, by now you get the gist of how to install themes and plug-ins for Oh My Zsh. A full list of all the plug-ins can be found here. You are now a shell Ninja! You know how to install Ubuntu, install Z, OH MY ZSH, as well as trick it out. Happy Coding!