From 092913992741384894caa98a37cf61e1096999d7 Mon Sep 17 00:00:00 2001 From: czjstmax Date: Sat, 16 May 2026 17:55:27 +0200 Subject: update fish prompt + git integration, remove right prompt --- cfg/fish/fish_prompt.fish | 30 +++++++++++++++++++++++++----- cfg/fish/fish_right_prompt.fish | 20 -------------------- 2 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 cfg/fish/fish_right_prompt.fish diff --git a/cfg/fish/fish_prompt.fish b/cfg/fish/fish_prompt.fish index b14256f..e5c6af9 100644 --- a/cfg/fish/fish_prompt.fish +++ b/cfg/fish/fish_prompt.fish @@ -2,10 +2,18 @@ function fish_prompt set -l user $USER set -l cwd $PWD set -l home $HOME + set -l branch "" + set -l branch_sym "" # unused but here for da futurr + if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" + #set branch (git branch --show-current 2>/dev/null) + set branch (git branch --show-current 2>/dev/null); or set branch (git rev-parse --short HEAD 2>/dev/null) + end + if test "$cwd" = "$home" + set colored "~" # if in ~ - echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"~"(set_color white)")\n" \ + echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n"\ (set_color white)"λ "(set_color normal) # max at ~ # λ @@ -23,8 +31,14 @@ function fish_prompt set colored (string trim -r -c "/" $colored) # if in a ~ subdir - echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n" \ - (set_color white)"λ "(set_color normal) + if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" + echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"\ + (set_color white)"on "(set_color red)"$branch"(set_color white)")\n" \ + (set_color white)"λ "(set_color normal) + else + echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n"\ + (set_color white)"λ "(set_color normal) + end else set -l parts (string split "/" $cwd) set -l colored "" @@ -38,7 +52,13 @@ function fish_prompt set colored (string trim -r -c "/" $colored) set colored (set_color red)"#"$colored # if in any other dir - echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n" \ - (set_color white)"λ "(set_color normal) + if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" + echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"\ + (set_color white)"on "(set_color red)"$branch"(set_color white)")\n" \ + (set_color white)"λ "(set_color normal) + else + echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n"\ + (set_color white)"λ "(set_color normal) + end end end diff --git a/cfg/fish/fish_right_prompt.fish b/cfg/fish/fish_right_prompt.fish deleted file mode 100644 index 8346fb5..0000000 --- a/cfg/fish/fish_right_prompt.fish +++ /dev/null @@ -1,20 +0,0 @@ -function fish_right_prompt - set last_status $status - - # check for which color to use - if test $last_status -eq 0 - set color white - else - set color red - end - - # set battery capacity in bat - set bat $(cat /sys/class/power_supply/BAT0/capacity) - - # move up a line - echo -e "\e[1A" - # print prompt - echo -e (set_color red)"( "(set_color $color)"$last_status"(set_color red)" |" \ - (set_color white)"$bat%"(set_color red)" )"(set_color normal) - echo -e "\e[1B" -end -- cgit v1.3.1