diff options
| -rw-r--r-- | .bash_prompt | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/.bash_prompt b/.bash_prompt index 3b9b62c..712c95e 100644 --- a/.bash_prompt +++ b/.bash_prompt @@ -119,9 +119,14 @@ __set-prompt () if [ ${last_status} -ne 0 ] then - PS1+=$(__fontify "${last_status} " bold red) + 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+=' ' @@ -145,16 +150,22 @@ __current-column () fi } -__fill-line () +__signal-no-newline () +{ + local signal="/\n" + __fontify ${signal} bold red +} + +__draw-rule () { - local char=$1 + local length=$1 shift local line='' - for ((i=$(__current-column); i<COLUMNS; i++)) + for ((i=1; i<length; i++)) do - line+=${char} + line+=— done # If we do not add a newline, whatever comes after will be shoved @@ -164,16 +175,6 @@ __fill-line () __fontify ${line} $@ } -__draw-rule () -{ - __fill-line — dim -} - -__finish-line () -{ - __fill-line / dim red -} - __write-context () { local context='' @@ -194,7 +195,7 @@ __write-context () context+=$(__fontify "$(__git_ps1 '(%s)')" red) fi - echo -n "${context} " + echo ${context} } __refresh-terminal () @@ -206,11 +207,9 @@ __refresh-terminal () if [ ${last_column} -ne 1 ] then - __finish-line + __signal-no-newline fi - __write-context - __draw-rule __set-prompt ${last_status} } |
