5 files changed,
58 insertions(+),
2 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-03-23 17:31:17 +0200
Parent:
fa061e6
A
config/fish/functions/fish_default_mode_prompt.fish
··· 1 +function fish_default_mode_prompt 2 +end
A
config/fish/functions/fish_prompt.fish
··· 1 +function fish_prompt 2 + set -l last_status $status 3 + set -l cwd (prompt_pwd --full-length-dirs 1) 4 + set -l vcs (prompt_vcs) 5 + 6 + switch $fish_bind_mode 7 + case default 8 + set mode_char "❮" 9 + set mode_color (set_color cyan) 10 + case '*' 11 + set mode_char "❯" 12 + if test $last_status -eq 0 13 + set mode_color (set_color green) 14 + else 15 + set mode_color (set_color red) 16 + end 17 + end 18 + 19 + printf '%s%s%s%s %s%s%s ' (set_color cyan) $cwd (set_color normal) $vcs $mode_color $mode_char (set_color normal) 20 +end
A
config/fish/functions/prompt_vcs.fish
··· 1 +function prompt_vcs 2 + if command -sq jj; and jj root --quiet >/dev/null 2>&1 3 + set -l head (jj log --no-graph -r "@" -T "change_id.shortest()" 2>/dev/null) 4 + printf ' %s(jj: %s%s%s)%s' (set_color normal) (set_color blue) $head (set_color normal) (set_color normal) 5 + return 6 + end 7 + 8 + if not command -sq git 9 + return 10 + end 11 + 12 + set -l status_lines (command git status --porcelain=1 -b --ignore-submodules=dirty 2>/dev/null) 13 + if test $status -ne 0; or test (count $status_lines) -eq 0 14 + return 15 + end 16 + 17 + set -l branch_line $status_lines[1] 18 + if test -z "$branch_line" 19 + return 20 + end 21 + 22 + set -l branch (string replace -r '^## ' '' -- $branch_line) 23 + set branch (string replace -r '\\.{3}.*$' '' -- $branch) 24 + set branch (string replace -r '^No commits yet on ' '' -- $branch) 25 + if string match -qr '^HEAD' -- $branch 26 + set branch (command git rev-parse --short HEAD 2>/dev/null; or echo "HEAD") 27 + end 28 + 29 + set -l dirty "" 30 + if test (count $status_lines) -gt 1 31 + set dirty "*" 32 + end 33 + 34 + printf ' %s(%s%s%s%s%s)%s' (set_color normal) (set_color blue) $branch (set_color yellow) $dirty (set_color normal) (set_color normal) 35 +end