Badass Terminal: FCU WSL Edition (oh-my-zsh, powerlevel9k, tmux, and more!)

It’s that time again! The time to write another epic blog post, this time for WSL, also known as Windows Subsystem for Linux. One of my most popular posts is my badass terminal post for iTerm2/MacOS so I thought it was only fitting to try and recreate the same environment for WSL. The Windows 10 Fall Creator’s Update (FCU) introduces a few new features to WSL. Below are the key ones:

  • WSL is no longer a Beta feature
  • Install Linux distros via the Windows Store
  • WSL now runs multiple Linux distros
  • WSL no longer requires developer mode
  • WSL comes to Windows Server & Microsoft Azure VM’s!
  • WSL now supports USB/serial comms
  • Miscellaneous fixes and improvements
  • Deprecating the name “Bash on Windows”

Prior to the release, I had already planned on creating an automated install script for Linux / WSL to customize the terminal. With the new WSL release now available via the Windows Store, I’m even more excited for my script / this post. Key changes in WSL as part of the FCU now allows commands like “chsh” to work, which means we can use our favorite shell (zsh, fish, etc.) directly.

A few key points before we dive into the #badass customizations:

  • lxrun.exe is deprecated and is now considered legacy
    • This means your LXSS data no longer lives in %USERPROFILE%\appdata\local\lxss
      • Your data now lives in %USERPROFILE%\appdata\local\Packages\CanonicalGroupLimited.UbuntuonWindows_[random-numbers-and-characters]\LocalState\rootfs\home
    • This also means you no longer run lxrun.exe /uninstall /full /y to remove your WSL instance (when installed from the Windows Store). Instead, you would uninstall Ubuntu (WSL) the same way you would any other app – find the app in your start menu, right click, uninstall. Easy peasy.

The Setup

Everything shown here is available on my Github in the WSL branch of my dotfiles repo. To start the configuration, including copying the current dotfiles I use, you would simply type the following from your WSL Ubuntu Console.

What will this install?

  • Update package lists
  • zsh
  • git completion
  • oh-my-zsh
    • zsh-completions plugin
    • zsh-autosuggestions plugin
    • zsh-syntax-highlighting plugin
  • powerlevel9k
  • vimrc undle
  • pathogen
  • nerdtree
  • wombat vim colorsheme
  • midnight commander
  • bashrc colorscheme – solarized dark
  • optional: my dotfiles
  • optional: az cli 2.0
  • optional: change default shell to zsh

A few notes:

  • A clean install from this configuration.sh script (not using my dotfiles) looks like this. (See pic below)
  • you will need to enter your password during the oh-my-zsh install. You will also need to type “exit” after it completes so the remaining parts of the configuration.sh script can continue to install. (See pic below)
  • You will be prompted if you want to use my dotfiles. If you hit yes, this will create symlinks to the usual dotfiles and use the .dotfiles from my repo. To learn more, check out Zach Holman’s blog post, as I forked his repo and modified it accordingly. Side note: I started keeping a record of my dotfiles awhile back when I read this blog post from Nicola Paolucci. This allowed me to duplicate my environment seamlessly as I moved from system to system. Zach’s project is one Nicola moved to and I adapted as well. If you choose to use my dotfiles and the WSL Terminal Emulator I suggest below, your terminal will look like this. (See pic below)

Now, my .tmux.conf file runs .sh scripts for the status bar. As of now, those scripts don’t play nicely with Ubuntu WSL so I use a WSL Terminal Emulator. Fear not, I wrote you an install script to get that going, too. From an Administrator PowerShell prompt, run the following:

This will set up your WSL Terminal Emulator and add a shortcut named “bash” to your desktop. I don’t know why I named it ‘bash’ as I’ve been using ZSH for quite some time now, but alas, that’s the name. Update the shortcut name if you wish.

Fonts and Themes:

You will need to install a font to use some of the Unicode characters I have in my configuration. Both WSL Terminal Emulator and Ubuntu WSL support mono fonts so you can choose whichever patched mono font you want. I recommend picking one from Nerd Fonts. The one I’m using is Ubuntu Mono Regular for Windows. It is also in my repo. You will also need to select a theme for the WSL Emulator. I am using base16-solarized-dark.minttyrc.

