diff --git a/themes/budspencer/fish_prompt.fish b/themes/budspencer/fish_prompt.fish index acb7cc1..8e1a289 100644 --- a/themes/budspencer/fish_prompt.fish +++ b/themes/budspencer/fish_prompt.fish @@ -1,10 +1,17 @@ -# TODO: git improvements -# name: budspencer +############################################################################### +# +# prompt theme name: budspencer +# +# description: a sophisticated airline/powerline theme +# +# author: Joseph Tannhuber +# +############################################################################### ############################################################################### # Color definitions ############################################################################### -set -g budspencer_colors 000000 002b36 083743 445659 657b83 839496 93a1a1 eee8d5 fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900 +set -g budspencer_colors 000000 083743 445659 fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900 ############################################################################### # Utils @@ -15,80 +22,89 @@ set -g __budspencer_display_rprompt 1 function __budspencer_git_branch_name -d "Return the current branch name" set -l branch (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') if test (count $branch) -eq 0 - echo -n (set_color -b $budspencer_colors[14])""(set_color $budspencer_colors[1])"  "(git describe --contains --all HEAD ^/dev/null)" "(set_color $budspencer_colors[14]) + set -l position (git describe --contains --all HEAD ^/dev/null) + if test (count $position) -eq 0 + set -l commit (git rev-parse HEAD ^/dev/null) + echo -n (set_color -b $budspencer_colors[11])""(set_color $budspencer_colors[1])" ➦ "$commit" "(set_color $budspencer_colors[11]) + else + echo -n (set_color -b $budspencer_colors[9])""(set_color $budspencer_colors[1])"  "$position" "(set_color $budspencer_colors[9]) + end else - echo -n (set_color -b $budspencer_colors[4])""(set_color $budspencer_colors[1])"  "$branch" "(set_color $budspencer_colors[4]) + echo -n (set_color -b $budspencer_colors[3])""(set_color $budspencer_colors[1])"  "$branch" "(set_color $budspencer_colors[3]) end end function fish_vi_prompt_cm --description "Displays the current mode" switch $fish_bind_mode case default - set_color -b $budspencer_colors[15] $budspencer_colors[1] - echo -en "\033]12;#$budspencer_colors[15]\007" - echo -n " NORMAL " - set_color -b $budspencer_colors[1] $budspencer_colors[15] - case insert set_color -b $budspencer_colors[10] $budspencer_colors[1] echo -en "\033]12;#$budspencer_colors[10]\007" - echo -n " INSERT " + echo -n " NORMAL " set_color -b $budspencer_colors[1] $budspencer_colors[10] + case insert + set_color -b $budspencer_colors[5] $budspencer_colors[1] + echo -en "\033]12;#$budspencer_colors[5]\007" + echo -n " INSERT " + set_color -b $budspencer_colors[1] $budspencer_colors[5] case visual - set_color -b $budspencer_colors[13] $budspencer_colors[1] - echo -en "\033]12;#$budspencer_colors[13]\007" + set_color -b $budspencer_colors[8] $budspencer_colors[1] + echo -en "\033]12;#$budspencer_colors[8]\007" echo -n " VISUAL " - set_color -b $budspencer_colors[1] $budspencer_colors[13] + set_color -b $budspencer_colors[1] $budspencer_colors[8] end end function fish_prompt_symbols --description "Display symbols" - set_color -b $budspencer_colors[3] + set_color -b $budspencer_colors[2] echo -n "" # indicator for vim parent process if set -q -x VIM - set_color $budspencer_colors[14] + set_color -o $budspencer_colors[9] echo -n " V" end # indicator for ranger parent process if set -q -x RANGER_LEVEL - set_color $budspencer_colors[14] + set_color -o $budspencer_colors[9] echo -n " R" end # background job indicator if [ (jobs | wc -l) -gt 0 ] - set_color $budspencer_colors[16] + set_color -o $budspencer_colors[11] echo -n " ⚙" end # write protection indicator if [ ! -w . ] - set_color $budspencer_colors[11] + set_color -o $budspencer_colors[6] echo -n " " end # status indicator if [ $last_status -eq 0 ] - set_color $budspencer_colors[17] + set_color -o $budspencer_colors[12] echo -n " ✔" else - set_color $budspencer_colors[12] + set_color -o $budspencer_colors[7] echo -n " ✘" end # superuser indicator if [ $USER = "root" ] - set_color $budspencer_colors[11] + set_color -o $budspencer_colors[6] echo -n " ⚡" end echo -n " " - set_color -b normal $budspencer_colors[3] + set_color -b normal $budspencer_colors[2] end + ############################################################################### -# Prompts +# Prompt ############################################################################### function fish_prompt -d "Write out the left prompt of the budspencer theme" set -g last_status $status set -l basedir_name (basename (prompt_pwd)) + ############################################################################# # Segments + ############################################################################# # vi mode set -l ps_vi "" @@ -103,11 +119,9 @@ function fish_prompt -d "Write out the left prompt of the budspencer theme" set ps_git $git_branch_name end + # symbols set -l ps_symbols (fish_prompt_symbols) - # Left Prompt - + # left prompt echo -n -s $ps_vi $ps_git $ps_symbols '' ' ' end - - diff --git a/themes/budspencer/fish_right_prompt.fish b/themes/budspencer/fish_right_prompt.fish index 9d50554..d9f4167 100644 --- a/themes/budspencer/fish_right_prompt.fish +++ b/themes/budspencer/fish_right_prompt.fish @@ -1,3 +1,7 @@ +############################################################################### +# Utils +############################################################################### + function __budspencer_is_git_ahead_or_behind -d "Check if there are unpulled or unpushed commits" echo (command git rev-list --count --left-right "HEAD...@{upstream}" ^/dev/null | sed 's/[[:space:]+]/\\x1e/g') end @@ -57,9 +61,9 @@ function fish_cmd_duration_cm -d "Displays the elapsed time of last command" if test (count $CMD_DURATION) -gt 0 set -l duration (echo $CMD_DURATION | tr -d '[[:space:]]' | sed 's|\.[[:digit:]]*||') if test $last_status -ne 0 - echo -n (set_color $budspencer_colors[3])""(set_color -b $budspencer_colors[3] $budspencer_colors[12])" "$duration + echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[7])" "$duration else - echo -n (set_color $budspencer_colors[3])""(set_color -b $budspencer_colors[3] $budspencer_colors[17])" "$duration + echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[12])" "$duration end end end @@ -73,17 +77,17 @@ function fish_git_prompt_cm --description "Displays the git symbols" if test (count $git_ahead_behind) -eq 2 if test $git_ahead_behind[1] -gt 0 if test $git_style = "symbols" - set git_prompt (set_color -o $budspencer_colors[10])" ↑" + set git_prompt (set_color -o $budspencer_colors[5])" ↑" else - set git_prompt (set_color -o $budspencer_colors[10])" "$git_ahead_behind[1] + set git_prompt (set_color -o $budspencer_colors[5])" "$git_ahead_behind[1] end end if test $git_ahead_behind[2] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[10])" ↓" + set git_prompt $git_prompt(set_color -o $budspencer_colors[5])" ↓" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[10])" "$git_ahead_behind[2] + set git_prompt $git_prompt(set_color -o $budspencer_colors[5])" "$git_ahead_behind[2] end end end @@ -91,58 +95,58 @@ function fish_git_prompt_cm --description "Displays the git symbols" set -l git_status (__budspencer_git_status) if test $git_status[1] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[17])" +" + set git_prompt $git_prompt(set_color -o $budspencer_colors[12])" +" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[17])" "$git_status[1] + set git_prompt $git_prompt(set_color -o $budspencer_colors[12])" "$git_status[1] end end if test $git_status[2] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[12])" –" + set git_prompt $git_prompt(set_color -o $budspencer_colors[7])" –" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[12])" "$git_status[2] + set git_prompt $git_prompt(set_color -o $budspencer_colors[7])" "$git_status[2] end end if test $git_status[3] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[15])" ✱" + set git_prompt $git_prompt(set_color -o $budspencer_colors[10])" ✱" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[15])" "$git_status[3] + set git_prompt $git_prompt(set_color -o $budspencer_colors[10])" "$git_status[3] end end if test $git_status[4] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[13])" →" + set git_prompt $git_prompt(set_color -o $budspencer_colors[8])" →" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[13])" "$git_status[4] + set git_prompt $git_prompt(set_color -o $budspencer_colors[8])" "$git_status[4] end end if test $git_status[5] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[14])" ═" + set git_prompt $git_prompt(set_color -o $budspencer_colors[9])" ═" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[14])" "$git_status[5] + set git_prompt $git_prompt(set_color -o $budspencer_colors[9])" "$git_status[5] end end if test $git_status[6] -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[9])" ●" + set git_prompt $git_prompt(set_color -o $budspencer_colors[4])" ●" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[9])" "$git_status[6] + set git_prompt $git_prompt(set_color -o $budspencer_colors[4])" "$git_status[6] end end set -l git_stashed (__budspencer_is_git_stashed) if test git_stashed -gt 0 if test $git_style = "symbols" - set git_prompt $git_prompt(set_color -o $budspencer_colors[16])" ✭" + set git_prompt $git_prompt(set_color -o $budspencer_colors[11])" ✭" else - set git_prompt $git_prompt(set_color -o $budspencer_colors[16])" "$git_stashed + set git_prompt $git_prompt(set_color -o $budspencer_colors[11])" "$git_stashed end end echo -n $git_prompt @@ -160,20 +164,20 @@ function fish_pwd_prompt_cm --description "Displays the present working director end switch $fish_bind_mode case default - set_color $budspencer_colors[15] - echo -n "" - set_color normal - set_color -b $budspencer_colors[15] $budspencer_colors[1] - case insert set_color $budspencer_colors[10] echo -n "" set_color normal set_color -b $budspencer_colors[10] $budspencer_colors[1] - case visual - set_color $budspencer_colors[13] + case insert + set_color $budspencer_colors[5] echo -n "" set_color normal - set_color -b $budspencer_colors[13] $budspencer_colors[1] + set_color -b $budspencer_colors[5] $budspencer_colors[1] + case visual + set_color $budspencer_colors[8] + echo -n "" + set_color normal + set_color -b $budspencer_colors[8] $budspencer_colors[1] end switch $pwd_style case none @@ -186,9 +190,15 @@ function fish_pwd_prompt_cm --description "Displays the present working director set_color normal end +############################################################################### +# Prompt +############################################################################### + function fish_right_prompt -d "Write out the right prompt of the budspencer theme" + ############################################################################# # Segments + ############################################################################# # command duration set ps_duration (fish_cmd_duration_cm) @@ -196,7 +206,7 @@ function fish_right_prompt -d "Write out the right prompt of the budspencer them # git set ps_git (fish_git_prompt_cm) if test -n "$ps_git" - set ps_git (set_color $budspencer_colors[4])""(set_color -b $budspencer_colors[4])""$ps_git + set ps_git (set_color $budspencer_colors[3])""(set_color -b $budspencer_colors[3])""$ps_git end # pwd @@ -205,6 +215,7 @@ function fish_right_prompt -d "Write out the right prompt of the budspencer them set ps_pwd (fish_pwd_prompt_cm) end + # right prompt echo -n $ps_duration $ps_git $ps_pwd set_color normal end