Add counter for removed files to bash git prompt

This commit is contained in:
Talia 2018-11-19 21:30:40 +01:00
parent 90dfa6fc12
commit e5e62e6044

6
bashrc
View file

@ -1,4 +1,3 @@
alias hello='echo "Hello :)"' alias hello='echo "Hello :)"'
alias rmd='rm --recursive' alias rmd='rm --recursive'
alias temp='watch -t -d -n 1 sensors -A coretemp-isa-0000' alias temp='watch -t -d -n 1 sensors -A coretemp-isa-0000'
@ -40,6 +39,7 @@ git__prompt () {
modif=`git status --short 2>/dev/null | grep -Po '^\s*M' | wc -l` modif=`git status --short 2>/dev/null | grep -Po '^\s*M' | wc -l`
untracked=`git status --short 2>/dev/null | grep -Po '^\?\?' | wc -l` untracked=`git status --short 2>/dev/null | grep -Po '^\?\?' | wc -l`
added=`git status --short 2>/dev/null | grep -Po '^\s*A' | wc -l` added=`git status --short 2>/dev/null | grep -Po '^\s*A' | wc -l`
deleted=`git status --short 2>/dev/null | grep -Po '^\s*D' | wc -l`
stat=`git branch -vv | grep -P '^\*' | grep -Po '\[.*\]'` stat=`git branch -vv | grep -P '^\*' | grep -Po '\[.*\]'`
ahead=`echo $stat | grep -Po '(?<=ahead )\d*'` ahead=`echo $stat | grep -Po '(?<=ahead )\d*'`
behind=`echo $stat | grep -Po '(?<=behind )\d*'` behind=`echo $stat | grep -Po '(?<=behind )\d*'`
@ -70,6 +70,10 @@ git__prompt () {
then then
echo -ne "${green}+$added" echo -ne "${green}+$added"
fi fi
if [ $deleted -ne 0 ]
then
echo -ne "${red}-$deleted"
fi
if [ $untracked -ne 0 ] if [ $untracked -ne 0 ]
then then
echo -ne "${red}*" echo -ne "${red}*"