Zsh, Oh-My-Zsh and Powerline fonts running on Windows Subsystem for Linux and Windows Terminal
Pjuh, that is a handfull of a title…
Tired of that same old looking terminal?
Want to look leet in front of your friends?
Or actually just get a bit more “productivity” out of yer terminal?
Hello, welcome and let us begin already
This is done on Windows 10 Pro version 1909, Ubuntu 18.04 LTS and we will be installing and configurating the following software:
- Zsh
- Oh-My-Zsh
- Powerline Fonts (on both Windows and Ubuntu)
- Windows WSL
- Windows Terminal
- Powerlevel9k ZSH theme
And some prerequisites:
- Windows
- Chocolatey, which is a package mamanger that is sorely missing in Windows
- Git, Source Code Management (SCM) system
- Ubuntu
- Git
Installtion via git
is needed when the vendors do not publish their content to repositories like Chocolatey or Ubuntu or if the software is very outdated. It should work as well to use the version in Ubuntus repositories if you rather want to use that.
Vendors should provide their software in repositories, but not all do. Usually because they are focused more towards developers or other “power users” that they expect should be able to use git
like a boss.
We are going to go from the default bash
shell look
To the end goal of this running with all the perty software we are about to install
With the Git plugin that is enabled by default, you will get the current branch and status of any existing Git repository directory you are in.
[!WARNING] Make sure to always audit and understand every single line of any script(s) you are asked to copy and paste from the scary internet.
With that warning in mind, you should be able to copy paste the following code into a powershell and bash shell respectively and get up and running. :)
Windows
You can opt to just install the specific font(s) you want, please adjust accordintly in that case.
Open up powershell
as administrator.
Installing the fonts will take some time and very in your face about it.
Set-Location -Path c:\windows\temp
# Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install -y git microsoft-windows-terminal
# WSL, will require and ask for restart
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# Ubuntu 18.04 LTS
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile c:\windows\temp\Ubuntu.appx -UseBasicParsing
Add-AppxPackage c:\windows\temp\Ubuntu.appx
# Powerline fonts
git clone https://github.com/powerline/fonts.git --depth=1
Invoke-Expression -Command .\fonts\install.ps1
Remove-Item -Path .\fonts -Recurse -Force
Ubuntu
cd "${HOME}"
sudo apt update && sudo apt upgrade -y && sudo apt autoremove
sudo apt install -y git zsh fonts-powerline
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
sed -i 's/ZSH_THEME\=\"robbyrussell\"/ZSH_THEME\=\"powerlevel10k\/powerlevel10k\"/' .zshrc
TERMINAL_CONFIG="/mnt/c/Users/"${USER}"/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/profiles.json"
if [ -f "${TERMINAL_CONFIG}" ]; then
sed -i 's/\"fontFace\" \: \"Consolas\"\,/\"fontFace\" \: \"Roboto Mono for Powerline\"\,/' "${TERMINAL_CONFIG}"
else
echo "Unable to find the Windows terminal configuration file, please change the font manually..."
exit 1
fi
Conclusion
We used the Ubuntu terminal to change the Windows Terminal configuration file, you could also to that from the Windows side of things if you so please.
There are a lot of Oh-My-Zsh themes so make sure to check out the best alternative for you.
The next step would be to turn this into an Ansible playbook using one or more roles. But that is a whole other blog post for another time.
Other Oh-My-Zsh themes
Powerlevel9k
Powerlevel9k is deprecated and now unmaintained
Reference P9K Github
Powerlevel10k
Aka. P10K apparently.
Powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience.
Here is how you replace it if you have powerlevel9k installed already.
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
sed 's/powerlevel9k/powerlevel10k/g' -i ~/.zshrc
rm -rf $ZSH_CUSTOM/themes/powerlevel9k
exec zsh
If you haven’t installed any other custome theme, here is how you install it.
Open up a new Zsh or if there is no p10k config started run p10k configure
manuallt to choose prompt style.
References
- Oh-My-ZSH
- Oh-My-Zsh Github
- Initializing a newly installed distro
- Manually download Windows Subsystem for Linux distro packages
Revison
Updated 2020-04-16
Added powerlevel10k replacement for powerlevel9k due to slow speed.
Make sure to always keep your Operating System(s) and all of the software that you are using up to date.
Feedback on our content or did you find a bug somewhere?
Send us an email to feedback at this domain.
kthxbai