diff options
Diffstat (limited to '.bashprompt')
| -rw-r--r-- | .bashprompt | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/.bashprompt b/.bashprompt index 2e0ba7d..d7a6a54 100644 --- a/.bashprompt +++ b/.bashprompt @@ -13,6 +13,22 @@ __set-title () echo -ne "\033]2;${title}\007" } +__start-nonprinting () +{ + if [ ${BUILDING_PS1} ] + then + echo -en '\[' + fi +} + +__end-nonprinting () +{ + if [ ${BUILDING_PS1} ] + then + echo -en '\]' + fi +} + __fontify () { local -A codes @@ -30,7 +46,8 @@ __fontify () # We need to add \[ \] around CSI sequences so that Bash can tell which # characters are non-printing. - echo -en '\[\033[' + __start-nonprinting + echo -en '\033[' local attributes=($@) local nb=$# @@ -44,16 +61,22 @@ __fontify () then echo -en ';' else - echo -en 'm\]' + echo -en 'm' fi done + __end-nonprinting + echo -n "${string}" - echo -en "\[\033[0m\]" + __start-nonprinting + echo -en "\033[0m" + __end-nonprinting } __set-prompt () { + BUILDING_PS1=t + local last_status=$1 PS1='' @@ -69,6 +92,8 @@ __set-prompt () PS1+=$(__fontify "$(__git_ps1 '(%s)')" red) PS1+=$(__fontify '\$' bold white) PS1+=' ' + + BUILDING_PS1= } __draw-rule () @@ -87,7 +112,7 @@ __refresh-terminal () __set-title __set-prompt ${last_status} - # __draw-rule + __draw-rule } |
