2015-06-23 22:58:56 +00:00
|
|
|
|
# name: Sorin
|
|
|
|
|
# author: Ivan Tham <ivanthamjunhoe@gmail.com>
|
2015-06-15 10:16:17 +00:00
|
|
|
|
|
|
|
|
|
function fish_prompt
|
2016-11-02 02:19:45 +00:00
|
|
|
|
test $SSH_TTY
|
|
|
|
|
and printf (set_color red)$USER(set_color brwhite)'@'(set_color yellow)(prompt_hostname)' '
|
2017-07-20 17:45:32 +00:00
|
|
|
|
test "$USER" = 'root'
|
2016-11-02 02:19:45 +00:00
|
|
|
|
and echo (set_color red)"#"
|
2015-06-15 10:16:17 +00:00
|
|
|
|
|
|
|
|
|
# Main
|
2016-11-02 02:19:45 +00:00
|
|
|
|
echo -n (set_color cyan)(prompt_pwd) (set_color red)'❯'(set_color yellow)'❯'(set_color green)'❯ '
|
2015-06-15 10:16:17 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function fish_right_prompt
|
|
|
|
|
# last status
|
2016-11-02 02:19:45 +00:00
|
|
|
|
test $status != 0
|
|
|
|
|
and printf (set_color red)"⏎ "
|
2015-06-15 10:16:17 +00:00
|
|
|
|
|
2018-12-06 15:15:11 +00:00
|
|
|
|
if set -l git_dir (git rev-parse --git-dir 2>/dev/null)
|
2016-11-01 06:29:50 +00:00
|
|
|
|
# Magenta if branch detached else green
|
2018-11-29 16:37:06 +00:00
|
|
|
|
set -l branch (command git branch -qv | string match "\**")
|
|
|
|
|
string match -rq detached -- $branch
|
2016-11-02 02:19:45 +00:00
|
|
|
|
and set_color brmagenta
|
|
|
|
|
or set_color brgreen
|
2015-06-15 10:16:17 +00:00
|
|
|
|
|
|
|
|
|
git name-rev --name-only HEAD
|
|
|
|
|
|
2018-12-06 15:15:11 +00:00
|
|
|
|
# Merging state
|
|
|
|
|
test -f "$git_dir/MERGE_HEAD"
|
|
|
|
|
and printf ':'(set_color red)'merge'
|
|
|
|
|
printf ' '
|
|
|
|
|
|
2015-06-15 10:16:17 +00:00
|
|
|
|
# Symbols
|
2018-11-29 16:37:06 +00:00
|
|
|
|
if set -l count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
|
|
|
|
|
echo $count | read -l ahead behind
|
|
|
|
|
if test "$ahead" -gt 0
|
|
|
|
|
printf (set_color magenta)⬆' '
|
|
|
|
|
end
|
|
|
|
|
if test "$behind" -gt 0
|
|
|
|
|
printf (set_color magenta)⬇' '
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i in (git status --porcelain | string sub -l 2 | uniq)
|
2016-11-02 02:19:45 +00:00
|
|
|
|
switch $i
|
|
|
|
|
case "."
|
|
|
|
|
printf (set_color green)✚' '
|
|
|
|
|
case " D"
|
|
|
|
|
printf (set_color red)✖' '
|
|
|
|
|
case "*M*"
|
|
|
|
|
printf (set_color blue)✱' '
|
2015-06-15 10:16:17 +00:00
|
|
|
|
case "*R*"
|
2016-11-01 06:29:50 +00:00
|
|
|
|
printf (set_color brmagenta)➜' '
|
2015-06-15 10:16:17 +00:00
|
|
|
|
case "*U*"
|
2016-11-01 06:29:50 +00:00
|
|
|
|
printf (set_color bryellow)═' '
|
2016-11-02 02:19:45 +00:00
|
|
|
|
case "??"
|
|
|
|
|
printf (set_color brwhite)◼' '
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2015-06-15 10:16:17 +00:00
|
|
|
|
end
|