diff options
author | Alexander Blinne <alexander.blinne@uni-jena.de> | 2016-04-11 22:09:51 +0200 |
---|---|---|
committer | Alexander Blinne <alexander.blinne@uni-jena.de> | 2016-04-11 22:09:51 +0200 |
commit | 7872f2cb67c6b4fe5d3ed841891b8371b13649b5 (patch) | |
tree | d074e267ea6e340d46b9c3bf757276f9ddb23c99 | |
parent | ca1e617eddb6225166b0e626e187a14c7cbd2ae0 (diff) | |
download | bash-git-prompt-7872f2cb67c6b4fe5d3ed841891b8371b13649b5.tar.xz |
sollte jetzt flexibel genug seinv0.1
-rw-r--r-- | bash-git-prompt | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/bash-git-prompt b/bash-git-prompt index 4a510ba..1397a50 100644 --- a/bash-git-prompt +++ b/bash-git-prompt @@ -1,21 +1,50 @@ #!/bin/bash -PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}<\t> \[\033[01;32m\]\u\[\033[00m\]@\[\033[01;33m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]' - set -o pipefail +[[ "$TERM" = *-color ]] && mitFarbe=true || mitFarbe=false + +[ -z "$PS1save" ] && PS1save="$PS1" + +if echo "$PS1save" | grep -q "\S" +then + PS1Ende="$(echo "$PS1save" | sed "s|^.*[^\\]\(\\\\\?\S\s*\)\$|\1|")" + PS1="$(echo "$PS1save" | sed "s|\\\\\?\S\s*\$||")" +else + PS1Ende="" + PS1="$PS1save" +fi + if branch=$(git branch 2>/dev/null | grep '\*' | cut -d' ' -f2) then - if git status --porcelain | grep -q "^.\S" + PS1="$PS1 " + git status --porcelain | grep -q "^.\S" && wtClean=false || wtClean=true + git status --porcelain | grep -q "^\S" && idxClean=false || idxClean=true + if $mitFarbe then - PS1="$PS1 \[\033[01;31m\]" - elif git status --porcelain | grep -q "^\S" + if ! $wtClean + then + PS1="$PS1\[\033[01;31m\]" + elif ! $idxClean + then + PS1="$PS1\[\033[01;33m\]" + else + PS1="$PS1\[\033[01;32m\]" + fi + fi + PS1="$PS1$branch" + if $mitFarbe then - PS1="$PS1 \[\033[01;33m\]" + PS1="$PS1\[\033[00m\]" else - PS1="$PS1 \[\033[01;32m\]" + if ! $wtClean + then + PS1="$PS1!" + elif ! $idxClean + then + PS1="$PS1+" + fi fi - PS1="$PS1$branch\[\033[00m\]\$ " -else - PS1="$PS1\$ " fi + +PS1="$PS1$PS1Ende" |