summaryrefslogtreecommitdiff
path: root/.bash_prompt
diff options
context:
space:
mode:
Diffstat (limited to '.bash_prompt')
-rw-r--r--.bash_prompt79
1 files changed, 53 insertions, 26 deletions
diff --git a/.bash_prompt b/.bash_prompt
index 55c94b6..3b9b62c 100644
--- a/.bash_prompt
+++ b/.bash_prompt
@@ -122,22 +122,6 @@ __set-prompt ()
PS1+=$(__fontify "${last_status} " bold red)
fi
- PS1+=$(__fontify '\u' green)
-
- if __show-hostname
- then
- PS1+=$(__fontify '@' dim)
- PS1+=$(__fontify '\H' bold green)
- fi
-
- PS1+=$(__fontify : dim)
- PS1+=$(__fontify '\w' bold blue)
-
- if [ ${PS1_SHOWGITSTATUS} ]
- then
- PS1+=$(__fontify "$(__git_ps1 '(%s)')" red)
- fi
-
PS1+=$(__fontify '\$' dim)
PS1+=' '
@@ -161,30 +145,73 @@ __current-column ()
fi
}
-__draw-rule ()
+__fill-line ()
{
- local rule=''
- local column=$(__current-column)
+ local char=$1
+ shift
+
+ local line=''
- for ((i=column; i<=COLUMNS; i++))
+ for ((i=$(__current-column); i<COLUMNS; i++))
do
- rule+=—
+ line+=${char}
done
- # If we do not add a newline, the prompt will be shoved offscreen
- # when autowrap is off.
- rule+='\n'
+ # If we do not add a newline, whatever comes after will be shoved
+ # offscreen when autowrap is off.
+ line+='\n'
+
+ __fontify ${line} $@
+}
+
+__draw-rule ()
+{
+ __fill-line — dim
+}
+
+__finish-line ()
+{
+ __fill-line / dim red
+}
+
+__write-context ()
+{
+ local context=''
+
+ context+=$(__fontify "${USER}" green)
+
+ if __show-hostname
+ then
+ context+=$(__fontify '@' dim)
+ context+=$(__fontify "${HOSTNAME}" bold green)
+ fi
+
+ context+=$(__fontify : dim)
+ context+=$(__fontify "${PWD/~/\~}" bold blue)
- __fontify ${rule} dim
+ if [ ${PS1_SHOWGITSTATUS} ]
+ then
+ context+=$(__fontify "$(__git_ps1 '(%s)')" red)
+ fi
+
+ echo -n "${context} "
}
__refresh-terminal ()
{
local last_status=$?
+ local last_column=$(__current-column)
__set-title
- __set-prompt ${last_status}
+
+ if [ ${last_column} -ne 1 ]
+ then
+ __finish-line
+ fi
+
+ __write-context
__draw-rule
+ __set-prompt ${last_status}
}