summaryrefslogtreecommitdiff
path: root/bash-git-prompt.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-05-04 10:47:48 +0200
committerErich Eckner <git@eckner.net>2016-05-04 10:47:48 +0200
commit608ae3752a8719cb43120c9baf706d17b124d9ae (patch)
tree14d8b2125ab6309eb640aab7f71add209c88aa1e /bash-git-prompt.in
parentba496fe97a56cefb5d0129215c902995e9862dd5 (diff)
downloadbash-git-prompt-608ae3752a8719cb43120c9baf706d17b124d9ae.tar.xz
Makefile neu, Versionsupdatev0.9
Diffstat (limited to 'bash-git-prompt.in')
-rwxr-xr-xbash-git-prompt.in66
1 files changed, 66 insertions, 0 deletions
diff --git a/bash-git-prompt.in b/bash-git-prompt.in
new file mode 100755
index 0000000..a8ef63b
--- /dev/null
+++ b/bash-git-prompt.in
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# bash-git-prompt version #VERSION#
+
+[[ "$TERM" = *color ]] && mitFarbe=true || mitFarbe=false
+
+[ -z "$PS1Start" ] && [ -z "$PS1Ende" ] &&
+ if echo "$PS1" | grep -q "\S"
+ then
+ PS1Ende="$(echo "$PS1" | sed 's|^.*[^\]\(\\\?[$#>]\s*\([]\\[0-9m]\)*\s*\)$|\1|')"
+ PS1Start="$(echo "$PS1" | sed 's|\\\?[$#>]\s*\([]\\[0-9m]\)*\s*$||')"
+ else
+ PS1Ende=""
+ PS1Start="$PS1"
+ fi
+
+PS1="$PS1Start"
+
+if status=$(git status --porcelain 2> /dev/null)
+then
+ PS1="$PS1 "
+ branch="$(git symbolic-ref HEAD 2> /dev/null | sed "s|^.*/||")"
+ echo "$status" | grep -q "^.\S" && wtClean=false || wtClean=true
+ echo "$status" | grep -q "^\S" && idxClean=false || idxClean=true
+
+ [ $(git show-ref HEAD "${branch}" --head -s | \
+ uniq | \
+ wc -l
+ ) -eq 1 ] && \
+ remClean=true || \
+ remClean=false
+
+ if $mitFarbe
+ then
+ if ! $wtClean
+ then
+ PS1="$PS1\[\033[01;31m\]"
+ elif ! $idxClean
+ then
+ PS1="$PS1\[\033[01;33m\]"
+ elif ! $remClean
+ then
+ PS1="$PS1\[\033[01;34m\]"
+ else
+ PS1="$PS1\[\033[01;32m\]"
+ fi
+ fi
+ PS1="$PS1$branch"
+ if $mitFarbe
+ then
+ PS1="$PS1\[\033[00m\]"
+ else
+ if ! $wtClean
+ then
+ PS1="$PS1!"
+ elif ! $idxClean
+ then
+ PS1="$PS1+"
+ elif ! $remClean
+ then
+ PS1="$PS1^"
+ fi
+ fi
+fi
+
+PS1="$PS1$PS1Ende"