zsh-git-prompt-rs 1.0.8

A git status prompt for zsh written in Rust
zsh-git-prompt-rs-1.0.8 is not a library.

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

Development

The justfile is the source of truth for build/test/lint. CI runs just ci; run the same locally before pushing:

just ci          # fmt-check + lint + test + build
just install     # build and install gitstatus into ~/.cargo/bin

CI runs on Forgejo Actions (.forgejo/workflows/ci-linux.yml) and checks formatting, clippy (warnings = errors), tests, and a release build. The Rust toolchain is pinned in rust-toolchain.toml and must match the toolchain: input in every workflow.

Releases

Releases are cut by pushing a vX.Y.Z tag. Forgejo Actions runs .forgejo/workflows/release.yml, which bumps the version in Cargo.toml, regenerates Cargo.lock, pushes the bump back to main, and publishes to crates.io.

git tag v1.0.5
git push origin v1.0.5

Required Forgejo repo secrets (Settings → Actions → Secrets and Variables):

  • PAT — Forgejo personal access token with write:repository scope (used to push the version bump back to main).
  • CRATES_IO_TOKEN — API token from https://crates.io/settings/tokens.

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
#