How to Install Zsh and Oh My Zsh on Windows 10 (ok)
https://dominikrys.com/posts/zsh-in-git-bash-on-windows/
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
C:\Users\lione.zshrc
Installing Zsh (and oh-my-zsh) in Windows Git Bash
November 11, 2021 · 3 min
I’ve recently started using Windows again. After a long time using a customised Zsh shell on macOS and Linux though, I’ve started to miss some of the small productivity boosts that Zsh plugins offered me. Of course, I could set up the shell as I want it under WSL, but WSL doesn’t always play nicely with Windows-native applications and tools. To remedy this, I looked into how I could set up Zsh to run instead of Bash in Git Bash.
There are a couple of guides on GitHub from some years ago on how this can be achieved. However, I found they’re either outdated, or they don’t include information on whether plugins and custom themes can be used. I’ve addressed these issues in this post.
Installing Zsh in Git Bash
Download the latest MSYS2 zsh package from the MSYS2 package repository. The file will be named something along the lines of
zsh-5.8-5-x86_64.pkg.tar.zst
.Install an extractor that can open ZST archives such as PeaZip or 7-Zip Beta.
Extract the contents of the archive (which should include
etc
andusr
folders) into your Git Bash installation directory. This is likely to be underC:\Program Files\Git
. Merge the contents of the folder if asked (no files should be getting overridden).Open Git Bash and run:
IMPORTANT: configure the tab completion and history in the Zsh first use wizard. If for some reason it doesn’t appear, or you skip it, re-run it:
To configure the history, press
1
, change the values if you like by pressing1-3
, and then press0
.To configure the completion, press
2
to “Use the new completion system”, and then press0
.Press
0
to save the settings.
Configure Zsh as the default shell by appending the following to your
~/.bashrc
file:
Installing oh-my-zsh
From this point, your Git Bash will behave essentially like a Unix Zsh shell. To install oh-my-zsh, run the usual command that you’d run in any Zsh shell:
Installing Plugins and Themes
To install plugins and themes, use their oh-my-zsh installation methods. I’ve installed the Powerlevel10k theme as well as the following plugins, and can verify that they work:
NOTE: you may get strange artifacts and spacing in your terminal as of version
v0.7.0
. To fix this, use versionv.0.6.4
:
Fixing Mangled Output
Windows can mangle some UTF-8 encoded text, causing unexpected characters to be displayed in your terminal (more info in this Stack Overflow answer). To fix this, add the following to your ~/.bashrc
file, ideally before code that sets your shell as Zsh:
Troubleshooting
fworks’s guide tends to be fairly active, so it’s worth searching for or asking about any problems you may have there. Note that some of the information on there is outdated.
How to Install Zsh and Oh My Zsh on Windows 10
FEBRUARY 24TH, 2017
In this article I will tell how to make work with command prompt on Windows 10 better with Windows Subsystem for Linux
, Hyper
terminal, oh-my-zsh
framework for zsh
and zsh-syntax-highlighting
plugin.
For this article you need to have Windows 10 x64 Version 1607 Build 14393 or higher and installed Node.js.
Install Windows Subsystem for Linux
If you have installed Windows 10 Build Less Than 16215:
First, you need to install Windows Subsystem for Linux. Go to Settings -> Update and Security -> For developers
and change Sideload apps
setting to Developer mode
Next open command prompt and go to OptionalFeatures.exe
and enable Windows Subsystem for Linux (Beta)
then reboot your PC. After rebooting you need to open command prompt and use bash
command. Then begin automatic downloading and installation of Linux Subsystem.
In the next time when you need to use bash shell open command prompt and use bash
command.
If you have installed Windows 10 Version 1709 (Fall Creators Update) Build 16215 or Higher:
Go to Settings -> Update and Security -> For developers
and change Sideload apps
setting to Developer mode
.
Open command prompt and go to OptionalFeatures.exe
and enable Windows Subsystem for Linux
then reboot your PC.
Since Fall Creators Update
we need to install Windows Subsystem for Linux from Windows Store.
For now (21 October 2017) we have three Linux distributions in Windows Store to choose from:
I recommend to install Ubuntu to this article.
Then after installing Ubuntu and rebooting PC you can run it with bash
or ubuntu
commands in command prompt.
In more detail, this parts is described in Installation Guide on the Microsoft Official Website.
Install Hyper Terminal
Go to official hyper terminal website and download latest version of terminal for Windows.
Install cURL and Git
Go to bash terminal installed above and use following commands:
Install cURL:
Install Git:
Install Zsh
To install Zsh use following command:
Install Oh My Zsh
Official GitHub repository of oh-my-zsh project https://github.com/robbyrussell/oh-my-zsh
To install oh-my-zsh go to bash terminal and use following command:
and wait until the installation is completed.
Configure and Run Oh My Zsh
Now each time when you need to use bash shell and zsh you need go to command prompt, use bash
(or ubuntu
) command and then use zsh
command.
Let’s simplify it.
If you have installed Windows 10 Build Less Than 16215:
Open bash terminal using bash
command and use nano ~/.bashrc
to open .bashrc
config file.
Warning: Do not change Linux files using Windows apps and tools
In start of that file add following command:
Example: .bashrc
file on gist
Note that in this time if you will try to use “default” command chsh -s /bin/zsh
in bash shell terminal it will not run zsh as default bash shell environment.
Look at this comment of Ben Hillis @benhillis - https://github.com/Microsoft/BashOnWindows/issues/1724#issuecomment-282420193
Now each time when you will use bash
in command prompt then zsh
will start automatically instead of bash shell.
If you have installed Windows 10 Version 1709 (Fall Creators Update) Build 16215 or Higher:
Since Windows 10 Fall Creators Update you can run WSL with ubuntu
command and chsh
command will works.
https://github.com/Microsoft/BashOnWindows/issues/2199#issuecomment-334453644
So open ubuntu
command in command prompt and use following command:
Each time when you will run ubuntu
command then zsh
will runs automatically as the default shell environment.
Note that this still will not work if you will run the bash
command.
Configure and Run Hyper Terminal
If you have installed Windows 10 Build Less Than 16215:
After you installed Hyper Terminal open %USERPROFILE%/.hyper.js
config file and replace line:
with
Now each time when you will open hyper terminal it’s will be use zsh
as default shell environment.
If you have installed Windows 10 Version 1709 (Fall Creators Update) Build 16215 or Higher:
After you installed Hyper Terminal open %USERPROFILE%/.hyper.js
config file and replace lines:
and:
with:
and:
respectively.
Short Q&A:
Question:
Why not just use path to ubuntu.exe
file in hyper.is config?
Answer:
You can just use ubuntu.exe
or full path to ubuntu.exe
without any shell arguments:
or
but in this case your hyper terminal will opens only in Ubuntu home directory.
Links to related issues about this:
Solution: we can use cmd.exe
in config and just run wsl
as a command line argument. That’s works.
Also, note that in this case we are running wsl.exe
not ubuntu.exe
and this running Ubuntu because Ubuntu is current default “WSL OS”. For example if you will install openSUSE
from Windows Store and set as default then wsl.exe
will run openSUSE
.
To understand what I mean, I recommend to reading article: Manage multiple Linux Distributions in WSL.
There is a second way to solve:
Also you can just use wsl.exe
without any shell arguments:
And that’s works too.
Without installed themes for hyper this will looks like this:
Themes and other plugins for Hyper Terminal you can find here https://github.com/bnb/awesome-hyper.
I use hyper-material-theme theme by Mattia Astorino @equinusocio.
Change Oh My Zsh Theme
List of Oh My Zsh themes you can find here https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
By default oh-my-zsh use robbyrussell
(like on screen above). If you want to change theme open ~/.zshrc
config file by use following command in terminal:
and change default “robbyrussell” value of ZSH_THEME
variable to another theme name that you need to enable.
Known Issue: Hot key
Ctrl + X
in Hyper Terminal Does not Work. Instead of this useShift + Ctrl + X
. Link to Related GitHub Issue https://github.com/zeit/hyper/issues/1069
Known Issues for Windows Subsystem for Linux here https://github.com/Microsoft/BashOnWindows
Install zsh-syntax-highlighting plugin
Official GitHub repository of project https://github.com/zsh-users/zsh-syntax-highlighting
This plugin provides syntax highlighting in terminal like in Fish
shell.
Open terminal and download zsh-syntax-highlighting
plugin to .oh-my-zsh
plugins directory using git:
If $ZSH_CUSTOM
variable exist and contains value (full path to /.oh-my-zsh/custom
in this case) use its value, otherwise use ~/.oh-my-zsh/custom
.
About :-
(colon dash) you can read in this topic on stackoverflow: Usage of :- (colon dash) in bash.
Next to activate this plugin open ~/.zshrc
config file using nano ~/.zshrc
and find the following text:
Here you need to add zsh-syntax-highlighting
to plugins
list. For that just replace
with
and save changes.
Finally you need to take changes into account. For that use follow command:
And now after restart hyper terminal you can see result. Screen:
Last updated