commit 2335e45cd6cf47f10fd0cd3b5a9fbfba1739240f
parent a69f6c9837e03b3c691ec4c55c7ecd833a15cb65
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date: Thu, 2 Mar 2017 07:20:37 +0100
Change no-newline and error code reporting
- no newline: simply append a visible /
- error code: move to first line and make rule red
Diffstat:
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git 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}
}