git-aware-prompt icon indicating copy to clipboard operation
git-aware-prompt copied to clipboard

Does this work with zsh?

Open cmacdonnacha opened this issue 3 years ago • 6 comments

Does this work with zsh?

cmacdonnacha avatar Aug 25 '20 09:08 cmacdonnacha

yup I would like to know the answer too

also see - https://stackoverflow.com/questions/65041568/iterm2-use-bash-as-well-as-zsh

I am happy to use zsh but asked this SO question so that if git-aware-prompt only works with bash then I need bash!

danday74 avatar Nov 27 '20 17:11 danday74

works with bash for me - exact same setup does not work with zsh

danday74 avatar Nov 28 '20 04:11 danday74

I can affirm, I just tried switching to zsh, and git-aware-prompt does not work with zsh, but continues to work with bash beautifully.

However, here's a zsh solution (found from various articles and stuff over the internet):

# Load version control information, set git branch, and load colors
autoload -Uz vcs_info
precmd() { vcs_info }
zstyle ':vcs_info:git:*' formats '(%b)'

# Mon Jan 01 13:26:31 ~/path/to/current_dir (git-branch)
# %
setopt PROMPT_SUBST
PROMPT='%B%F{cyan}%D{%a %b %d %H:%M:%S} %F{yellow}${PWD/#$HOME/~} %F{green}${vcs_info_msg_0_}'$'\n''%f%% %b'

I also color my prompt, so the date/time is cyan, the path is yellow, and the branch is green.

emmahsax avatar Jun 09 '21 21:06 emmahsax

@danday74 and @cmacdonnacha I updated my comment above to provide a zsh solution that does the same thing as git-aware-prompt.

emmahsax avatar Jun 12 '21 15:06 emmahsax

I'm afraid git-aware-prompt is very specific to bash right now. For years I have wanted to do a complete rewrite that'll work on both bash and zsh, as I haven't personally used git-aware-prompt since 2011 when I switched to zsh.

And I would very much like to start using my own solution again rather than a third party one. Right now most of my spare time is going towards my emacs-builds project, but I've just bumped the bash+zsh rewrite up into second place on my todo list, so this time I'm hoping I'll actually get around to it 🤞

jimeh avatar Jun 13 '21 12:06 jimeh

My fork supports zsh, and has a bunch of extra options.

I have also made a PR to add zsh support to this repo.

joeytwiddle avatar Aug 09 '21 12:08 joeytwiddle