From there, you will need to ensure you select that font in your Ubuntu or WSL Terminal: Right-click on the title bar at top > Properties > Font (or Text). Similarly, you will do the same for Themes in WSL Emulator (Right-click on the title bar at top > Options > Select Theme (under Looks).

For quick visual reference, see my MacOS and WSL Terminal Emulated environments next to each other below.

Overall, I’m thrilled with the improvements WSL has made in the FCU. We are so much further ahead now than we were 18 months ago. I am able to nearly replicate my MacOS terminal entirely on my Window systems, which only allows for more productivity in development and operations… or DevOps!

Reminder: All of my posts are provided "AS IS", imply no warranties, and confer no rights or special privileges. Use of included postings, code samples and other works are subject to the terms specified at Microsoft. For more information, click here.

Comments 15

  • Hey there,

    Nice post, but I’m having some issues in WSL (check screen). Any ideas?
    https://imgur.com/a/wnaP3

    • Hey there! Yep – that’s where I mentioned my .tmux.conf goes crazy in UbtuntunWSL – if you use the WSL terminal emulator I mentioned you should be good! 👌🏼 Let me know!

  • Thanks for this post! Can’t stress enough how useful this was. I used the WSL emulator and configured my zsh, tmux, vim, etc. config files. Everything work fines except one thing which I am still unable to fix. It is this weird highlight of results: https://i.imgur.com/DdqzvuE.png

  • Hi there!

    Have you tried Linuxbrew yet? It sorta kinda works on WSL so it’s worth using for package management.

    Also: zplug may be a nice way to manage the zsh plugins (and tpm for tmux). If you’re looking for some inspiration here are mine: https://github.com/DoomHammer/dotfiles/

    BTW: Thanks for great post, I am sure to borrow some ideas from it 🙂

    • I have not! I will have to check that out. I have xubuntu-desktop working with XFCE via VcXSrv, but I haven’t tried Linuxbrew yet… I’ll give it a go. If I can get it stable, I’ll update the Badass terminal configuraiton.sh. Thanks!

  • chsh is not switching my shell to zsh. Thoughts?

    • Are you using WSL as part of the Fall Creator’s Update? (I.E. How was your version of WSL installed? If you did not install it through the Windows Store, chsh won’t work.)

  • I can’t get WSL to use ZSH as the shell. Any ideas?

    • Are you using WSL as part of the Fall Creator’s Update? (I.E. How was your version of WSL installed? If you did not install it through the Windows Store, chsh won’t work.)

      • I did update to the Fall Creator’s Version. I only pasted the WSL PowerShell script you made into an admin PowerShell prompt, I thought this was enough to install WSL. I do have a “bash” link on my Windows Desktop now. Browsing around, I haven’t been able to find a WSL in the Windows Store.

        • When you updated to the Fall Creator’s Update, did you reinstall WSL from the Store? Or are you still using the version installed via cmd prompt (lxrun.exe /install)

          • I’ve been using WSL since the Beta. I uninstalled what was there and reinstalled Ubuntu from the store. I’m not sure that I ever used the lxrun.exe /install technique.

            I’ve had some more time to tinker with this today and I can’t figure out exactly what’s wrong but I’m working on it. I’ve noticed that currently, if I open Ubuntu on Windows, tmux is auto loaded. But if I open from the bash shortcut that your script installed, tmux is not autoloaded.

            Further, ZSH is not default shell in either case. I’m not sure why.

  • I was able to get the solarized_dark theme on the default WSL console using the new color tool (https://github.com/Microsoft/Console/tree/master/tools/ColorTool) this does not solve the font issue, but helps with looks.
    Also I did not see in your zshrc.symlink where you actually loaded the *.zsh files after I cloned the repo. Looking at holman’s zshrc.symlink there is code to loop over them and run them.

    Thanks for the post, made me rethink my current repo setup and enhance it.

Leave a Reply

Your email address will not be published. Required fields are marked *