From a5d6be98633ac692f7a0cd23e613c03c0ea90351 Mon Sep 17 00:00:00 2001 From: Froloket64 Date: Sat, 5 Mar 2022 13:37:57 +0300 Subject: [PATCH 1/4] Changed vi mode indication to the arrow --- functions/fish_prompt.fish | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index a3ce22a..1fb8a67 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -1,4 +1,10 @@ # name: Integral +# fork by: Froloket + +# Overwrite mode prompt as we use another approach +function fish_mode_prompt +end + function _git_branch_name echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||') end @@ -39,7 +45,7 @@ function fish_prompt set -l green (set_color green) set -l arrow "∫" - set -l cwd $blue(prompt_pwd) + set -l cwd $blue(prompt_pwd) $normal if [ (_git_branch_name) ] set -l git_branch (_git_branch_name) @@ -54,12 +60,30 @@ function fish_prompt end end - echo -n -s $cwd' '"$git_info" $normal $arrow ' ' + # Set $arrow color depending on mode (when in vi mode) + if test "$fish_key_bindings" = fish_vi_key_bindings + or test "$fish_key_bindings" = fish_hybrid_key_bindings + switch $fish_bind_mode + case default + set arrow_color (set_color brblack) + case insert + set arrow_color (set_color brwhite) + case replace_one + set arrow_color (set_color green) + case replace + set arrow_color (set_color yellow) + case visual + set arrow_color (set_color magenta) + end + else + set arrow_color $normal + end + + echo -n -s ' ' $cwd ' ' "$git_info" $arrow_color $arrow $normal ' ' end function fish_right_prompt set -l dark_gray (set_color 222) echo -n -s $dark_gray ' ['(date +%H:%M:%S)'] ' - end From 0deb5c333ee4b6a726718d1aac0cd2d4028df619 Mon Sep 17 00:00:00 2001 From: Froloket64 Date: Fri, 22 Apr 2022 14:56:17 +0300 Subject: [PATCH 2/4] **Bugfix**: Now tab completion is colored in `normal` instead of `dark_grey` from the clock --- functions/fish_prompt.fish | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 1fb8a67..1b5a0e6 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -1,6 +1,13 @@ # name: Integral # fork by: Froloket +# Colors +set blue (set_color blue) +set yellow (set_color yellow) +set normal (set_color normal) +set green (set_color green) +set dark_gray (set_color 222) + # Overwrite mode prompt as we use another approach function fish_mode_prompt end @@ -39,11 +46,6 @@ function _is_git_dirty end function fish_prompt - set -l blue (set_color blue) - set -l yellow (set_color yellow) - set -l normal (set_color normal) - set -l green (set_color green) - set -l arrow "∫" set -l cwd $blue(prompt_pwd) $normal @@ -83,7 +85,5 @@ function fish_prompt end function fish_right_prompt - set -l dark_gray (set_color 222) - - echo -n -s $dark_gray ' ['(date +%H:%M:%S)'] ' + echo -n -s $dark_gray ' ['(date +%H:%M:%S)'] ' $normal end From 9c2098b615c557a23378b326e5fa4780fd021970 Mon Sep 17 00:00:00 2001 From: Froloket64 Date: Fri, 10 Nov 2023 23:48:22 +0300 Subject: [PATCH 3/4] Rework prompt display; Allow to change arrow symbol --- functions/fish_prompt.fish | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 1b5a0e6..41c1b44 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -8,6 +8,8 @@ set normal (set_color normal) set green (set_color green) set dark_gray (set_color 222) +set arrow_symbol "∫" + # Overwrite mode prompt as we use another approach function fish_mode_prompt end @@ -20,6 +22,10 @@ function _upstream_count echo (command git rev-list --count --left-right origin/(_git_branch_name)...HEAD 2> /dev/null) end +function set_arrow -a symbol + set arrow_symbol $symbol +end + function _git_up_info if [ (_upstream_count) ] set -l count (_upstream_count) @@ -45,13 +51,27 @@ function _is_git_dirty echo (command git status -s --ignore-submodules=dirty 2> /dev/null) end +function charrow -a mode + switch $mode + case "default" + set arrow_symbol "∫" + case "haskell" "lambda" + set arrow_symbol "λ" + case "arrow" + set arrow_symbol ">" + case "*" + charrow default + end +end + function fish_prompt - set -l arrow "∫" - set -l cwd $blue(prompt_pwd) $normal + if [ (prompt_pwd) != "~" ] + set cwd $blue(prompt_pwd) $normal + end if [ (_git_branch_name) ] - set -l git_branch (_git_branch_name) - set -l git_vs_upstream (_git_up_info) + set git_branch (_git_branch_name) + set git_vs_upstream (_git_up_info) if [ (_is_git_dirty) ] set git_info $yellow'('$git_branch "±" "$git_vs_upstream"')' $normal @@ -81,7 +101,9 @@ function fish_prompt set arrow_color $normal end - echo -n -s ' ' $cwd ' ' "$git_info" $arrow_color $arrow $normal ' ' + set arrow $arrow_color$arrow_symbol$normal + + printf " $cwd$git_info$arrow " end function fish_right_prompt From a634e33eec6a9a363ab6f7e2c67e1a8907e8c3e6 Mon Sep 17 00:00:00 2001 From: Froloket64 Date: Fri, 10 Nov 2023 23:48:58 +0300 Subject: [PATCH 4/4] Convert tabs from 2 to 4 spaces --- functions/fish_prompt.fish | 134 ++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 41c1b44..cf66969 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -15,97 +15,97 @@ function fish_mode_prompt end function _git_branch_name - echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||') + echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||') end function _upstream_count - echo (command git rev-list --count --left-right origin/(_git_branch_name)...HEAD 2> /dev/null) + echo (command git rev-list --count --left-right origin/(_git_branch_name)...HEAD 2> /dev/null) end function set_arrow -a symbol - set arrow_symbol $symbol + set arrow_symbol $symbol end function _git_up_info - if [ (_upstream_count) ] - set -l count (_upstream_count) - - switch $count - case "" # no upstream - echo '' - case "0?0" # equal to upstream - echo '' - case "0??" # ahead of upstream - echo 'u+'(echo $count | cut -f2) - case "??0" # behind upstream - echo 'u-'(echo $count | cut -f1) - case '???' # diverged from upstream - echo $count 'u+'(echo $count | cut -f2)'-'(echo $count | cut -f1) - case '*' - echo '' + if [ (_upstream_count) ] + set -l count (_upstream_count) + + switch $count + case "" # no upstream + echo '' + case "0?0" # equal to upstream + echo '' + case "0??" # ahead of upstream + echo 'u+'(echo $count | cut -f2) + case "??0" # behind upstream + echo 'u-'(echo $count | cut -f1) + case '???' # diverged from upstream + echo $count 'u+'(echo $count | cut -f2)'-'(echo $count | cut -f1) + case '*' + echo '' + end end - end end function _is_git_dirty - echo (command git status -s --ignore-submodules=dirty 2> /dev/null) + echo (command git status -s --ignore-submodules=dirty 2> /dev/null) end function charrow -a mode - switch $mode - case "default" - set arrow_symbol "∫" - case "haskell" "lambda" - set arrow_symbol "λ" - case "arrow" - set arrow_symbol ">" - case "*" - charrow default - end + switch $mode + case "default" + set arrow_symbol "∫" + case "haskell" "lambda" + set arrow_symbol "λ" + case "arrow" + set arrow_symbol ">" + case "*" + charrow default + end end function fish_prompt - if [ (prompt_pwd) != "~" ] - set cwd $blue(prompt_pwd) $normal - end - - if [ (_git_branch_name) ] - set git_branch (_git_branch_name) - set git_vs_upstream (_git_up_info) - - if [ (_is_git_dirty) ] - set git_info $yellow'('$git_branch "±" "$git_vs_upstream"')' $normal - else if [ (_git_up_info) ] - set git_info $yellow'('$git_branch "$git_vs_upstream"')' $normal - else - set git_info $green'('$git_branch')' $normal + if [ (prompt_pwd) != "~" ] + set cwd $blue(prompt_pwd) $normal + end + + if [ (_git_branch_name) ] + set git_branch (_git_branch_name) + set git_vs_upstream (_git_up_info) + + if [ (_is_git_dirty) ] + set git_info $yellow'('$git_branch "±" "$git_vs_upstream"')' $normal + else if [ (_git_up_info) ] + set git_info $yellow'('$git_branch "$git_vs_upstream"')' $normal + else + set git_info $green'('$git_branch')' $normal + end end - end - - # Set $arrow color depending on mode (when in vi mode) - if test "$fish_key_bindings" = fish_vi_key_bindings - or test "$fish_key_bindings" = fish_hybrid_key_bindings - switch $fish_bind_mode - case default - set arrow_color (set_color brblack) - case insert - set arrow_color (set_color brwhite) - case replace_one - set arrow_color (set_color green) - case replace - set arrow_color (set_color yellow) - case visual - set arrow_color (set_color magenta) + + # Set $arrow color depending on mode (when in vi mode) + if test "$fish_key_bindings" = fish_vi_key_bindings + or test "$fish_key_bindings" = fish_hybrid_key_bindings + switch $fish_bind_mode + case default + set arrow_color (set_color brblack) + case insert + set arrow_color (set_color brwhite) + case replace_one + set arrow_color (set_color green) + case replace + set arrow_color (set_color yellow) + case visual + set arrow_color (set_color magenta) + end + else + set arrow_color $normal end - else - set arrow_color $normal - end - set arrow $arrow_color$arrow_symbol$normal + set arrow $arrow_color$arrow_symbol$normal - printf " $cwd$git_info$arrow " + printf " $cwd$git_info$arrow " end function fish_right_prompt - echo -n -s $dark_gray ' ['(date +%H:%M:%S)'] ' $normal + echo -n -s $dark_gray ' ['(date +%H:%M:%S)'] ' $normal end