From 5f04b1fee4768b38e15952b87f39304b9612c5e6 Mon Sep 17 00:00:00 2001 From: Alexander Blinne Date: Mon, 11 Apr 2016 23:01:21 +0200 Subject: Effizienzsteigerung --- bash-git-prompt | 24 +++++++++++++----------- 1 file 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 -- cgit v1.2.3-70-g09d2