[bash] env STATICPS1 now toggles PS1 prompt_command

This commit is contained in:
Eric Teunis de Boone 2024-07-04 15:17:53 +02:00
parent fd86e1cd6d
commit eeb2f10d2d
1 changed files with 36 additions and 26 deletions

View File

@ -5,6 +5,9 @@
SHORTPS1=${SHORTPS1:-}
export SHORTPS1
STATICPS1=${STATICPS1:-}
export STATICPS1
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
@ -117,6 +120,7 @@ function __colored_username() {
}
function __prompt_command() {
local STATIC_PS1="${1:-${STATICPS1}}"
local RETVAL=$?
if [ ! $RETVAL -ne 0 ]; then
RETVAL=0
@ -124,7 +128,8 @@ function __prompt_command() {
PS1="${debian_chroot:+($debian_chroot)}"
#Return Value
if [ -z "${STATIC_PS1}" ]; then
### Add Return Value ###
if [ -n $RETVAL ]; then
PS1+="$(retval ${RETVAL})"
fi
@ -139,6 +144,8 @@ function __prompt_command() {
PS1+="$(git_status)"
fi
PS1+=" "
fi
# user@hostname
if color ; then
@ -165,8 +172,10 @@ function __prompt_command() {
if color ; then
PS1+="${RCol}"
fi
PS1+=" "
# dir count, pwd
if [ -z "${STATIC_PS1}" ]; then
PS1+=" "
if color ; then
PS1+="${BBlu}"
fi
@ -177,6 +186,7 @@ function __prompt_command() {
PS1+="${RCol}"
fi
PS1+=" "
fi
## Short prompt
if [ -n "${SHORTPS1}" ]; then
PS1+="\r\n"