Skip to content

Instantly share code, notes, and snippets.

@sanbox-irl
Created April 25, 2026 17:11
Show Gist options
  • Select an option

  • Save sanbox-irl/71efce7ab7fb5c9a8dcd969ce501ec1b to your computer and use it in GitHub Desktop.

Select an option

Save sanbox-irl/71efce7ab7fb5c9a8dcd969ce501ec1b to your computer and use it in GitHub Desktop.
function fish_prompt
set_color blue --bold
echo -n (prompt_pwd)
# 2. Check for Jujutsu first
if jj root >/dev/null 2>&1
set -l jj_shortest (jj log -r @ -T "change_id.shortest()" --no-graph 2>/dev/null)
if test -n "$jj_shortest"
set -l jj_full (jj log -r @ -T "change_id.short(8)" --no-graph 2>/dev/null)
set -l jj_rest (string replace "$jj_shortest" "" "$jj_full")
echo -n " "
# Highlight the shortest unique part (Bold/Bright)
set_color white --bold
echo -n $jj_shortest
set_color normal
end
set -l jj_bookmark (jj log -r @ -T "bookmarks.join(', ')" --no-graph 2>/dev/null | string trim)
set -l had_bookmark false
if test -n "$jj_bookmark"
set_color cyan
echo -n " $jj_bookmark"
set_color normal
set had_bookmark true
end
# check for diffs and show those
set -l jj_diffs (jj diff --summary 2>/dev/null | wc -l | string trim)
if test "$jj_diffs" -gt 0
set_color blue --dim
echo -n " ($jj_diffs)"
set_color normal
end
else if git rev-parse --is-inside-work-tree >/dev/null 2>&1
# --- Git Logic ---
set -l branch (git branch --show-current)
set_color cyan
echo -n " $branch"
# Get the status lines as an array
set -l git_status (git status --porcelain 2>/dev/null)
if test -n "$git_status"
# Parse into arrays using string match
set -l untracked (string match -r '^\?\?' -- $git_status)
set -l modified (string match -v -r '^\?\?' -- $git_status)
# Show modified count
if set -q modified[1]
set_color magenta
# Notice how (count) is OUTSIDE the quotes now
echo -n " !"(count $modified)
end
# Show untracked count
if set -q untracked[1]
set_color yellow
echo -n " ?"(count $untracked)
end
end
set_color normal
end
set_color cyan --bold
echo -n ' ❯ '
set_color normal
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment