2014-06-01 14:56:37 +08:00
|
|
|
function fish_prompt
|
2014-06-02 01:38:28 +08:00
|
|
|
# Cache exit status
|
2014-06-01 14:56:37 +08:00
|
|
|
set -l last_status $status
|
2014-06-02 01:38:28 +08:00
|
|
|
|
|
|
|
# Setup colors
|
2014-06-01 14:56:37 +08:00
|
|
|
set -l normal (set_color normal)
|
|
|
|
set -l red (set_color red)
|
|
|
|
set -l cyan (set_color cyan)
|
|
|
|
set -l white (set_color white)
|
|
|
|
set -l gray (set_color -o cyan)
|
|
|
|
set -l brwhite (set_color -o white)
|
|
|
|
|
2014-06-02 01:38:28 +08:00
|
|
|
# Configure __fish_git_prompt
|
|
|
|
set -g __fish_git_prompt_showdirtystate true
|
|
|
|
set -g __fish_git_prompt_showuntrackedfiles true
|
|
|
|
set -g __fish_git_prompt_showstashstate true
|
|
|
|
set -g __fish_git_prompt_color green
|
|
|
|
set -g __fish_git_prompt_color_flags red
|
|
|
|
|
|
|
|
# Color prompt char red for non-zero exit status
|
|
|
|
set -l pcolor $gray
|
|
|
|
if test $last_status -ne 0
|
|
|
|
set pcolor $red
|
2014-06-01 14:56:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Traditional prompt chars
|
|
|
|
set -l pchar '$'
|
|
|
|
if test (id -u) = '0'
|
|
|
|
set pchar = '#'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Line 1
|
|
|
|
echo -n $red'┌'$cyan$USER$white'@'$cyan(hostname -s)' '$gray(prompt_pwd)$normal
|
2014-06-02 01:38:28 +08:00
|
|
|
__fish_git_prompt
|
|
|
|
# Check for gwip; does last commit log contain --wip--?
|
|
|
|
if begin git log -n 1 ^/dev/null | grep -qc "\-\-wip\-\-"; end
|
|
|
|
echo -n $brwhite' WIP!'$normal
|
2014-06-01 14:56:37 +08:00
|
|
|
end
|
|
|
|
echo
|
|
|
|
|
|
|
|
# Line 2
|
|
|
|
echo -n $red'└'$pcolor$pchar' '$normal
|
|
|
|
end
|