summaryrefslogtreecommitdiff
path: root/.bash_prompt
diff options
context:
space:
mode:
authorKรฉvin Le Gouguec <kevin.legouguec@gmail.com>2017-03-02 07:20:37 +0100
committerKรฉvin Le Gouguec <kevin.legouguec@gmail.com>2017-03-02 07:20:37 +0100
commit2335e45cd6cf47f10fd0cd3b5a9fbfba1739240f (patch)
tree1e068467b698f1b0f100adc1d71bcc671d80add9 /.bash_prompt
parenta69f6c9837e03b3c691ec4c55c7ecd833a15cb65 (diff)
downloaddotfiles-2335e45cd6cf47f10fd0cd3b5a9fbfba1739240f.tar.xz
Change no-newline and error code reporting
- no newline: simply append a visible / - error code: move to first line and make rule red
Diffstat (limited to '.bash_prompt')
-rw-r--r--.bash_prompt37
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}
}