From e65cbc2ef307135c15015a75efa81d44d8390d9c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 6 Oct 2016 15:03:12 +0200 Subject: correct(er) handling of colour-characters --- bash-git-prompt.in | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/bash-git-prompt.in b/bash-git-prompt.in index e39ea81..0c06894 100755 --- a/bash-git-prompt.in +++ b/bash-git-prompt.in @@ -4,15 +4,11 @@ [[ "$TERM" = *color ]] && mitFarbe=true || mitFarbe=false -[ -z "$PS1Start" ] && [ -z "$PS1Ende" ] && - if echo "$PS1" | grep -q "\S" - then - export PS1Ende="$(echo "$PS1" | sed 's|^.*[^\]\(\\\?[$#>]\s*\([]\\[0-9m]\)*\s*\)$|\1|')" - export PS1Start="$(echo "$PS1" | sed 's|\\\?[$#>]\s*\([]\\[0-9m]\)*\s*$||')" - else - export PS1Ende="" - export PS1Start="$PS1" - fi +if [ -z "$PS1Start" ] && [ -z "$PS1Ende" ] && [ -n "$PS1" ] +then + export PS1Start="$(echo "$PS1" | sed 's@\(\\\[\\033\[[0-9]\+m\\]\|\s\)*\(\\\?\S\)\?\(\\\[\\033\[[0-9]\+m\\]\|\s\)*$@@')" + export PS1Ende="${PS1:${#a}}" +fi PS1="$PS1Start" -- cgit v1.2.3-70-g09d2