Skip to content
Snippets Groups Projects
Commit cf5b5aba authored by Bruno Pinto's avatar Bruno Pinto
Browse files

Merge pull request #251 from tannhuber/master

parents 01adb417 fce4cadd
Branches
No related merge requests found
...@@ -171,7 +171,8 @@ It makes the commandline as powerful as your editor. If `$EDITOR` is not set, ...@@ -171,7 +171,8 @@ It makes the commandline as powerful as your editor. If `$EDITOR` is not set,
vi is used. vi is used.
The following shortcut needs vi mode: The following shortcut needs vi mode:
- Type `.` in NORMAL mode to edit commandline in editor. - Type `.` in NORMAL mode or `\cv` in NORMAL/INSERT mode to edit commandline in
editor.
## Sessions ## Sessions
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
set -U budspencer_night 000000 083743 445659 fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900 set -U budspencer_night 000000 083743 445659 fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900
set -U budspencer_day 000000 333333 666666 ffffff ffff00 ff6600 ff0000 ff0033 3300ff 00aaff 00ffff 00ff00 set -U budspencer_day 000000 333333 666666 ffffff ffff00 ff6600 ff0000 ff0033 3300ff 00aaff 00ffff 00ff00
if not set -q budspencer_colors if not set -q budspencer_colors
# Values are: black dark_gray light_gray white yellow orange red magenta violet blue cyan green # Values are: black dark_gray light_gray white yellow orange red magenta violet blue cyan green
set -U budspencer_colors $budspencer_night set -U budspencer_colors $budspencer_night
end end
# Cursor color changes according to vi-mode # Cursor color changes according to vi-mode
...@@ -38,7 +38,7 @@ set -U budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budsp ...@@ -38,7 +38,7 @@ set -U budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budsp
# Some terminals cannot change the cursor color # Some terminals cannot change the cursor color
set -l unsupported_terminals 'fbterm' 'st' 'linux' 'screen' set -l unsupported_terminals 'fbterm' 'st' 'linux' 'screen'
if contains $TERM $unsupported_terminals if contains $TERM $unsupported_terminals
set budspencer_cursors '' '' '' '' set budspencer_cursors '' '' '' ''
end end
############################################################################### ###############################################################################
...@@ -49,54 +49,54 @@ end ...@@ -49,54 +49,54 @@ end
# => Help # => Help
######### #########
function budspencer_help -d 'Show helpfile' function budspencer_help -d 'Show helpfile'
set -l readme_file "$fish_path/themes/budspencer/README.md" set -l readme_file "$fish_path/themes/budspencer/README.md"
if set -q PAGER if set -q PAGER
if [ -e $readme_file ] if [ -e $readme_file ]
eval $PAGER $readme_file eval $PAGER $readme_file
else else
set_color $fish_color_error[1] set_color $fish_color_error[1]
echo "$readme_file wasn't found." echo "$readme_file wasn't found."
end end
else else
open $readme_file open $readme_file
end end
end end
################ ################
# => Environment # => Environment
################ ################
function day -d "Set color palette for bright environment." function day -d "Set color palette for bright environment."
set budspencer_colors $budspencer_day set budspencer_colors $budspencer_day
set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007" set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
end end
function night -d "Set color palette for dark environment." function night -d "Set color palette for dark environment."
set budspencer_colors $budspencer_night set budspencer_colors $budspencer_night
set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007" set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
end end
################# #################
# => Window title # => Window title
################# #################
function wt -d 'Set window title' function wt -d 'Set window title'
set -g window_title $argv set -g window_title $argv
function fish_title function fish_title
echo -n $window_title echo -n $window_title
end end
end end
#################### ####################
# => Welcome message # => Welcome message
#################### ####################
function fish_greeting -d 'Show greeting in login shell.' function fish_greeting -d 'Show greeting in login shell.'
if not set -q budspencer_nogreeting if not set -q budspencer_nogreeting
if begin if begin
not set -q -x LOGIN not set -q -x LOGIN
and not set -q -x RANGER_LEVEL and not set -q -x RANGER_LEVEL
and not set -q -x VIM and not set -q -x VIM
end end
echo This is (set_color -b $budspencer_colors[2] $budspencer_colors[10])budspencer(set_color normal) theme for fish, a theme for the 70s. echo This is (set_color -b $budspencer_colors[2] $budspencer_colors[10])budspencer(set_color normal) theme for fish, a theme for the 70s.
echo Type (set_color -b $budspencer_colors[2] $budspencer_colors[6])»budspencer_help«(set_color normal) in order to see how you can speed up your workflow. echo Type (set_color -b $budspencer_colors[2] $budspencer_colors[6])»budspencer_help«(set_color normal) in order to see how you can speed up your workflow.
end end
end end
end end
This diff is collapsed.
...@@ -27,205 +27,206 @@ ...@@ -27,205 +27,206 @@
# => Toggle functions # => Toggle functions
##################### #####################
function __budspencer_toggle_symbols -d 'Toggles style of symbols, press # in NORMAL or VISUAL mode' function __budspencer_toggle_symbols -d 'Toggles style of symbols, press # in NORMAL or VISUAL mode'
if [ $symbols_style = 'symbols' ] if [ $symbols_style = 'symbols' ]
set symbols_style 'numbers' set symbols_style 'numbers'
else else
set symbols_style 'symbols' set symbols_style 'symbols'
end end
set pwd_hist_lock true set pwd_hist_lock true
commandline -f repaint commandline -f repaint
end end
function __budspencer_toggle_pwd -d 'Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode' function __budspencer_toggle_pwd -d 'Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode'
for i in (seq (count $budspencer_pwdstyle)) for i in (seq (count $budspencer_pwdstyle))
if [ $budspencer_pwdstyle[$i] = $pwd_style ] if [ $budspencer_pwdstyle[$i] = $pwd_style ]
set pwd_style $budspencer_pwdstyle[(expr $i \% (count $budspencer_pwdstyle) + 1)] set pwd_style $budspencer_pwdstyle[(expr $i \% (count $budspencer_pwdstyle) + 1)]
set pwd_hist_lock true set pwd_hist_lock true
commandline -f repaint commandline -f repaint
break break
end end
end end
end end
############################# #############################
# => Command duration segment # => Command duration segment
############################# #############################
function __budspencer_cmd_duration -d 'Displays the elapsed time of last command' function __budspencer_cmd_duration -d 'Displays the elapsed time of last command'
set -l seconds '' set -l seconds ''
set -l minutes '' set -l minutes ''
set -l hours '' set -l hours ''
set -l days '' set -l days ''
set -l cmd_duration (expr $CMD_DURATION / 1000) set -l cmd_duration (expr $CMD_DURATION / 1000)
if [ $cmd_duration -gt 0 ] if [ $cmd_duration -gt 0 ]
set seconds (expr $cmd_duration \% 68400 \% 3600 \% 60)'s' set seconds (expr $cmd_duration \% 68400 \% 3600 \% 60)'s'
if [ $cmd_duration -ge 60 ] if [ $cmd_duration -ge 60 ]
set minutes (expr $cmd_duration \% 68400 \% 3600 / 60)'m' set minutes (expr $cmd_duration \% 68400 \% 3600 / 60)'m'
if [ $cmd_duration -ge 3600 ] if [ $cmd_duration -ge 3600 ]
set hours (expr $cmd_duration \% 68400 / 3600)'h' set hours (expr $cmd_duration \% 68400 / 3600)'h'
if [ $cmd_duration -ge 68400 ] if [ $cmd_duration -ge 68400 ]
set days (expr $cmd_duration / 68400)'d' set days (expr $cmd_duration / 68400)'d'
end end
end end
end end
if [ $last_status -ne 0 ] if [ $last_status -ne 0 ]
echo -n (set_color $budspencer_colors[2])''(set_color -b $budspencer_colors[2] $budspencer_colors[7])' '$days$hours$minutes$seconds 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])' '$days$hours$minutes$seconds 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
################ ################
# => Git segment # => Git segment
################ ################
function __budspencer_is_git_ahead_or_behind -d 'Check if there are unpulled or unpushed commits' function __budspencer_is_git_ahead_or_behind -d 'Check if there are unpulled or unpushed commits'
command git rev-list --count --left-right 'HEAD...@{upstream}' ^ /dev/null | sed 's|\s\+|\n|g' command git rev-list --count --left-right 'HEAD...@{upstream}' ^ /dev/null | sed 's|\s\+|\n|g'
end end
function __budspencer_git_status -d 'Check git status' function __budspencer_git_status -d 'Check git status'
set -l git_status (command git status --porcelain ^/dev/null | cut -c 1-2) set -l git_status (command git status --porcelain ^/dev/null | cut -c 1-2)
set -l added (echo -sn $git_status\n | egrep -c "[ACDMT][ MT]|[ACMT]D") set -l added (echo -sn $git_status\n | egrep -c "[ACDMT][ MT]|[ACMT]D")
set -l deleted (echo -sn $git_status\n | egrep -c "[ ACMRT]D") set -l deleted (echo -sn $git_status\n | egrep -c "[ ACMRT]D")
set -l modified (echo -sn $git_status\n | egrep -c ".[MT]") set -l modified (echo -sn $git_status\n | egrep -c ".[MT]")
set -l renamed (echo -sn $git_status\n | egrep -c "R.") set -l renamed (echo -sn $git_status\n | egrep -c "R.")
set -l unmerged (echo -sn $git_status\n | egrep -c "AA|DD|U.|.U") set -l unmerged (echo -sn $git_status\n | egrep -c "AA|DD|U.|.U")
set -l untracked (echo -sn $git_status\n | egrep -c "\?\?") set -l untracked (echo -sn $git_status\n | egrep -c "\?\?")
echo -n $added\n$deleted\n$modified\n$renamed\n$unmerged\n$untracked echo -n $added\n$deleted\n$modified\n$renamed\n$unmerged\n$untracked
end end
function __budspencer_is_git_stashed -d 'Check if there are stashed commits' function __budspencer_is_git_stashed -d 'Check if there are stashed commits'
command git stash list ^ /dev/null | wc -l command git log --format="%gd" -g $argv 'refs/stash' -- ^ /dev/null | wc -l
end end
function __budspencer_prompt_git_symbols -d 'Displays the git symbols' function __budspencer_prompt_git_symbols -d 'Displays the git symbols'
set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null) set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null)
set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind) if [ -z $is_repo ]
set -l git_status (__budspencer_git_status) return
set -l git_stashed (__budspencer_is_git_stashed) end
set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind)
set -l git_status (__budspencer_git_status)
set -l git_stashed (__budspencer_is_git_stashed)
if begin if [ (expr $git_status[1] + $git_status[2] + $git_status[3] + $git_status[4] + $git_status[5] + $git_status[6] + $git_stashed) -ne 0 ]
[ $is_repo=true ] set_color $budspencer_colors[3]
[ (expr $git_status[1] + $git_status[2] + $git_status[3] + $git_status[4] + $git_status[5] + $git_status[6]) -ne 0 ] echo -n ''
end set_color -b $budspencer_colors[3]
set_color $budspencer_colors[3] if [ $symbols_style = 'symbols' ]
echo -n '' if [ (count $git_ahead_behind) -eq 2 ]
set_color -b $budspencer_colors[3] if [ $git_ahead_behind[1] -gt 0 ]
if [ $symbols_style = 'symbols' ] set_color -o $budspencer_colors[5]
if [ (count $git_ahead_behind) -eq 2 ] echo -n ' ↑'
if [ $git_ahead_behind[1] -gt 0 ] end
set_color -o $budspencer_colors[5] if [ $git_ahead_behind[2] -gt 0 ]
echo -n ' ↑' set_color -o $budspencer_colors[5]
end echo -n ' ↓'
if [ $git_ahead_behind[2] -gt 0 ] end
set_color -o $budspencer_colors[5] end
echo -n ' ↓' if [ $git_status[1] -gt 0 ]
end set_color -o $budspencer_colors[12]
end echo -n ' +'
if [ $git_status[1] -gt 0 ] end
set_color -o $budspencer_colors[12] if [ $git_status[2] -gt 0 ]
echo -n ' +' set_color -o $budspencer_colors[7]
end echo -n ' –'
if [ $git_status[2] -gt 0 ] end
set_color -o $budspencer_colors[7] if [ $git_status[3] -gt 0 ]
echo -n ' –' set_color -o $budspencer_colors[10]
end echo -n ' ✱'
if [ $git_status[3] -gt 0 ] end
set_color -o $budspencer_colors[10] if [ $git_status[4] -gt 0 ]
echo -n ' ✱' set_color -o $budspencer_colors[8]
end echo -n ' →'
if [ $git_status[4] -gt 0 ] end
set_color -o $budspencer_colors[8] if [ $git_status[5] -gt 0 ]
echo -n ' →' set_color -o $budspencer_colors[9]
end echo -n ' ═'
if [ $git_status[5] -gt 0 ] end
set_color -o $budspencer_colors[9] if [ $git_status[6] -gt 0 ]
echo -n ' ═' set_color -o $budspencer_colors[4]
end echo -n ' ●'
if [ $git_status[6] -gt 0 ] end
set_color -o $budspencer_colors[4] if [ $git_stashed -gt 0 ]
echo -n ' ●' set_color -o $budspencer_colors[11]
end echo -n ' ✭'
if [ $git_stashed -gt 0 ] end
set_color -o $budspencer_colors[11] else
echo -n ' ✭' if [ (count $git_ahead_behind) -eq 2 ]
end if [ $git_ahead_behind[1] -gt 0 ]
else set_color $budspencer_colors[5]
if [ (count $git_ahead_behind) -eq 2 ] echo -n ' '$git_ahead_behind[1]
if [ $git_ahead_behind[1] -gt 0 ] end
set_color $budspencer_colors[5] if [ $git_ahead_behind[2] -gt 0 ]
echo -n ' '$git_ahead_behind[1] set_color $budspencer_colors[5]
end echo -n ' '$git_ahead_behind[2]
if [ $git_ahead_behind[2] -gt 0 ] end
set_color $budspencer_colors[5] end
echo -n ' '$git_ahead_behind[2] if [ $git_status[1] -gt 0 ]
end set_color $budspencer_colors[12]
end echo -n ' '$git_status[1]
if [ $git_status[1] -gt 0 ] end
set_color $budspencer_colors[12] if [ $git_status[2] -gt 0 ]
echo -n ' '$git_status[1] set_color $budspencer_colors[7]
end echo -n ' '$git_status[2]
if [ $git_status[2] -gt 0 ] end
set_color $budspencer_colors[7] if [ $git_status[3] -gt 0 ]
echo -n ' '$git_status[2] set_color $budspencer_colors[10]
end echo -n ' '$git_status[3]
if [ $git_status[3] -gt 0 ] end
set_color $budspencer_colors[10] if [ $git_status[4] -gt 0 ]
echo -n ' '$git_status[3] set_color $budspencer_colors[8]
end echo -n ' '$git_status[4]
if [ $git_status[4] -gt 0 ] end
set_color $budspencer_colors[8] if [ $git_status[5] -gt 0 ]
echo -n ' '$git_status[4] set_color $budspencer_colors[9]
end echo -n ' '$git_status[5]
if [ $git_status[5] -gt 0 ] end
set_color $budspencer_colors[9] if [ $git_status[6] -gt 0 ]
echo -n ' '$git_status[5] set_color $budspencer_colors[4]
end echo -n ' '$git_status[6]
if [ $git_status[6] -gt 0 ] end
set_color $budspencer_colors[4] if [ $git_stashed -gt 0 ]
echo -n ' '$git_status[6] set_color $budspencer_colors[11]
end echo -n ' '$git_stashed
if [ $git_stashed -gt 0 ] end
set_color $budspencer_colors[11] end
echo -n ' '$git_stashed set_color -b $budspencer_colors[3] normal
end end
end
set_color -b $budspencer_colors[3] normal
end
end end
################ ################
# => PWD segment # => PWD segment
################ ################
function __budspencer_prompt_pwd -d 'Displays the present working directory' function __budspencer_prompt_pwd -d 'Displays the present working directory'
set -l user_host ' ' set -l user_host ' '
if set -q SSH_CLIENT if set -q SSH_CLIENT
if [ $symbols_style = 'symbols' ] if [ $symbols_style = 'symbols' ]
switch $pwd_style switch $pwd_style
case short case short
set user_host " $USER@"(hostname -s)':' set user_host " $USER@"(hostname -s)':'
case long case long
set user_host " $USER@"(hostname -f)':' set user_host " $USER@"(hostname -f)':'
end end
else else
set user_host " $USER@"(hostname -i)':' set user_host " $USER@"(hostname -i)':'
end end
end end
set_color $budspencer_current_bindmode_color set_color $budspencer_current_bindmode_color
echo -n '' echo -n ''
set_color normal set_color normal
set_color -b $budspencer_current_bindmode_color $budspencer_colors[1] set_color -b $budspencer_current_bindmode_color $budspencer_colors[1]
if [ (count $budspencer_prompt_error) != 1 ] if [ (count $budspencer_prompt_error) != 1 ]
switch $pwd_style switch $pwd_style
case short case short
echo -n $user_host(prompt_pwd)' ' echo -n $user_host(prompt_pwd)' '
case long case long
echo -n $user_host$PWD' ' echo -n $user_host(pwd)' '
end end
else else
echo -n " $budspencer_prompt_error " echo -n " $budspencer_prompt_error "
set -e budspencer_prompt_error[1] set -e budspencer_prompt_error[1]
end end
set_color normal set_color normal
end end
############################################################################### ###############################################################################
...@@ -233,6 +234,6 @@ end ...@@ -233,6 +234,6 @@ end
############################################################################### ###############################################################################
function fish_right_prompt -d 'Write out the right prompt of the budspencer theme' function fish_right_prompt -d 'Write out the right prompt of the budspencer theme'
echo -n (__budspencer_cmd_duration) (__budspencer_prompt_git_symbols) (__budspencer_prompt_pwd) echo -n (__budspencer_cmd_duration) (__budspencer_prompt_git_symbols) (__budspencer_prompt_pwd)
set_color normal set_color normal
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