Compare commits

..

No commits in common. "84582af9689a963b19ddd30f88be65c50f7a74ce" and "bb3fb18730e1579db828f574d85e0d6ca18d8039" have entirely different histories.

2 changed files with 87 additions and 94 deletions

View File

@ -6,4 +6,3 @@ git config --global user.email dirk@mount-mockery.de
git config --global diff.tool meld git config --global diff.tool meld
git config --global merge.tool meld git config --global merge.tool meld
git config --global --add difftool.prompt false git config --global --add difftool.prompt false
git config --global pull.rebase false

86
giti
View File

@ -1,13 +1,11 @@
#!/bin/bash #!/bin/bash
# #
usage="Usage: $0 [-n | no details] [-r | repeat]"
# while getopts "hnrs" options; do
# command line arguments
#
usage="Usage: $0 [-p | output for prompt]"
while getopts "hp" options; do
case $options in case $options in
p ) PROMPT="True";; n ) NO_DETAILS="True";;
r ) REPEAT="True";;
s ) SHORT="True";;
h ) echo $usage h ) echo $usage
exit 0 exit 0
;; ;;
@ -17,9 +15,9 @@ while getopts "hp" options; do
esac esac
done done
# if [[ $REPEAT == "True" ]]; then
# color definitions watch -n 1 -c "clear && $0 -s"
# else
COLOR_WHITE="\033[00m" COLOR_WHITE="\033[00m"
COLOR_CYAN="\033[1;36m" COLOR_CYAN="\033[1;36m"
COLOR_RED="\033[1;31m" COLOR_RED="\033[1;31m"
@ -28,25 +26,34 @@ COLOR_DARKYELLOW="\033[0;33m"
COLOR_GREEN="\033[1;32m" COLOR_GREEN="\033[1;32m"
COLOR_DARKGREEN="\033[0;32m" COLOR_DARKGREEN="\033[0;32m"
COLOR_OCHRE="\033[38;5;95m" COLOR_OCHRE="\033[38;5;95m"
#
# git information storage
# #
git_status="$(LANGUAGE='en_US.UTF-8 git' git status 2> /dev/null)" git_status="$(LANGUAGE='en_US.UTF-8 git' git status 2> /dev/null)"
git_diff="$(git status --porcelain 2> /dev/null)" git_diff="$(git status --porcelain 2> /dev/null)"
#
# decision for git output (path is repository)
# #
if [ -z "$git_status" ]; then if [ -z "$git_status" ]; then
# No GIT repository # No GIT repository
exit exit
fi fi
if [[ $SHORT ]]; then
# if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
# git preparations 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
if [[ ! $git_status = "" ]]; then
git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')" git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')"
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
@ -65,45 +72,32 @@ else
git_status_color="$COLOR_OCHRE" git_status_color="$COLOR_OCHRE"
git_status_text="unknown " git_status_text="unknown "
fi fi
fi
if [[ $NO_DETAILS ]]; then
# # echo -e "$git_status_color╠══$COLOR_GREEN($git_branch)$git_status_color - $git_status_text - $COLOR_CYAN$git_url$COLOR_WHITE\n\b"
# Start of console output echo -e "$git_status_color├──$COLOR_GREEN($git_branch)$git_status_color - $git_status_text - $COLOR_CYAN$git_url$COLOR_WHITE\n\b"
#
## STATUS AND INFO ######
if [[ $PROMPT ]]; then
# print status
echo -e "$git_status_color├──$COLOR_GREEN($git_branch)$git_status_color - $git_status_text - $COLOR_CYAN$git_url$COLOR_WHITE"
else else
# print status and # echo -e "$git_status_color╔═══╡ $git_status_text ╞════════════════════════════════════════════════════════════════"
echo -e "$git_status_color┌───┤ $git_status_text ├────────────────────────────────────────────────────────────────" echo -e "$git_status_color┌───┤ $git_status_text ├────────────────────────────────────────────────────────────────"
# echo -e "$git_status_color║ $COLOR_GREEN($git_branch) $COLOR_CYAN$git_url"
echo -e "$git_status_color│ $COLOR_GREEN($git_branch) $COLOR_CYAN$git_url" echo -e "$git_status_color│ $COLOR_GREEN($git_branch) $COLOR_CYAN$git_url"
if [[ ! $git_diff == "" ]]; then if [[ ! $git_diff == "" ]]; then
# echo -e "$git_status_color╠════════════════════════════════════════════════════════════════════════════════════"
echo -e "$git_status_color├────────────────────────────────────────────────────────────────────────────────────" echo -e "$git_status_color├────────────────────────────────────────────────────────────────────────────────────"
else
echo -e "$git_status_color└────────────────────────────────────────────────────────────────────────────────────$COLOR_WHITE\n \b"
fi
fi
## FILE INFO ############
if [[ ! $git_diff == "" ]]; then
if [[ ! $PROMPT || "$GIT_PROMPT_DETAILS" == "on" ]]; then
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" 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" echo -e "$git_status_color│ $COLOR_YELLOW$ENTRY"
fi fi
done done
fi fi
fi # echo -e "$git_status_color╚════════════════════════════════════════════════════════════════════════════════════$COLOR_WHITE\n \b"
## CLOSING ##############
if [[ $PROMPT ]]; then
echo -e " \b"
else
echo -e "$git_status_color└────────────────────────────────────────────────────────────────────────────────────$COLOR_WHITE\n \b" echo -e "$git_status_color└────────────────────────────────────────────────────────────────────────────────────$COLOR_WHITE\n \b"
fi fi
fi
fi