Skip to content

Instantly share code, notes, and snippets.

@nickcernis
Last active January 14, 2026 16:18
Show Gist options
  • Select an option

  • Save nickcernis/7a6ec18761a34690484cb5f6cec96dac to your computer and use it in GitHub Desktop.

Select an option

Save nickcernis/7a6ec18761a34690484cb5f6cec96dac to your computer and use it in GitHub Desktop.
Fast lightweight zsh prompt — just folder and git branch, no fancy plugins needed
# Gives this prompt if in git root:
#
# folder-name on branch
# ❯
#
# Or this if no git root:
#
# folder-name
# ❯
# Add line break before prompt
precmd() { print "" }
# Fast git branch detection
git_branch() {
local branch
if [[ -f .git/HEAD ]]; then
read branch < .git/HEAD
branch=${branch#ref: refs/heads/}
echo " %F{white}on%f %B%F{magenta}$branch%f%b"
fi
}
# Styled prompt
setopt PROMPT_SUBST
PROMPT='%B%F{cyan}%1~%f%b$(git_branch)
%F{green}❯%f '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment