2015-06-24 06:58:56 +08:00
|
|
|
|
# name: Sorin
|
|
|
|
|
# author: Ivan Tham <ivanthamjunhoe@gmail.com>
|
2015-06-15 18:16:17 +08:00
|
|
|
|
|
|
|
|
|
function fish_prompt
|
2016-11-02 10:19:45 +08:00
|
|
|
|
test $SSH_TTY
|
|
|
|
|
and printf (set_color red)$USER(set_color brwhite)'@'(set_color yellow)(prompt_hostname)' '
|
|
|
|
|
test $USER = 'root'
|
|
|
|
|
and echo (set_color red)"#"
|
2015-06-15 18:16:17 +08:00
|
|
|
|
|
|
|
|
|
# Main
|
2016-11-02 10:19:45 +08:00
|
|
|
|
echo -n (set_color cyan)(prompt_pwd) (set_color red)'❯'(set_color yellow)'❯'(set_color green)'❯ '
|
2015-06-15 18:16:17 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function fish_right_prompt
|
|
|
|
|
# last status
|
2016-11-02 10:19:45 +08:00
|
|
|
|
test $status != 0
|
|
|
|
|
and printf (set_color red)"⏎ "
|
2015-06-15 18:16:17 +08:00
|
|
|
|
|
2016-11-02 10:19:45 +08:00
|
|
|
|
if git rev-parse ^/dev/null
|
2016-11-01 14:29:50 +08:00
|
|
|
|
# Magenta if branch detached else green
|
|
|
|
|
git branch -qv | grep "\*" | string match -rq detached
|
2016-11-02 10:19:45 +08:00
|
|
|
|
and set_color brmagenta
|
|
|
|
|
or set_color brgreen
|
2015-06-15 18:16:17 +08:00
|
|
|
|
|
|
|
|
|
# Need optimization on this block (eliminate space)
|
|
|
|
|
git name-rev --name-only HEAD
|
|
|
|
|
|
|
|
|
|
# Merging state
|
2016-11-02 10:19:45 +08:00
|
|
|
|
git merge -q ^/dev/null
|
|
|
|
|
or printf ':'(set_color red)'merge'
|
2015-06-15 18:16:17 +08:00
|
|
|
|
printf ' '
|
|
|
|
|
|
|
|
|
|
# Symbols
|
2016-11-02 10:19:45 +08:00
|
|
|
|
for i in (git branch -qv --no-color|grep \*|cut -d' ' -f4-|cut -d] -f1|tr , \n)\
|
|
|
|
|
(git status --porcelain | cut -c 1-2 | uniq)
|
|
|
|
|
switch $i
|
2015-06-15 18:16:17 +08:00
|
|
|
|
case "*[ahead *"
|
2016-11-01 14:29:50 +08:00
|
|
|
|
printf (set_color magenta)⬆' '
|
2015-06-15 18:16:17 +08:00
|
|
|
|
case "*behind *"
|
2016-11-01 14:29:50 +08:00
|
|
|
|
printf (set_color magenta)⬇' '
|
2016-11-02 10:19:45 +08:00
|
|
|
|
case "."
|
|
|
|
|
printf (set_color green)✚' '
|
|
|
|
|
case " D"
|
|
|
|
|
printf (set_color red)✖' '
|
|
|
|
|
case "*M*"
|
|
|
|
|
printf (set_color blue)✱' '
|
2015-06-15 18:16:17 +08:00
|
|
|
|
case "*R*"
|
2016-11-01 14:29:50 +08:00
|
|
|
|
printf (set_color brmagenta)➜' '
|
2015-06-15 18:16:17 +08:00
|
|
|
|
case "*U*"
|
2016-11-01 14:29:50 +08:00
|
|
|
|
printf (set_color bryellow)═' '
|
2016-11-02 10:19:45 +08:00
|
|
|
|
case "??"
|
|
|
|
|
printf (set_color brwhite)◼' '
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2015-06-15 18:16:17 +08:00
|
|
|
|
end
|