Merged detached head into master
This commit is contained in:
parent
f8e4764feb
commit
eacb28b712
4 changed files with 62 additions and 30 deletions
40
PS1
40
PS1
|
@ -9,6 +9,7 @@ parse_git_branch() {
|
||||||
[ -z "${RBRANCH-x}" ] && unset RBRANCH
|
[ -z "${RBRANCH-x}" ] && unset RBRANCH
|
||||||
local BRANCH="${LBRANCH}${RBRANCH+ -> }${RBRANCH}"
|
local BRANCH="${LBRANCH}${RBRANCH+ -> }${RBRANCH}"
|
||||||
[ -z "${BRANCH-x}" ] || echo "($BRANCH)"|tr -s '()'
|
[ -z "${BRANCH-x}" ] || echo "($BRANCH)"|tr -s '()'
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
set_label() {
|
set_label() {
|
||||||
|
@ -127,26 +128,41 @@ case "$TERM" in
|
||||||
*) SCREEN="";;
|
*) SCREEN="";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Base prompt
|
# # Base prompt
|
||||||
if [ "`id -u`" -eq 0 ]; then
|
# 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}${SYSSUBVOL}\u@\h \[$BRed\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]\$(set_label)\n\[$BRed\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BRed\]# "
|
||||||
else
|
# 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}${SYSSUBVOL}\u@\h \[$BIBlue\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]\$(set_label)\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BIBlue\]\$ "
|
||||||
fi
|
# fi
|
||||||
RETVAL0="\342\234\223"
|
RETVAL0="\342\234\223"
|
||||||
RETVALN0="\342\234\227 "
|
RETVALN0="\342\234\227 "
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Base prompt
|
# # Base prompt
|
||||||
if [ "`id -u`" -eq 0 ]; then
|
# if [ "`id -u`" -eq 0 ]; then
|
||||||
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\]"
|
# 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
|
# else
|
||||||
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\]"
|
# 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
|
# fi
|
||||||
RETVAL0=":)"
|
RETVAL0=":)"
|
||||||
RETVALN0=":("
|
RETVALN0=":("
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Base prompt
|
||||||
|
#if [ "`id -u`" -eq 0 ]; then
|
||||||
|
# PS1="\[$BRed\]${SCREEN}${SYSSUBVOL}\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}${SYSSUBVOL}\u@\h \[$BIBlue\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]\$(set_label)\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BIBlue\]\$ "
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if [ "`id -u`" -eq 0 ]; then
|
||||||
|
PS1="\[$BRed\]${SCREEN}${SYSSUBVOL}\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}${SYSSUBVOL}\u@\h \[$BIBlue\]\[\e[m\]\[$IPurple\](\A)\[\e[m\]\$(set_label)\n\[$BIBlue\]${SYSSUBVOL}\w:\$(parse_git_branch) \[\e[m\]\[$BIBlue\]\$ "
|
||||||
|
fi
|
||||||
|
|
||||||
PS1="( \$? \$(if [[ \$? == 0 ]]; then echo \"\[$Green\]${RETVAL0}\"; else echo \"\[$Red\]${RETVALN0}\"; fi )\[\e[m\]) ${PS1}\[\e[m\]"
|
PS1="( \$? \$(if [[ \$? == 0 ]]; then echo \"\[$Green\]${RETVAL0}\"; else echo \"\[$Red\]${RETVALN0}\"; fi )\[\e[m\]) ${PS1}\[\e[m\]"
|
||||||
|
|
||||||
|
|
||||||
#trap 'echo -ne "\e[0m"' DEBUG
|
#trap 'echo -ne "\e[0m"' DEBUG
|
||||||
|
|
13
bashrc_add
13
bashrc_add
|
@ -199,19 +199,18 @@ EOF
|
||||||
_tmux_hook
|
_tmux_hook
|
||||||
_umask_hook
|
_umask_hook
|
||||||
#_pkcs11module_hook
|
#_pkcs11module_hook
|
||||||
promptcommandmunge "_tmux_hook"
|
[[ $(type -t _umask_hook) == function ]] && promptcommandmunge "_umask_hook"
|
||||||
promptcommandmunge "_umask_hook"
|
[[ $(type -t _tmux_hook) == function ]] && promptcommandmunge "_tmux_hook"
|
||||||
#promptcommandmunge "_pkcs11module_hook"
|
#[[ $(type -t _pkcs11module_hook) == function ]] && promptcommandmunge "_pkcs11module_hook"
|
||||||
promptcommandmunge "_bashrc_tmp_hook"
|
[[ $(type -t _bashrc_tmp_hook) == function ]] && promptcommandmunge "_bashrc_tmp_hook"
|
||||||
promptcommandmunge "_remote_ssh_agent_hook"
|
[[ $(type -t _remote_ssh_agent_hook) == function ]] && promptcommandmunge "_remote_ssh_agent_hook"
|
||||||
|
#[[ $(type -t _ps1_hook) == function ]] && promptcommandmunge "_ps1_hook"
|
||||||
which direnv >/dev/null && eval "$(direnv hook bash)"
|
which direnv >/dev/null && eval "$(direnv hook bash)"
|
||||||
|
|
||||||
cat << EOF >> "${MSC_LOGFILE}"
|
cat << EOF >> "${MSC_LOGFILE}"
|
||||||
==8<=== finished configure new shell ================ $(date) ===============8<==
|
==8<=== finished configure new shell ================ $(date) ===============8<==
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
#else
|
|
||||||
# echo "non-interactive shell" >&2
|
|
||||||
SCRIPTEXIT
|
SCRIPTEXIT
|
||||||
|
|
||||||
# Start tmux if not defined as STARTTMUX in bashrc
|
# Start tmux if not defined as STARTTMUX in bashrc
|
||||||
|
|
24
functions.sh
24
functions.sh
|
@ -21,6 +21,29 @@ promptcommandmunge () {
|
||||||
EXIT
|
EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ps1_hook() {
|
||||||
|
local EXIT="$?" # This needs to be first
|
||||||
|
PS1=""
|
||||||
|
|
||||||
|
local RCol='\[\e[0m\]'
|
||||||
|
local Red='\[\e[0;31m\]'
|
||||||
|
local Gre='\[\e[0;32m\]'
|
||||||
|
local BYel='\[\e[1;33m\]'
|
||||||
|
local BBlu='\[\e[1;34m\]'
|
||||||
|
local Pur='\[\e[0;35m\]'
|
||||||
|
|
||||||
|
echo EXIT $EXIT
|
||||||
|
if [ $EXIT != 0 ]; then
|
||||||
|
PS1+="${Red}\u${RCol}" # Add red if exit code non 0
|
||||||
|
else
|
||||||
|
PS1+="${Gre}\u${RCol}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PS1+="${RCol}@${BBlu}\h ${Pur}\W${BYel}$ ${RCol}"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
_bashrc_tmp_hook() {
|
_bashrc_tmp_hook() {
|
||||||
if [ ! -z "${bashrctmp:-x}" ];
|
if [ ! -z "${bashrctmp:-x}" ];
|
||||||
then
|
then
|
||||||
|
@ -96,7 +119,6 @@ function _tmux_hook() {
|
||||||
if [ -n "${TMUX:-}" ]; then
|
if [ -n "${TMUX:-}" ]; then
|
||||||
eval "$(tmux show-environment -s)"
|
eval "$(tmux show-environment -s)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _umask_hook {
|
function _umask_hook {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# if we are root, exit after 5 Minutes
|
|
||||||
case $(tty) in
|
case $(tty) in
|
||||||
|
# if we run on console, then terminate shell
|
||||||
/dev/tty[0-9]*)
|
/dev/tty[0-9]*)
|
||||||
|
# if we are root, exit after 5 minutes
|
||||||
|
# if we are user, exit after 10 minutes
|
||||||
case $(id -u) in
|
case $(id -u) in
|
||||||
0)
|
0)
|
||||||
TMOUT=${MSC_ROOT_TMOUT:-500}
|
TMOUT=${MSC_ROOT_TMOUT:-500}
|
||||||
|
@ -104,14 +106,7 @@ if ! $SSHS; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if test ! $TMUX && test $SSH_TTY && test $TERM != screen && test $(systemctl status tmux@${USER}.service 1>/dev/null 2>&1; echo $? ) -eq 0; then
|
logdebug "STARTTMUXDEFAULT: ${STARTTMUXDEFAULT}"
|
||||||
# : # STARTTMUXDEFAULT=${STARTTMUXREMOTEDEFAULT}
|
|
||||||
# logwarn "TEST1"
|
|
||||||
# else
|
|
||||||
# logwarn "TEST2"
|
|
||||||
# STARTTMUXDEFAULT=${STARTTMUXREMOTEDEFAULT}
|
|
||||||
# fi
|
|
||||||
logdebug "${STARTTMUXDEFAULT}"
|
|
||||||
|
|
||||||
unset -f pathmunge
|
unset -f pathmunge
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue