dotfiles

🎜 Clone'em, tweak'em, stick'em in your $HOME 🎝
git clone https://git.kevinlegouguec.net/dotfiles
Log | Files | Refs | README

commit 4c9afc91a5e0669abb6e35be395ee80f6ed7f150
parent a766685321f35f131863041e10d8a36e4814eab0
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Fri,  4 Nov 2016 18:48:15 +0100

Add horizontal rule

Diffstat:
M.bashprompt | 33+++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)

diff --git 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 }