This article contains unstructions on how to configure Windows Terminal to use Oh My Posh with Zsh and zsh-autosuggestions.
This approach is not relying on WSL, it is utilizing existing Git installation on Windows. This way, you can have fully functional Zsh shell with autocomplete natively on Windows, just like you would on Mac.
Some people recommend using ble.sh – Bash Line Editor, a command line editor written in pure Bash which replaces the default GNU Readline (mentioned in Bash vs ZSH vs Fish: What's the Difference?). However, on Windows I still prefer using Zsh with zsh-autosuggestions.
Configuration Instructions
- Download and install Git from git-scm. Make sure to uncheck suggested options for Git Bash (e.g. the 2 options under "Windows Explorer integration"). You can select the option to add a Git Bash Profile to Windows Terminal, we will modify it manually later. When asked about adjusting your PATH environment, I like to use the Recommended setting, and I also like to enable symbolic links. I usually keep everything else on default.
- From Microsoft Store, install Windows Terminal and
wingetApp Installer. Check if everything has been installed properly by opening a new Windows Terminal session and typingwinget --version. - Open your Windows Start menu, and search for "PowerShell".
-
Run Windows PowerShell as Administrator, then install Oh My Posh using
winget, for example:
winget install JanDeDobbeleer.OhMyPosh -s winget -
Close PowerShell, then add
oh-my-poshpath to your Windows environment variables (User):- Press
Win + r. - Type in
controland hitENTER. - Navigate to "User Accounts".
- Click on "User Accounts" one more time, then click the "Change my environment variables" link on the left side to open the "Environment Variables" window.
- In the upper (User) part of the window, scroll down and select
Path, then click theEdit...button. - Depending on the way your variables are displayed, either click
Newto add a new variable, or add a;at the end of the line, then type in%LOCALAPPDATA%\Programs\oh-my-posh\binfor the value. It might be that this value already exists, in which case you don't need to edit anything. - Press
OK, then confirm every previously opened window by clickingOK.
- Press
-
Run PowerShell one more time with Administrator privileges, then install either the
FiraCode Nerd FontorSauceCodePro Nerd Font(I preferSourceCodePro) from Nerd Fonts using the following command (follow their instructions in order to select the desired font):
oh-my-posh font install Start a new Git Bash terminal by double-clicking on
git-bash.exelocated underC:\Program Files\Git\.-
Download the Zsh for Windows package
zsh~x86_64.pkg.tar.zstby executing the following command:
curl -fsLo $HOME/zsh-5.9-2-x86_64.pkg.tar.zst https://mirror.msys2.org/msys/x86_64/zsh-5.9-2-x86_64.pkg.tar.zst -
In Windows Explorer, locate the downloaded
.zstfile in your home directory and extract it either using: You only need the
etcandusrdirectories, so copy these two directories from the extracted folder intoC:\Program Files\Gitand when prompted, select the option to overwrite all existing files – don't worry, these two directories (etcandusr) contain completely new files, no existing files will be overwritten.-
Open
%PROGRAMFILES%/Git/etc/profilein your text editor as Administrator (because you might need elevated privileges in order to save the changes) and:- Comment out the entire block near the bottom of the file that starts with line
if [ ! "x${BASH_VERSION}" = "x" ]; thenand ends with linefi. At the moment of writing the article, I commented out lines111-133. We don't need all of this code since we know we will be using Zsh. -
Below the commented out block, add the following 3 lines:
HOSTNAME="$(exec /usr/bin/hostname)" profile_d zsh SHELL='/usr/bin/zsh' Save the changes.
- Comment out the entire block near the bottom of the file that starts with line
Open the Windows Start menu, search for "Terminal" and start it.
-
Open Windows Terminal's settings using the
Ctrl + Shift + ,keyboard shortcut, then under theprofiles > listarray modify the existing Bash profile, or add a new profile:
{ "name": "Git Bash", "guid": "{12398ec4-4e3d-5e58-b989-0a998ec441b1}", "commandline": "%PROGRAMFILES%/git/usr/bin/zsh.exe -il", "icon": "%USERPROFILE%/git.ico", "startingDirectory": "%USERPROFILE%", "colorScheme": "VibrantInk", "font": { "face": "SauceCodePro NFM" }, "useAcrylic": true, "opacity": 70, "adjustIndistinguishableColors": "always", "bellStyle": "none", "hidden": false } HINT: For the code mentioned above, make sure to add the
,character after the closing curly brace, if needed, so that the settings file syntax is valid.The profile above uses a custom
~/git.icoicon, so you can either reference the defaultgit-for-windows.icoicon file underC:\Program Files\Git\mingw64\share\gitor find another one you like.If you wish, you can also set the above profile to be your default Windows Terminal profile by setting the same
guidas thedefaultProfilevalue in the settings JSON.Restart Windows Terminal and verify that everything is working (configure
zshusing the interactive menu).-
Execute the following command from any location to install Oh My Zsh under your
$HOME/.oh-my-zshdirectory:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" -
Clone
zsh-autosuggestionsusing the following command:
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions -
Open
~/.zshrcfile, comment out the line that setsZSH_THEMEon line 11 (we will be using Oh My Posh theme, not Oh My Zsh), then below on line 73, add thezsh-autosuggestionsplugin tooh-my-zshplugins:
plugins=( git zsh-autosuggestions ) Save the changes and verify that autosuggestions are working (you need to have something in your history first, so type a couple of commands in Windows Terminal, exit with
logout, then start the Terminal again). NOTE: On first run,~/.zcompdumpfile will be created, so it is normal for Terminal to start a bit slower.-
Grab the Gocilla theme for
Oh My Poshand save the file underoh-my-poshthemes:
curl -fsLo $HOME/AppData/Local/Programs/oh-my-posh/themes/gocilla.omp.json https://raw.githubusercontent.com/goranvasic/gocilla-oh-my-posh/main/gocilla.omp.json Navigate to your Windows
%USERPROFILE%directory, and open the.zshrcfile one more time.-
Add the following line below the
source $ZSH/oh-my-zsh.shline:
eval "$(oh-my-posh init zsh --config $HOME/AppData/Local/Programs/oh-my-posh/themes/gocilla.omp.json)" Restart Windows Terminal and verify that everything is working properly.
That's it. Hopefully this works on your side. You can run this customized Zsh in IntelliJ or VS Code by setting the built-in terminal to open "C:\Program Files\Git\usr\bin\zsh.exe" -il.
You can find the latest version of these instructions on my GitHub repo here. Any comments or suggestions for improvement will be much appreciated.
Top comments (0)