shell: add git agead/behind to PS1
This commit is contained in:
parent
40dcc1b24d
commit
3afa33f28e
@ -13,8 +13,22 @@ parse_git_branch() {
|
||||
local b=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
|
||||
if [ "$b" != "" ]
|
||||
then
|
||||
local behind=$(git rev-list HEAD...@{u} --ignore-submodules --count 2>/dev/null)
|
||||
local ahead=$(git rev-list @{u}...HEAD --ignore-submodules --count 2>/dev/null)
|
||||
git diff --cached --exit-code &> /dev/null || b="${b}+"
|
||||
git diff --exit-code &> /dev/null || b="${b}*"
|
||||
if [[ "$behind" > 0 || "$ahead" > 0 ]]
|
||||
then
|
||||
b="$b ☁ "
|
||||
if [[ "$ahead" > 0 ]]
|
||||
then
|
||||
b="$b+$ahead"
|
||||
fi
|
||||
if [[ "$behind" > 0 ]]
|
||||
then
|
||||
b="$b-$behind"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo -n "$b"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user