Bugfixes and simplifications after revision

from bpinto. Thank you very much.
This commit is contained in:
Joseph Tannhuber 2014-08-06 12:51:20 +02:00
parent b842611986
commit 9376094d05
2 changed files with 33 additions and 15 deletions

View File

@ -13,29 +13,29 @@
###############################################################################
# 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
# 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"
# some terminals cannot change the cursor color
set -l unsupported_terminals "fbterm" "st" "linux" "screen"
for term in $unsupported_terminals
if test $term = $TERM
set -g budspencer_cursors "" "" ""
end
if contains $TERM $unsupported_terminals
set -e budspencer_cursors
end
###############################################################################
# Utils
###############################################################################
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
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 | 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])
else
echo -n (set_color -b $budspencer_colors[9])""(set_color $budspencer_colors[1])"  "$position" "(set_color $budspencer_colors[9])
@ -111,7 +111,6 @@ end
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

View File

@ -1,3 +1,8 @@
###############################################################################
# Init
###############################################################################
set -g CMD_DURATION 0
###############################################################################
# Utils
###############################################################################
@ -14,7 +19,7 @@ function __budspencer_git_status -d "Check git status"
set -l unmerged 0
set -l untracked 0
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 "^[\ ACMRT]D\ " > /dev/null; and set deleted (math $deleted+1)
echo $git_status[$i] | egrep "^.[MT]\ " > /dev/null; and set modified (math $modified+1)
@ -46,7 +51,7 @@ if set -q -x $PWDSTYLE
end
set pwd_style $PWDSTYLE[1]
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
set pwd_style $PWDSTYLE[(math $i%(count $PWDSTYLE)+1)]
commandline -f repaint
@ -58,12 +63,26 @@ bind -M default ' ' fish_pwd_toggle_cm
bind -M visual ' ' fish_pwd_toggle_cm
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:]]*||')
set -l seconds ""
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
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
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