From 2335e45cd6cf47f10fd0cd3b5a9fbfba1739240f Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Thu, 2 Mar 2017 07:20:37 +0100 Subject: Change no-newline and error code reporting - no newline: simply append a visible / - error code: move to first line and make rule red --- .bash_prompt | 37 ++++++++++++++++++------------------- 1 file 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