Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@Rick-1990
Copy link

Rick-1990 commented Apr 18, 2022

Thank you @nidefawl, I don't currently use key based auth in my setup, but I'll remember your fix 😃

@driwand The "resize problem" seems to be from oh-my-zsh, more specifically it's a bug of the git_prompt_info function (I think this happens only on Windows, in my Mac I wasn't ever able to reproduce it): ohmyzsh/ohmyzsh#9953

@Rick-1990
Copy link

Rick-1990 commented Apr 25, 2022

Ok, I have absolutely NO IDEA about this one, but it works. I was checking out this article and saw that in the bottom notes he suggests to place unset LESS; at the end of ~/.zshrc because "on some commands oh-my-zsh runs less command with -R (repaint)". That had me curious, so I tried and I have no more crashes.

Just to be clear, that -R flag actually instructs less to print raw control characters. This MAY be a reason for the crashes, but I don't know anything more than that.

I tried to look for less usages inside oh-my-zsh to no luck (found it inside some plugins, but I haven't enabled any of them). I really have no clue 👀

@Salloom99
Copy link

Salloom99 commented Jun 16, 2022

I noticed an issue with root directory autocompletion when I type for example "/c/use" and hit tab it won't find it, except in git bash I could get the autocompletion correctly and with capitalized folders like "/c/Users"

@hatakawas
Copy link

hatakawas commented Jun 17, 2022

I personally still have issues with trying to fix the ERROR: this script is obsolete, please see git-completion.zsh that pops up each time I open ZSH.

I've tried all the methods mentioned above by @wl2776 and @michelpfirter

Where exactly in git/etc/zsh should I place those two lines?

local drives=($(mount | command grep --perl-regexp '^\w: on /\w ' | cut --delimiter=' ' --fields=3))
zstyle ':completion:*' fake-files "/:${(j. .)drives//\//}"

UPDATE I was looking at solving slow performance in zsh, and stumbled upon this: adding those 2 lines at the .gitconfig files in the home directory

git config --add oh-my-zsh.hide-status 1
git config --add oh-my-zsh.hide-dirty 1

Not only did it speed up my zsh significantly, it also removed the error somehow, not sure exactly why.

Source: https://stackoverflow.com/questions/12765344/oh-my-zsh-slow-but-only-for-certain-git-repo

Thanks, it works for me!

The 2 lines of "git config", seems it just hide the error but the error still there. I don't like this.

I added the "local drivers" and "zstyles" lines to /etc/zshprofile located in C:\Program Files\Git\etc\zsh
Then the ERROR messge gone.

@thienbao12a2
Copy link

thienbao12a2 commented Jun 20, 2022

I am having an issue in vscode terminal where typing text, then removing it will leave small pixel on the screen like in the picture. Could you please help me fix this issue? Thank you
image

@tanishqmanuja
Copy link

tanishqmanuja commented Jul 25, 2022

Same pixel issue for me also

@HaiLin545
Copy link

HaiLin545 commented Aug 2, 2022

Is any one help with this problem ? zsh on git-bash cant't user "conda activate" and "source activate",it horrible!
image

@fworks
Copy link
Author

fworks commented Aug 8, 2022

Is any one help with this problem ? zsh on git-bash cant't user "conda activate" and "source activate",it horrible! image

Hi, I think it is not a zsh thing, it is more a git-bash/windows thing.
I remember using conda before on git bash, I think you have to use the conda activate comand instead of source activate.

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