From dde875e474abf6439c6421b58013453915f6808d Mon Sep 17 00:00:00 2001 From: Nick Mello Date: Tue, 24 Feb 2026 22:47:13 -0600 Subject: [PATCH] fish: Add fish prompt for customization Signed-off-by: Nicholas Mello --- fish/functions/fish_prompt.fish | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 fish/functions/fish_prompt.fish diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..282ff5a --- /dev/null +++ b/fish/functions/fish_prompt.fish @@ -0,0 +1,64 @@ +function fish_prompt + set -l last_status $status + set -l cwd (prompt_pwd) + set -l jobs_count (count (jobs -p)) + + # --- Base path --- + set_color cyan + echo -n $cwd + + # --- Git Info --- + if command -sq git + if git rev-parse --is-inside-work-tree >/dev/null 2>&1 + set -l branch (git symbolic-ref --short HEAD 2>/dev/null; or git rev-parse --short HEAD) + + # Ahead / behind vs upstream + set -l ahead 0 + set -l behind 0 + set -l counts (git rev-list --left-right --count @{upstream}...HEAD 2>/dev/null) + + if test -n "$counts" + set behind (echo $counts | awk '{print $1}') + set ahead (echo $counts | awk '{print $2}') + end + + # Dirty working tree? + git diff --quiet --ignore-submodules HEAD >/dev/null 2>&1 + or set -l dirty "*" + + set_color magenta + echo -n " ["$branch + + if test $ahead -gt 0 + echo -n " ↑$ahead" + end + + if test $behind -gt 0 + echo -n " ↓$behind" + end + + if test -n "$dirty" + echo -n " $dirty" + end + + echo -n "]" + end + end + + if test $jobs_count -gt 0 + set_color yellow + echo -n " [$jobs_count jobs]" + set_color normal + end + + # --- Exit status --- + if test $last_status -ne 0 + set_color red + echo -n " [$last_status]" + end + + # --- Final prompt character --- + set_color green + echo -n "> " + set_color normal +end