summaryrefslogtreecommitdiff
path: root/bash-git-prompt.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-10-06 15:03:12 +0200
committerErich Eckner <git@eckner.net>2016-10-06 15:03:12 +0200
commite65cbc2ef307135c15015a75efa81d44d8390d9c (patch)
treeee991f13eb5745ea1b7024abc73d26783eebc84a /bash-git-prompt.in
parentb578186bb1a96e97583fdbfb7b576314e91a8df9 (diff)
downloadbash-git-prompt-e65cbc2ef307135c15015a75efa81d44d8390d9c.tar.xz
correct(er) handling of colour-characters
Diffstat (limited to 'bash-git-prompt.in')
-rwxr-xr-xbash-git-prompt.in14
1 files 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"