a couple nice git things in the right_prompt

weechat-localhost
Ben Harris 2018-09-20 15:13:23 -04:00
parent 3b4c981ccc
commit 48c60eb6d4
5 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,20 @@
function fish_right_prompt
if is_git
if is_git_dirty
set_color --underline
end
set_color yellow
if is_git_ahead
echo -n '^'
else
echo -n '='
end
echo -n ' '
echo -n (git_branch)
set_color normal
end
end

View File

@ -0,0 +1,5 @@
function git_branch
if is_git
echo (git rev-parse --abbrev-ref HEAD ^/dev/null)
end
end

View File

@ -0,0 +1,3 @@
function is_git
git symbolic-ref HEAD > /dev/null ^&1
end

View File

@ -0,0 +1,4 @@
function is_git_ahead
set -l revs (git rev-list origin/(git_branch)..HEAD ^/dev/null)
[ "$revs" != "" ]
end

View File

@ -0,0 +1,3 @@
function is_git_dirty
is_git; and [ (git status | tail -n1) != "nothing to commit, working tree clean" ]
end