short repos status added to giti

This commit is contained in:
Dirk Alders 2022-05-08 14:43:32 +02:00
parent 22aa8ab62a
commit fcfcf72c41

55
giti
View File

@ -5,6 +5,7 @@ while getopts "hnrs" options; do
case $options in
n ) NO_DETAILS="True";;
r ) REPEAT="True";;
s ) SHORT="True";;
h ) echo $usage
exit 0
;;
@ -29,24 +30,44 @@ else
git_status="$(LANGUAGE='en_US.UTF-8 git' git status 2> /dev/null)"
git_diff="$(git status --porcelain 2> /dev/null)"
#
if [[ ! $git_status = "" ]]; then
git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')"
git_url="$(git config --get remote.origin.url 2> /dev/null)"
if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
git_status_color="$COLOR_RED"
git_status_text="╡ local changes ╞"
elif [[ $git_status =~ "Your branch is behind" ]]; then
git_status_color="$COLOR_YELLOW"
git_status_text="╡ pull required ╞"
elif [[ $git_status =~ "Your branch is ahead of" ]]; then
git_status_color="$COLOR_YELLOW"
git_status_text="╡ push required ╞"
elif [[ $git_status =~ "nothing to commit" ]]; then
git_status_color="$COLOR_DARKGREEN"
git_status_text="╡ clean ╞════════"
if [[ $SHORT ]]; then
if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
git_status_color="$COLOR_RED"
git_status_text="local changes"
elif [[ $git_status =~ "Your branch is behind" ]]; then
git_status_color="$COLOR_YELLOW"
git_status_text="pull required"
elif [[ $git_status =~ "Your branch is ahead of" ]]; then
git_status_color="$COLOR_YELLOW"
git_status_text="push required"
elif [[ $git_status =~ "nothing to commit" ]]; then
git_status_color="$COLOR_DARKGREEN"
git_status_text="clean "
else
git_status_color="$COLOR_OCHRE"
git_status_text="unknown "
fi
echo -ne "$git_status_color$git_status_text$COLOR_WHITE"
else
git_status_color="$COLOR_OCHRE"
git_status_text="╡ unknown ╞══════"
if [[ ! $git_status = "" ]]; then
git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')"
git_url="$(git config --get remote.origin.url 2> /dev/null)"
if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
git_status_color="$COLOR_RED"
git_status_text="╡ local changes ╞"
elif [[ $git_status =~ "Your branch is behind" ]]; then
git_status_color="$COLOR_YELLOW"
git_status_text="╡ pull required ╞"
elif [[ $git_status =~ "Your branch is ahead of" ]]; then
git_status_color="$COLOR_YELLOW"
git_status_text="╡ push required ╞"
elif [[ $git_status =~ "nothing to commit" ]]; then
git_status_color="$COLOR_DARKGREEN"
git_status_text="╡ clean ╞════════"
else
git_status_color="$COLOR_OCHRE"
git_status_text="╡ unknown ╞══════"
fi
fi
echo -e "$git_status_color╔═══$git_status_text════════════════════════════════════════════════════════════════"