zsh-git-prompt-rs

Crates.iozsh-git-prompt-rs
lib.rszsh-git-prompt-rs
version1.0.3
created_at2024-12-18 06:00:45.466604+00
updated_at2026-01-18 14:08:59.679815+00
descriptionA git status prompt for zsh written in Rust
homepage
repositoryhttps://github.com/navicore/zsh-git-prompt-rs
max_upload_size
id1487240
size30,877
Ed Sweeney (navicore)

documentation

https://docs.rs/zsh-git-prompt-rs

README

Dependabot Updates rust-clippy analyze Publish-Crate

zsh prompt originally 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

The prompt supports optional Nerd Font icons for the branch symbol and stash indicator. If you have a Nerd Font installed, you can enable them by setting ZSH_THEME_GIT_PROMPT_BRANCH_SYMBOL and ZSH_THEME_GIT_PROMPT_STASH as shown in the example below.

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 %{$reset_color%}$(git_super_status)%{$fg_bold[red]%}% %{$reset_color%}'

# Git prompt customization
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=" "
ZSH_THEME_GIT_PROMPT_SEPARATOR=""
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_BRANCH_SYMBOL="%{$fg_bold[cyan]%}%{%G%}"  # nerd font branch icon
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_STASH="%{$fg[yellow]%}%{ 󰏗%G%}"  # nerd font stash icon
ZSH_THEME_GIT_PROMPT_CLEAN=""

#
# END PROMPT
#
Commit count: 63

cargo fmt