Below diagram explains what we are going to do.
So to list the steps, we'll
- Install WSL (Windows subsystem for linux)
- Install Ubuntu from Microsoft store
- Install zsh shell
- Install oh my zsh
- Install PowerLevel10k
- Plugins
- Choose a terminal
- Points worth noting
Installations
WSL
I just enabled 'Windows Subsystem for Linux' in Windows Feature and restarted the system.
You can follow the instructions on Microsoft website.
Ubuntu
For this, visit this Microsoft Store webpage and install it.
Download size 444.5MB on 05-12-2020
After it is installed. Open it from start menu to continue installation.
Setup will ask for a username for linux subsystem.
After entering username, the setup will finish.
Update the packages with following command
sudo apt update && sudo apt upgrade
ZSH
Install ZSH with following command
sudo apt-get install zsh
Make zsh
the default shell with following command:
chsh -s /usr/bin/zsh
Restart the Ubuntu app and you should be greeted with following screen:
Complete the configuration as per your liking.
OH MY ZSH
Next, lets install 'OH MY ZSH' with following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Below is the screenshot of completed installation.
PowerLevel10k
Time to spice up the terminal with a nice theme.
But before that, Install the recommended font 'Meslo Nerd Font':
Why?
Icons will render properly with this font
You can download the fonts from this GitHub page.
To install a font, open it and click install button on top
Install PowerLevel10k
Now, for PowerLevel10k, you can follow the guide at https://github.com/romkatv/powerlevel10k
Below are the steps I've taken:
-
Installation of PowerLevel10k for Oh My Zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
Set
ZSH_THEME="powerlevel10k/powerlevel10k"
in~/.zshrc
.Restart the Ubuntu app.
You will be prompted with the configuration wizard for PowerLevel10k. If not, type
p10k configure
if the configuration wizard doesn't start automatically.
After doing the configuration, my terminal looked like below:
Plugins
zsh-autosuggestions
This plugin will suggest command as you write from the terminal history.
Just use β
right arrow key to complete the command.
Link: https://github.com/zsh-users/zsh-autosuggestions
Steps I followed:
-
Installation
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
To activate the autosuggestions, add it to plugin list in your .zshrc:
-
You will also need to force reload of your .zshrc:
source ~/.zshrc
Try typing any command if its available in the history, you will see suggestion as below and then you press ->
right arrow key to complete it.
Choose a terminal
So far we have just configured a shell, zsh in this case.
Time to pick a terminal of choice.
Terminals are dumb. They are just UI layer. They take input and pass it on (to a shell for example).
You can choose any terminal like Hyper, cmder, Windows Terminal etc etc.
Up till now, we have been using the Ubuntu app as our terminal. You can continue using that and it works fine.
In case you want to switch, below i have notes on few of them.
Install it from Microsoft Store Open its settings from the dropdown and add By default it opens up PowerShell. You can change it by assigning the Windows Terminal
Install
Font
fontFace
to the profile named Ubuntu
as shown below
Default Profile
GUID
of Ubuntu
profile to the defaultProfile
in the settings.
Make hyper use the custom font we installed earlier. Lets tie hyper with Window's bash now. Add following in the very beginning of the file The colors were a little bit bright for me. So I installed a theme for hyper terminal named 'hyper-material-theme' from Hyper Website using below command: β Make sure you are running the hyper command from windows terminal. Meaning you are out zsh or linux terminal per se. Now colors are nice! One issue I noticed with hyper terminal is that it doesn't refresh/clear the screen after nano editor is closed. As shown below, Hyper(on left) and Windows Terminal(on right) after closing nano editor. Hyper
Install
Font
Open Hyper Terminal config file with ctrl+,
and add 'MesloLGS NF,' in front of the existing value for fontFamily
key.
Shell
ctrl+,
.
shell
's value to C:\\Windows\\System32\\bash.exe
.
bash
shell in Hyper.
To switch to ZSH on startup, Open your bash profile with
vim ~/.bashrc
zsh
Colors
Use exit command to get out of zsh.hyper i hyper-material-theme
Issue
Make Cmder use the custom font we installed earlier. Lets tie cmder with Window's bash now. Add a new task in cmder's settings window as shown below Cmder
Install
Font
Open settings and select 'MesloLGS NF' as shown below
Shell
Points worth noting:
β Do not change Linux files using Windows apps and tools
-
NodeJs Projects
I have moved these node related notes to separate space here
-
Misc
- Do not try to copy text with
ctrl+c
while a command is running π.
- Do not try to copy text with
Thats it for this note.
HIH
~ RD
This was originally published on https://www.therdnotes.com/setup-zsh-on-windows
And I keep updating my notes with new findings... β
Top comments (4)
What you are doing in your
.bashrc
is really strange:This means your system will load
bash
, then immediately loadbash
again, and finally loadzsh
.If you use
chsh
you can set which login shell you use directly.hmm. thnx Ben.
chsh
worked for me, only when I launch 'Ubuntu' app from start menu.BUT, as I am using Hyper terminal and have configured its shell as below
It always starts
bash
irrespective of the shell set in/etc/passwd
either withchsh
orusermod -s
So had to add
bash -c zsh
in.bashrc
Though, can be summoned with just
zsh
in the.bashrc
.Let me know, if there is any workaround to this situation!
Hmm, not sure. I use Windows Terminal and it's configured to run
wsl.exe -d Ubuntu
instead of a shell directly.Windows Terminal is alright. It's very slow, but last time I used Hyper Terminal that was even slower!
Cool π
I just switched to Hyper. Lets see how it behaves with time.
Thanks
For all,
Terminals are UI layer. The above setup will work fine with CMD too.
Below is the screenshot for same [with autosuggestion also]