Oh My ZSH on Windows WSL and Windows Terminal


In this article, I’ve thrown together the steps I used to install Oh My ZSH! for the Windows Subsystem for Linux (WSL) with Powerlevel9k. I’m using Ubuntu in the WSL, so the steps apply to Ubuntu.

Note, the screenshot was taken when using the agnoster theme.

Setup for the Windows Subsystem for Linux

Install the required packages.

1
sudo apt-get install -y zsh fontconfig

Install Oh My ZSH! (https://ohmyz.sh/)

1
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Install the Powerlevel9k theme (https://github.com/Powerlevel9k/powerlevel9k). Note, I found WSL to be a little sluggish with Powerlevel9k, so I have it set up for the agnoster theme (included with Oh My ZSH!)

1
2
3
cd ~/.oh-my-zsh/themes
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel9k\/powerlevel9k"/' ~/.zshrc

I like to remove the user@hostname prompt to do that implement the following.

1
2
3
4
cat <<EOF >> ~/.zshrc
DEFAULT_USER=$USER
prompt_context(){}
EOF

Install a compatible font. Reference here.

1
2
3
4
5
6
7
8
cd ~
wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
mkdir -p ~/.local/share/fonts/
mkdir -p ~/.config/fontconfig/conf.d/
mv PowerlineSymbols.otf ~/.local/share/fonts/
fc-cache -vf ~/.local/share/fonts/
mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/

At this point, we need to install the compatible font on Windows so the terminal emulator can correctly display the symbols used in Powerlevel9k.

Setup for Windows Terminal

If you aren’t familiar with the new Windows Terminal (still in development) I suggest checking it out here.

Download the font from here - note; I’ve only tested with this one successfully; you may be able to use alternatives.

Double click the downloaded file and click install.

Depending on the terminal emulator your using update the font settings to use the new “DejaVu Sans Mono for Powerline” font. For the Windows Terminal Preview, you can update the JSON configuration file. I did this for both the PowerShell and WSL profiles. For CMD or PowerShell terminals edit the font settings in the UI and select the DejaVu font.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"profiles" : 
    [
        {
            "acrylicOpacity" : 0.5,
            "backgroundImage" : "ms-appdata:///roaming/moon1.jpg",
            "backgroundImageOpacity" : 1.0,
            "backgroundImageStretchMode" : "uniformToFill",
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "powershell.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "DejaVu Sans Mono for Powerline",
            "fontSize" : 14,
            "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
            "name" : "Windows PowerShell",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : false
        },
        {
            "acrylicOpacity" : 0.5,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "wsl.exe -d Ubuntu",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "DejaVu Sans Mono for Powerline",
            "fontSize" : 10,
            "guid" : "{2c4de342-38b7-51cf-b940-2309a097f518}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
            "name" : "Ubuntu",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "useAcrylic" : false
        }

This will give you a terminal that looks like so when using the WSL or SSH’d into a machine using Oh My ZSH!.

Bonus Tips

For a Fedora system update the default shell by doing the following.

1
2
sudo yum install -y util-linux-user
chsh -s /usr/bin/zsh