···11+function __fish_prompt_git
22+ set -g __git_branch_name (command git symbolic-ref --short -q HEAD ^/dev/null)
33+44+ if not set -q -g __git_functions_defined
55+ set -g __git_functions_defined
66+77+ function _git_dirty
88+ echo (command git status -s --ignore-submodules=dirty)
99+ end
1010+1111+ function _git_ahead
1212+ echo (command git log --format=oneline origin/$__git_branch_name..$__git_branch_name ^/dev/null)
1313+ end
1414+1515+ function _git_behind
1616+ echo (command git log --format=oneline $__git_branch_name..origin/$__git_branch_name ^/dev/null)
1717+ end
1818+ end
1919+2020+ set -l cyan (set_color -o cyan)
2121+ set -l yellow (set_color -o yellow)
2222+ set -l purple (set_color -o purple)
2323+ set -l blue (set_color -o blue)
2424+ set -l normal (set_color normal)
2525+2626+ set -l cwd $cyan(prompt_pwd)
2727+2828+ if [ $__git_branch_name ]
2929+ set -l git_branch $purple$__git_branch_name
3030+ set git_info "$blue $git_branch"
3131+3232+ if [ (_git_dirty) ]
3333+ set -l dirty $yellow!
3434+ set git_info $git_info$dirty
3535+ end
3636+3737+ if [ (_git_ahead) ]
3838+ set -l ahead $blue↑
3939+ set git_info $git_info$ahead
4040+ end
4141+4242+ if [ (_git_behind) ]
4343+ set -l behind $blue↓
4444+ set git_info $git_info$behind
4545+ end
4646+ end
4747+4848+ echo $git_info
4949+end
···11+function __fish_prompt_timing
22+ if test "$CMD_DURATION" -gt '100'
33+ set_color $fish_color_error
44+55+ if test "$CMD_DURATION" -lt '60000'
66+ printf '%.1fs ' (awk "BEGIN { print $CMD_DURATION / 1000 }")
77+ else if test "$CMD_DURATION" -lt '3600000'
88+ printf '%.1fm ' (awk "BEGIN { print $CMD_DURATION / 60000 }")
99+ else
1010+ printf '%.1fh ' (awk "BEGIN { print $CMD_DURATION / 3600000 }")
1111+ end
1212+1313+ set_color normal
1414+ end
1515+end
+14-40
config/fish/functions/fish_prompt.fish
···11function fish_prompt
22- set -g __git_branch_name (command git symbolic-ref --short -q HEAD ^/dev/null)
22+ set -l last_status $status
3344- if not set -q -g __git_functions_defined
55- set -g __git_functions_defined
44+ # Command timing
55+ echo -n -s (__fish_prompt_timing)
6677- function _git_dirty
88- echo (command git status -s --ignore-submodules=dirty)
99- end
77+ # PWD
88+ set_color cyan
99+ echo -n (__fish_prompt_pwd)
1010+ set_color normal
10111111- function _git_ahead
1212- echo (command git log --format=oneline origin/$__git_branch_name..$__git_branch_name ^/dev/null)
1313- end
1212+ # Git
1313+ printf '%s ' (__fish_prompt_git ' %s')
1414+ set_color normal
14151515- function _git_behind
1616- echo (command git log --format=oneline $__git_branch_name..origin/$__git_branch_name ^/dev/null)
1717- end
1616+ if not test $last_status -eq 0
1717+ set_color $fish_color_error
1818 end
19192020- set -l cyan (set_color -o cyan)
2121- set -l yellow (set_color -o yellow)
2222- set -l purple (set_color -o purple)
2323- set -l blue (set_color -o blue)
2424- set -l normal (set_color normal)
2525-2626- set -l cwd $cyan(prompt_pwd)
2727-2828- if [ $__git_branch_name ]
2929- set -l git_branch $purple$__git_branch_name
3030- set git_info "$blue $git_branch"
2020+ echo -n -s '% '
31213232- if [ (_git_dirty) ]
3333- set -l dirty $yellow!
3434- set git_info $git_info$dirty
3535- end
3636-3737- if [ (_git_ahead) ]
3838- set -l ahead $blue↑
3939- set git_info $git_info$ahead
4040- end
4141-4242- if [ (_git_behind) ]
4343- set -l behind $blue↓
4444- set git_info $git_info$behind
4545- end
4646- end
4747-4848- echo -n -s $cwd $git_info $normal ' % '
2222+ set_color normal
4923end
-3
config/fish/functions/prompt_pwd.fish
···11-function prompt_pwd --description 'Print the current working directory, shortend to fit the prompt'
22- echo $PWD | sed -e "s|^$DEVELOPER|~Developer|" -e "s|^$HOME/*|~|" -e 's-.*/\([^/]*/[^/]*\)-\1-'
33-end