Skip to content

Instantly share code, notes, and snippets.

@fworks
Last active January 29, 2025 04:18
Show Gist options
  • Save fworks/af4c896c9de47d827d4caa6fd7154b6b to your computer and use it in GitHub Desktop.
Save fworks/af4c896c9de47d827d4caa6fd7154b6b to your computer and use it in GitHub Desktop.
Zsh / Oh-my-zsh on Windows Git Bash

Steps:

  1. Download the latest zsh package: https://packages.msys2.org/package/zsh?repo=msys&variant=x86_64

Example:

zsh-5.7.1-1-x86_64.pkg.tar.xz

Update:

The package now is compacted using zstd, so now we need some "special" extractor.
So, in my case, I've downloaded this file
https://repo.msys2.org/msys/x86_64/zsh-5.8-5-x86_64.pkg.tar.zst And extracted it using the Peazip.
https://peazip.github.io/zst-compressed-file-format.html

  1. Extract the content to your git bash installation dir:

Usually C:\Program Files\Git

  1. Test it and config zsh:

Open git bash and type:

zsh

So, this step is important, it seems zsh will ask a few configurations, like the tab completion, history, etc.
Please read the options and set that according to your use.

  1. Installing oh-my-zsh, execute the following cmd on git bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  1. Configuring zsh as default shell

Edit the ~/.bashrc file. (create it if it doesn't exist)

Add the following lines at the end of the file

# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi

Close and open again the git bash.

Optional steps

  1. Installing the Honukay theme
curl -fsSL https://raw.githubusercontent.com/oskarkrawczyk/honukai-iterm/master/honukai.zsh-theme -o ~/.oh-my-zsh/custom/themes/honukai.zsh-theme
  1. Set it
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="honukai"/g' ~/.zshrc
@thesobercoder
Copy link

thesobercoder commented Aug 14, 2024

I cannot believe that I'm using Zsh on Windows. It works flawlessly. I didn't encounter most of the issues that others faced here except for ERROR: this script is obsolete, please see git-completion.zsh, and using OMZ on Windows is just the icing on cake. Wish somebody would create a Scoop installer to make the installation process easier alongside Git-bash.

@SteveDevOps
Copy link

This is awesome! Thx everyone.. added starship prompt to mine as well. Took steps here and moved init to .zshrc:
https://gist.github.com/SteveDevOps/b1f901dbc2128a378ff79d73ad3a59cc

Also running zsh in git bash as default shell within Tabby. Great for switching between git bash,
cmd, powershell, etc.

.. working!
gitbash-tabby

@TaekwanMin
Copy link

entering zsh on git bash was not working.

resolved by adding
alias zsh='/usr/bin/zsh-5.9.exe'
to my .bashrc

@farseenmanekhan1232
Copy link

@TaekwanMin
i have created a packaged version of the same
please check it out

https://github.com/farseenmanekhan1232/zsh-for-windows/releases/tag/1.0.0

@LionH
Copy link

LionH commented Jan 13, 2025

here my setup for anyone that need it (windows terminal). It works well now and I also installed oh-my-zsh:

{
  "commandline": "\"C:\\Program Files\\Git\\usr\\bin\\zsh.exe\" -l -i",
  "elevate": true,
  "guid": "{73e8aca6-a2c5-4ef4-9b2c-a60c476343e4}",
  "hidden": false,
  "icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
  "name": "Git Bash",
  "startingDirectory": "%USERPROFILE%"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment