make LABEL dynamic

This commit is contained in:
Jakobus Schürz 2020-07-09 22:36:07 +02:00
parent d45cf3484e
commit 23105d4f20

43
PS1
View file

@ -8,15 +8,19 @@ parse_git_branch() {
set_label() {
local LABEL
SSHS=${SSHS-false}
LABEL=""
# Labels: remote, tmpconfig, screen...
if [ ! -z ${SSH_TTY:+x} ]; then
LABEL="${LABEL} \[$On_IRed\]\[$BBlack\]remote\[$Color_Off\]"
#LABEL="${LABEL} \[$On_IRed\]\[$BBlack\]remote\[$Color_Off\]"
LABEL="${LABEL} \[$On_IRed\]remote\[$Color_Off\]"
fi
if $SSHS ; then
#LABEL="${LABEL} \[$On_IWhite\]\[$BBlack\]tmpconfig\[$Color_Off\]"
LABEL="${LABEL} \[$On_IWhite\]\[$BBlack\]tmpconfig\[$Color_Off\]"
fi
echo $LABEL
echo ${LABEL@P}
}
if [ -x "/usr/bin/getsyssubvol" ]; then
@ -113,7 +117,6 @@ On_ICyan='\e[0;106m' # Cyan
On_IWhite='\e[0;107m' # White
LABEL=""
SSHS=${SSHS-false}
case "$TERM" in
xterm*|rxvt*|screen*)
case "$TERM" in
@ -122,12 +125,12 @@ case "$TERM" in
esac
# Labels: remote, tmpconfig, screen...
if [ ! -z ${SSH_TTY:+x} ]; then
LABEL="${LABEL} \[$On_IRed\]\[$BBlack\]remote\[$Color_Off\]"
fi
if $SSHS ; then
LABEL="${LABEL} \[$On_IWhite\]\[$BBlack\]tmpconfig\[$Color_Off\]"
fi
# if [ ! -z ${SSH_TTY:+x} ]; then
# LABEL="${LABEL} \[$On_IRed\]\[$BBlack\]remote\[$Color_Off\]"
# fi
# if $SSHS ; then
# LABEL="${LABEL} \[$On_IWhite\]\[$BBlack\]tmpconfig\[$Color_Off\]"
# fi
# Base prompt
# if [ "`id -u`" -eq 0 ]; then
@ -136,27 +139,27 @@ case "$TERM" in
# PS1="\[$BIBlue\]$SCREEN\u@\h \[$BIBlue\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]$LABEL\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BIBlue\]\$ "
# fi
if [ "`id -u`" -eq 0 ]; then
PS1="\[$BRed\]$SCREEN\u@\h \[$BRed\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]$(set_label)\n\[$BRed\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BRed\]# "
PS1="\[$BRed\]$SCREEN\u@\h \[$BRed\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]\$(set_label)\n\[$BRed\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BRed\]# "
else
PS1="\[$BIBlue\]$SCREEN\u@\h \[$BIBlue\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]$(set_label)\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BIBlue\]\$ "
PS1="\[$BIBlue\]$SCREEN\u@\h \[$BIBlue\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]\$(set_label)\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BIBlue\]\$ "
fi
RETVAL0="\342\234\223"
RETVALN0="\342\234\227 "
;;
*)
# Labels: remote, tmpconfig, screen...
if [ ! -z ${SSH_TTY:+x} ]; then
LABEL="${LABEL} \[$On_Red\]\[$BWhite\]remote\[$Color_Off\]"
fi
if $SSHS ; then
LABEL="${LABEL} \[$On_White\]\[$BBlack\]tmpconfig\[$Color_Off\]"
fi
# if [ ! -z ${SSH_TTY:+x} ]; then
# LABEL="${LABEL} \[$On_Red\]\[$BWhite\]remote\[$Color_Off\]"
# fi
# if $SSHS ; then
# LABEL="${LABEL} \[$On_White\]\[$BBlack\]tmpconfig\[$Color_Off\]"
# fi
# Base prompt
if [ "`id -u`" -eq 0 ]; then
PS1="\[$BRed\][$SYSSUBVOL]\u@\h \[$BIBlue\]\[\e[m\]\[$BIPurple\](\A)\[\e[m\]\[$BBlue\]$LABEL\n\[$BRed\]${SYSSUBVOL}\w:\$(parse_git_branch) \$ \[\e[m\]\[$Blue\]"
PS1="\[$BRed\][$SYSSUBVOL]\u@\h \[$BIBlue\]\[\e[m\]\[$BIPurple\](\A)\[\e[m\]\[$BBlue\]\$(set_label)\n\[$BRed\]${SYSSUBVOL}\w:\$(parse_git_branch) \$ \[\e[m\]\[$Blue\]"
else
PS1="\[$BBlue\][$SYSSUBVOL]\u@\h \[$BIBlue\]\[\e[m\]\[$BIPurple\](\A)\[\e[m\]\[$BBlue\]$LABEL\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \$ \[\e[m\]\[$Blue\]"
PS1="\[$BBlue\][$SYSSUBVOL]\u@\h \[$BIBlue\]\[\e[m\]\[$BIPurple\](\A)\[\e[m\]\[$BBlue\]\$(set_label)\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \$ \[\e[m\]\[$Blue\]"
fi
RETVAL0=":)"
RETVALN0=":("