Personalize WSL2 with ZSH and Oh-My-ZSH
Why I use WSL2 instead of dual boot Linux
So I recently bought Microsoft Surface Pro 7, and it’s great. Slim body, ultra light, great battery performance etc. The drawbacks are small RAM, storage capacity (8Gb RAM and 256Gb Storage) and it cannot be upgraded (unless you bought the more expensive variant with up to 16Gb RAM and 1Tb Storage).
As a Linux and Unix user for the past 6 years and plan for using the surface as “E-learning” machine. I still need the Unix terminal, so the journey begin. With such small storage, dual boot practically will divide the storage, and make other inaccessible to other (seamlessly) and since Windows now supporting WSL2 (have full Linux kernel) and VSCode can do remote WSL, I guess Linux on Windows become great choice.
Install WSL2 on Windows
Follow this URL: Install WSL on Win 10. There are 2 choices:
- Simplified Installation for Windows Insiders
- Manual Installation Steps
Personally I prefer the later one, albeit its rather complicated, it give best result for me.
In this last step you’ll be ask to install Linux distro, here I choose Ubuntu 20.04. After last step you’ll be ask whether to launch Ubuntu or not, Choose “Launch”, here you need to setup username password for ubuntu. After that close the ubuntu’s window.
My personal choice for terminal for WSL is Windows Terminal, its customizable and support multi pane, Command palette, and many other things. To install go to “Microsoft Store” and search for “Windows Terminal” or click this link.
Now we need some fonts that support nerd-font themes later on. Download this font from this link and install MesloLGS Nerd Font. Then we need to configure Windows Terminal theme and font, open Windows Terminal and from dropdown choose Setting
or Keyboard Shortcut Ctrl+,
Edit setting.json
, mine look like this (Change Accordingly):
Install and configure ZSH
Install Powerline font and zsh:
sudo apt-get install powerline fonts-powerline zsh
Install oh-my-zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Install powerlevel10k Themes:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Install autosuggestion plugins:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Install syntax-highlighting plugins:
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Modify zsh setting
Run below command in you ubuntu terminal to modify zsh configuration file
vi ~/.zshrc
If you are curious about my settings, you find it below:
So this my Terminal look like:
And my VSCode:
Bonus
Install lsd (Next Generation ls)
Go to lsd release page in this link and download Debian installer (should be in this filename format lsd-musl_0.19.0_amd64.deb) and run
dpkg -i <path-to-file>/lsd-musl_0.19.0_amd64.deb
Originally published at http://github.com.