dotfiles

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

commit c57ac089c97db65e6e795bf45c266b645025e654
parent 2335e45cd6cf47f10fd0cd3b5a9fbfba1739240f
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Thu,  2 Mar 2017 07:36:29 +0100

Move horizontal rule out of prompt

Simplifies the code somewhat; less arguments to pass around.

Diffstat:
M.bash_prompt | 33++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/.bash_prompt b/.bash_prompt @@ -113,19 +113,9 @@ __fontify () __set-prompt () { - local last_status=$1 BUILDING_PS1=t PS1='' - if [ ${last_status} -ne 0 ] - then - local error="${last_status} " - PS1+=$(__fontify "${error}" bold red) - PS1+="$(__draw-rule $((COLUMNS-${#error})) dim red)" - else - PS1+="$(__draw-rule ${COLUMNS} dim)" - fi - PS1+="$(__write-context)\n" PS1+=$(__fontify '\$' dim) PS1+=' ' @@ -158,12 +148,9 @@ __signal-no-newline () __draw-rule () { - local length=$1 - shift - local line='' - for ((i=1; i<length; i++)) + for ((i=$(__current-column); i<COLUMNS; i++)) do line+=β€” done @@ -179,16 +166,16 @@ __write-context () { local context='' - context+=$(__fontify "${USER}" green) + context+=$(__fontify '\u' green) if __show-hostname then - context+=$(__fontify '@' dim) - context+=$(__fontify "${HOSTNAME}" bold green) + context+=$(__fontify @ dim) + context+=$(__fontify '\h' bold green) fi context+=$(__fontify : dim) - context+=$(__fontify "${PWD/~/\~}" bold blue) + context+=$(__fontify '\w' bold blue) if [ ${PS1_SHOWGITSTATUS} ] then @@ -210,7 +197,15 @@ __refresh-terminal () __signal-no-newline fi - __set-prompt ${last_status} + if [ ${last_status} -ne 0 ] + then + __fontify "${last_status} " bold red + __draw-rule dim red + else + __draw-rule dim + fi + + __set-prompt }