diff options
| author | czjstmax <jstmaxlol@disroot.org> | 2026-05-16 19:12:26 +0200 |
|---|---|---|
| committer | czjstmax <jstmaxlol@disroot.org> | 2026-05-16 19:12:26 +0200 |
| commit | 555b84b82c9a543ec977c6ba8aaa1a16a9613949 (patch) | |
| tree | 5d10d335b0f282ce97e6471dd52ac9d851df05f3 /cfg/fish | |
| parent | 458feb2e60946e5a9ae99fc693e260648671fc33 (diff) | |
Signed-off-by: czjstmax <jstmaxlol@disroot.org>
Diffstat (limited to 'cfg/fish')
| -rw-r--r-- | cfg/fish/fish_prompt.fish | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/cfg/fish/fish_prompt.fish b/cfg/fish/fish_prompt.fish index 8ff31f5..2d6d377 100644 --- a/cfg/fish/fish_prompt.fish +++ b/cfg/fish/fish_prompt.fish @@ -7,24 +7,36 @@ function fish_prompt set -l on_sym "⊢" set -l prompt_sym "λ" set -l root_dir_sym "" + # git integration set -l branch_sym "" set -l branch "" + set -l in_git false + set -l detached false if test "$user" = "root" set prompt_sym "#" end - set -l in_git false - if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" + if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true set in_git true end - if test "$in_git" = "true" - #set branch (git branch --show-current 2>/dev/null) + if test "$in_git" = true + if git status --porcelain=2 --branch | string match -q "*detached*" + set detached true + end + end + + if test "$in_git" = true; and test "$detached" = true + set on_sym "⊬" + end + + if test "$in_git" = true set branch (git branch --show-current 2>/dev/null); or set branch (git rev-parse --short HEAD 2>/dev/null) set branch "$branch_sym"(set_color red)"$branch" end + if test "$cwd" = "$home" set colored "~" echo -e (set_color white)"$pr_prefix"(set_color red)"$user"(set_color white)" $at_sym "(set_color red)"$colored"(set_color white)"\n"\ @@ -44,7 +56,7 @@ function fish_prompt set colored (string trim -r -c "/" $colored) # if in a ~ subdir - if test "$in_git" = "true" + if test "$in_git" = true echo -e (set_color white)"$pr_prefix"(set_color red)"$user"(set_color white)" $at_sym "(set_color red)"$colored"\ (set_color white)"$on_sym ""$branch"(set_color white)"\n" \ (set_color white)"$prompt_sym "(set_color normal) @@ -65,7 +77,7 @@ function fish_prompt set colored (string trim -r -c "/" $colored) set colored (set_color red)"$root_dir_sym""$colored" # if in any other dir - if test "$in_git" = "true" + if test "$in_git" = true echo -e (set_color white)"$pr_prefix"(set_color red)"$user"(set_color white)" $at_sym "(set_color red)"$colored"\ (set_color white)"$on_sym ""$branch"(set_color white)"\n" \ (set_color white)"$prompt_sym "(set_color normal) |