diff options
| -rw-r--r-- | .bash_prompt | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/.bash_prompt b/.bash_prompt index 712c95e..7a55f35 100644 --- 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 } |
