WSL 2 prompt with the Powerlevel10k theme

I'm using Windows for quite some time now, but honestly, it hasn't been the most comfortable operating system when you're creating software. Sure, there are workarounds, but the integration of development tools doesn't feel as smooth as on, for instance, Ubuntu. But, and this is a big but, since Microsoft introduced WSL, finally a natively supported shell is available, providing all the beautiful command-line tools that Ubuntu offers out of the box.

I've installed WSL 2, having Ubuntu as the Linux distribution and using the Windows Terminal. To improve the "command-line experience" significantly, I'm using the Powerlevel10k theme. Yes, a shell can have a theme too :) Its functionality goes way beyond changing the color palette to improve readability. For instance, the instant prompt feature ensures that you can type immediately, even when plugins are loaded, and the transient prompt trims down unnecessary information from previous commands. The thing I like the most is the status information shown when you're in a version-controlled directory. Typing git status has become a habit of the past for me.

To use Powerlevel10k, you first have to install Zsh (i.e., the Z shell), and I like to do this in combination with Oh My Zsh. Open up the WSL 2 prompt (via Windows Terminal) and perform:

sudo apt install zsh
sudo usermod -s /usr/bin/zsh $(whoami)
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

These commands install Zsh, make it the default shell (when using WSL 2 prompt, of course), use Oh My Zsh to manage the Zsh configuration, and clone the Powerlevel10k in the folder for custom themes.

Now set ZSH_THEME="powerlevel10k/powerlevel10k" in your ~/.zshrc file.

To take full advantage of all available style options that Powerlevel10k offers, install the recommended Meslo Nerd Font patched for Powerlevel10k in your system. And then indicate in the Windows Terminal settings (pressing ctrl + ,  opens a settings tab) to use the MesloLGS NF font for the fontFace property (i.e., Profiles > Ubuntu (1) > Additional settings > Appearance > Font face (2)):

 

I like to use an underscore for the cursorShape property, see Cursor > Cursor shape (3).

Now close and reopen the Windows Terminal, and answer the question of the Powerlevel10k configuration wizard. This wizard can also be started by running p10k configure.

Below is a screenshot of the prompt I use. As you can see, I've checked out the develop branch of this site, which is in sync with the remote repository located at Bitbucket (indicated by the icon).

Category
WSL 2
Windows Terminal
Powerlevel10k
Oh My Zsh
Zsh
Windows

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.