diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2016-11-04 18:48:15 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2016-11-04 18:48:15 +0100 |
| commit | 4c9afc91a5e0669abb6e35be395ee80f6ed7f150 (patch) | |
| tree | 35551708df3e17cc53f57e257e1bd0177700bbf6 | |
| parent | a766685321f35f131863041e10d8a36e4814eab0 (diff) | |
| download | dotfiles-4c9afc91a5e0669abb6e35be395ee80f6ed7f150.tar.xz | |
Add horizontal rule
| -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 } |
