diff options
-rw-r--r-- | bash-git-prompt | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/bash-git-prompt b/bash-git-prompt index 0eef652..e3159fc 100644 --- a/bash-git-prompt +++ b/bash-git-prompt @@ -4,22 +4,24 @@ set -o pipefail [[ "$TERM" = *-color ]] && mitFarbe=true || mitFarbe=false -[ -z "$PS1save" ] && PS1save="$PS1" +[ -z "$PS1Start" ] && [ -z "$PS1Ende" ] && + if echo "$PS1" | grep -q "\S" + then + PS1Ende="$(echo "$PS1" | sed "s|^.*[^\\]\(\\\\\?\S\s*\)\$|\1|")" + PS1Start="$(echo "$PS1" | sed "s|\\\\\?\S\s*\$||")" + else + PS1Ende="" + PS1Start="$PS1" + fi -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 +PS1="$PS1Start" if branch=$(git branch 2>/dev/null | grep '^\*' | sed "s|^\*\s*||") then PS1="$PS1 " - git status --porcelain | grep -q "^.\S" && wtClean=false || wtClean=true - git status --porcelain | grep -q "^\S" && idxClean=false || idxClean=true + status=$(git status --porcelain) + echo "$status" | grep -q "^.\S" && wtClean=false || wtClean=true + echo "$status" | grep -q "^\S" && idxClean=false || idxClean=true if $mitFarbe then if ! $wtClean |