#zsh #git #prompt #github #com #status #zsh-git-prompt

app zsh-git-prompt-rs

A git status prompt for zsh written in Rust

4 releases

new 0.3.5 Dec 21, 2024
0.3.4 Dec 19, 2024
0.3.3 Dec 18, 2024
0.1.0 Dec 18, 2024

#6 in #com

Download history 269/week @ 2024-12-14

269 downloads per month

MIT license

24KB
550 lines

zsh prompt origionally implemented by https://github.com/olivierverdier/zsh-git-prompt

I no longer install the haskell toolchain everywhere so am trying to implement that prompt in Rust.

Installation

Install zsh-git-prompt-rs via cargo:

cargo install zsh-git-prompt-rs

in your zsh init

#
# BEGIN PROMPT
#

# enable prompt

if command -v gitstatus >/dev/null 2>&1; then
  source <(gitstatus --script)
fi

# customize prompt

PROMPT_PRE=''
if [[ $SESSION_TYPE == 'remote/ssh' ]]; then
  PROMPT_PRE='%n@%m '
fi

PROMPT='${PROMPT_PRE}%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX %{$fg[green]%}%p %{$fg[green]%}%c %{$fg[cyan]%}$(git_super_status)%{$fg_bold[red]%}% %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[cyan]%}] "

ZSH_THEME_GIT_PROMPT_SEPARATOR=""
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[blue]%}%{ ●%G%}"
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{ ✖%G%}"
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[yellow]%}%{ ✚%G%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{ ↓%G%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{ ↑%G%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}%{ …%G%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""

#
# END PROMPT
#

TODO

  • Seems correct but real merge conflicts still need to be tested
  • Actually seems buggy - need more definition around the blue dot vs yellow +

Dependencies

~1MB
~18K SLoC