giti: adaption for kali_prompt

This commit is contained in:
Dirk Alders 2023-06-17 14:26:03 +00:00
parent 2ee1207ad3
commit 993cf955fb

44
giti
View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
usage="Usage: $0 [-n | no details] [-r | repeat]" usage="Usage: $0 [-n | no details] [-r | repeat]"
while getopts "hnrs" options; do while getopts "hnrs" options; do
case $options in case $options in
n ) NO_DETAILS="True";; n ) NO_DETAILS="True";;
@ -58,36 +58,40 @@ else
git_url="$(git config --get remote.origin.url 2> /dev/null)" git_url="$(git config --get remote.origin.url 2> /dev/null)"
if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
git_status_color="$COLOR_RED" git_status_color="$COLOR_RED"
git_status_text="local changes" git_status_text="local changes"
elif [[ $git_status =~ "Your branch is behind" ]]; then elif [[ $git_status =~ "Your branch is behind" ]]; then
git_status_color="$COLOR_YELLOW" git_status_color="$COLOR_YELLOW"
git_status_text="pull required" git_status_text="pull required"
elif [[ $git_status =~ "Your branch is ahead of" ]]; then elif [[ $git_status =~ "Your branch is ahead of" ]]; then
git_status_color="$COLOR_YELLOW" git_status_color="$COLOR_YELLOW"
git_status_text="push required" git_status_text="push required"
elif [[ $git_status =~ "nothing to commit" ]]; then elif [[ $git_status =~ "nothing to commit" ]]; then
git_status_color="$COLOR_DARKGREEN" git_status_color="$COLOR_DARKGREEN"
git_status_text="╡ clean ╞════════" git_status_text="clea "
else else
git_status_color="$COLOR_OCHRE" git_status_color="$COLOR_OCHRE"
git_status_text="╡ unknown ╞══════" git_status_text="unknown "
fi fi
fi fi
echo -e "$git_status_color╔═══$git_status_text════════════════════════════════════════════════════════════════" if [[ $NO_DETAILS ]]; then
echo -e "$git_status_color║ $COLOR_GREEN($git_branch) $COLOR_CYAN$git_url" echo -e "$git_status_color╠══$COLOR_GREEN($git_branch)$git_status_color - $git_status_text - $COLOR_CYAN$git_url$COLOR_WHITE\n\b"
else
echo -e "$git_status_color╔═══╡ $git_status_text ╞════════════════════════════════════════════════════════════════"
echo -e "$git_status_color║ $COLOR_GREEN($git_branch) $COLOR_CYAN$git_url"
if [[ ! $git_diff == "" && $NO_DETAILS != "True" ]]; then if [[ ! $git_diff == "" ]]; then
echo -e "$git_status_color╠════════════════════════════════════════════════════════════════════════════════════" echo -e "$git_status_color╠════════════════════════════════════════════════════════════════════════════════════"
IFS=$'\n' IFS=$'\n'
for ENTRY in $git_diff; do for ENTRY in $git_diff; do
if [[ $ENTRY = "D "* ]] || [[ $ENTRY = "A "* ]] || [[ $ENTRY = "M "* ]] || [[ $ENTRY = "R "* ]]; then if [[ $ENTRY = "D "* ]] || [[ $ENTRY = "A "* ]] || [[ $ENTRY = "M "* ]] || [[ $ENTRY = "R "* ]]; then
echo -e "$git_status_color║ $COLOR_DARKYELLOW$ENTRY" echo -e "$git_status_color║ $COLOR_DARKYELLOW$ENTRY"
else else
echo -e "$git_status_color║ $COLOR_YELLOW$ENTRY" echo -e "$git_status_color║ $COLOR_YELLOW$ENTRY"
fi fi
done done
fi fi
echo -e "$git_status_color╚════════════════════════════════════════════════════════════════════════════════════$COLOR_WHITE\n \b" echo -e "$git_status_color╚════════════════════════════════════════════════════════════════════════════════════$COLOR_WHITE\n \b"
fi fi
fi
fi fi