Skip to content
Snippets Groups Projects
Commit 9376094d authored by Joseph Tannhuber's avatar Joseph Tannhuber
Browse files

Bugfixes and simplifications after revision

from bpinto. Thank you very much.
parent b8426119
Branches
Tags
No related merge requests found
...@@ -13,29 +13,29 @@ ...@@ -13,29 +13,29 @@
############################################################################### ###############################################################################
# define colors # define colors
# values are: black dark_gray light_gray white yellow orange red magenta violet blue cyan green
set -g budspencer_colors 000000 083743 445659 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
# cursor colors # cursor color changes according to vi-mode
# define values for: normal_mode insert_mode visual_mode
set -g budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" set -g budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007"
# some terminals cannot change the cursor color
set -l unsupported_terminals "fbterm" "st" "linux" "screen" set -l unsupported_terminals "fbterm" "st" "linux" "screen"
for term in $unsupported_terminals if contains $TERM $unsupported_terminals
if test $term = $TERM set -e budspencer_cursors
set -g budspencer_cursors "" "" ""
end
end end
############################################################################### ###############################################################################
# Utils # Utils
############################################################################### ###############################################################################
set -g __budspencer_display_rprompt 1
function __budspencer_git_branch_name -d "Return the current branch name" 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/||') set -l branch (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
if test (count $branch) -eq 0 if test (count $branch) -eq 0
set -l position (git describe --contains --all HEAD ^/dev/null) set -l position (git describe --contains --all HEAD ^/dev/null)
if test (count $position) -eq 0 if test (count $position) -eq 0
set -l commit (git rev-parse HEAD ^/dev/null | sed -r 's|(^.{7}).*|\1|') set -l commit (git rev-parse HEAD ^/dev/null | sed 's|\(^.......\).*|\1|')
echo -n (set_color -b $budspencer_colors[11])""(set_color $budspencer_colors[1])" ➦ "$commit" "(set_color $budspencer_colors[11]) echo -n (set_color -b $budspencer_colors[11])""(set_color $budspencer_colors[1])" ➦ "$commit" "(set_color $budspencer_colors[11])
else else
echo -n (set_color -b $budspencer_colors[9])""(set_color $budspencer_colors[1])"  "$position" "(set_color $budspencer_colors[9]) echo -n (set_color -b $budspencer_colors[9])""(set_color $budspencer_colors[1])"  "$position" "(set_color $budspencer_colors[9])
...@@ -111,7 +111,6 @@ end ...@@ -111,7 +111,6 @@ end
function fish_prompt -d "Write out the left prompt of the budspencer theme" function fish_prompt -d "Write out the left prompt of the budspencer theme"
set -g last_status $status set -g last_status $status
set -l basedir_name (basename (prompt_pwd))
############################################################################# #############################################################################
# Segments # Segments
......
###############################################################################
# Init
###############################################################################
set -g CMD_DURATION 0
############################################################################### ###############################################################################
# Utils # Utils
############################################################################### ###############################################################################
...@@ -14,7 +19,7 @@ function __budspencer_git_status -d "Check git status" ...@@ -14,7 +19,7 @@ function __budspencer_git_status -d "Check git status"
set -l unmerged 0 set -l unmerged 0
set -l untracked 0 set -l untracked 0
set -l git_status (command git status --porcelain ^/dev/null) set -l git_status (command git status --porcelain ^/dev/null)
for i in (seq 1 (count $git_status)) for i in (seq (count $git_status))
echo $git_status[$i] | egrep "^[ACDMT][\ MT]\ |^[ACMT]D\ " > /dev/null; and set added (math $added+1) echo $git_status[$i] | egrep "^[ACDMT][\ MT]\ |^[ACMT]D\ " > /dev/null; and set added (math $added+1)
echo $git_status[$i] | egrep "^[\ ACMRT]D\ " > /dev/null; and set deleted (math $deleted+1) echo $git_status[$i] | egrep "^[\ ACMRT]D\ " > /dev/null; and set deleted (math $deleted+1)
echo $git_status[$i] | egrep "^.[MT]\ " > /dev/null; and set modified (math $modified+1) echo $git_status[$i] | egrep "^.[MT]\ " > /dev/null; and set modified (math $modified+1)
...@@ -46,7 +51,7 @@ if set -q -x $PWDSTYLE ...@@ -46,7 +51,7 @@ if set -q -x $PWDSTYLE
end end
set pwd_style $PWDSTYLE[1] set pwd_style $PWDSTYLE[1]
function fish_pwd_toggle_cm -d "Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode" function fish_pwd_toggle_cm -d "Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode"
for i in (seq 1 (count $PWDSTYLE)) for i in (seq (count $PWDSTYLE))
if test $PWDSTYLE[$i] = $pwd_style if test $PWDSTYLE[$i] = $pwd_style
set pwd_style $PWDSTYLE[(math $i%(count $PWDSTYLE)+1)] set pwd_style $PWDSTYLE[(math $i%(count $PWDSTYLE)+1)]
commandline -f repaint commandline -f repaint
...@@ -58,12 +63,26 @@ bind -M default ' ' fish_pwd_toggle_cm ...@@ -58,12 +63,26 @@ bind -M default ' ' fish_pwd_toggle_cm
bind -M visual ' ' fish_pwd_toggle_cm bind -M visual ' ' fish_pwd_toggle_cm
function fish_cmd_duration_cm -d "Displays the elapsed time of last command" function fish_cmd_duration_cm -d "Displays the elapsed time of last command"
if test (count $CMD_DURATION) -gt 0 set -l seconds ""
set -l duration (echo $CMD_DURATION | tr -d '[[:space:]]' | sed 's|\.[[:digit:]]*||') set -l minutes ""
set -l hours ""
set -l days ""
set -l cmd_duration (math $CMD_DURATION/1000)
if test $cmd_duration -gt 0
set seconds (math $cmd_duration%68400%3600%60)"s"
if test $cmd_duration -ge 60
set minutes (math $cmd_duration%68400%3600/60)"m"
if test $cmd_duration -ge 3600
set hours (math $cmd_duration%68400/3600)"h"
if test $cmd_duration -ge 68400
set days (math $cmd_duration/68400)"d"
end
end
end
if test $last_status -ne 0 if test $last_status -ne 0
echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[7])" "$duration echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[7])" "$days$hours$minutes$seconds
else else
echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[12])" "$duration echo -n (set_color $budspencer_colors[2])""(set_color -b $budspencer_colors[2] $budspencer_colors[12])" "$days$hours$minutes$seconds
end end
end end
end end
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment