summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKรฉvin Le Gouguec <kevin.legouguec@gmail.com>2017-03-02 07:36:29 +0100
committerKรฉvin Le Gouguec <kevin.legouguec@gmail.com>2017-03-02 07:36:29 +0100
commitc57ac089c97db65e6e795bf45c266b645025e654 (patch)
treef925aad8f8a586add67016b56aa2d8e18834c620
parent2335e45cd6cf47f10fd0cd3b5a9fbfba1739240f (diff)
downloaddotfiles-c57ac089c97db65e6e795bf45c266b645025e654.tar.xz
Move horizontal rule out of prompt
Simplifies the code somewhat; less arguments to pass around.
-rw-r--r--.bash_prompt33
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
}