Skip to content

Instantly share code, notes, and snippets.

@pnf
Created January 19, 2026 16:40
Show Gist options
  • Select an option

  • Save pnf/2ef343be58dc4e079c112055f677b29e to your computer and use it in GitHub Desktop.

Select an option

Save pnf/2ef343be58dc4e079c112055f677b29e to your computer and use it in GitHub Desktop.
#!/bin/sh
git_symbol="#{TMUX_GIT_SYMBOL}"
dirty_symbol="#{TMUX_GIT_DIRTY}"
conflict_symbol="#{TMUX_GIT_CONFLICT}"
stashed_symbol="#{TMUX_GIT_STASHED}"
ahead_symbol="#{TMUX_GIT_AHEAD}"
behind_symbol="#{TMUX_GIT_BEHIND}"
diverged_symbol="#{TMUX_GIT_DIVERGED}"
pane_path=$(tmux display-message -p -t "$TMUX_PANE" -F "#{pane_current_path}")
if git -C "$pane_path" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
git_root=$(basename "$(git -C "$pane_path" rev-parse --show-toplevel)")
git_branch=$(git branch --show-current)
symbols=""
[ -n "$(git -C "$pane_path" status --porcelain)" ] && symbols="${symbols}${dirty_symbol}"
[ -n "$(git -C "$pane_path" diff --name-only --diff-filter=U)" ] && symbols="${symbols}${conflict_symbol}"
[ -n "$(git -C "$pane_path" stash list)" ] && symbols="${symbols}${stashed_symbol}"
upstream=$(git -C "$pane_path" rev-list --count --left-right @{u}...HEAD 2>/dev/null)
if [ $? -eq 0 ]; then
behind=$(echo "$upstream" | cut -f1)
ahead=$(echo "$upstream" | cut -f2)
if [ "$ahead" -gt 0 ] && [ "$behind" -gt 0 ]; then
symbols="${symbols}${diverged_symbol}"
elif [ "$ahead" -gt 0 ]; then
symbols="${symbols}${ahead_symbol}"
elif [ "$behind" -gt 0 ]; then
symbols="${symbols}${behind_symbol}"
fi
fi
echo "${git_symbol}${git_root}${symbols}"
# echo "${git_symbol}${git_root}:${git_branch}"
else
echo 📁$(basename "$(dirname "$pane_path")")/$(basename "$pane_path")
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment