From 2961e10cbdc506f708b650643bd2dabfe3b38a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 17 Nov 2023 14:05:28 +0100 Subject: [PATCH 1/3] Merged detached head into master --- bin/startagent | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/startagent b/bin/startagent index cbf77b4..c1d7e99 100755 --- a/bin/startagent +++ b/bin/startagent @@ -35,6 +35,7 @@ usage(){ Just to be asked for password again, if you plugged off hardware-token and plugged it in again. --rm|--remove remove keys and token instead of adding them. + -R|--restart-agent -h|--info Show this info @@ -103,7 +104,9 @@ set_and_load_identity_config() { if [ -e "${ssh_identity_dir}/config" ]; then logdebug "source ${ssh_identity_dir}/config" unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE SSH_AGENT_ALLOW_FROM_REMOTE SSH_ADD_OPTION + set -a . "${ssh_identity_dir}/config" + set +a fi } @@ -116,6 +119,8 @@ start_or_restart_local_agent() { logdebug "SSH_AUTH_SOCK: ${SSH_AUTH_SOCK:-not set}" logdebug "SSH_AGENT_PID: ${SSH_AGENT_PID:-not set}" logdebug "PKCS11_MODULE: ${PKCS11_MODULE:-not set}" + # kill ssh-agent when wanted from options + ${restartagent:-false} && ssh-agent -k for i in $(pgrep -f ${SSH_AUTH_SOCK}) do logdebug "$(stat ${SSH_AUTH_SOCK})" @@ -348,6 +353,10 @@ keyonly=false remove=false while :; do case $1 in + -r|--restart-agent) + restartagent=true + shift + ;; -c|--create-only) createonly=true shift @@ -394,6 +403,7 @@ fi logdebug " PKCS11_MODULE=${PKCS11_MODULE:-not set}" logdebug " SSH_ADD_OPTIONS=${SSH_ADD_OPTIONS:-not set}" +logdebug " SSH_AGENT_OPTIONS=${SSH_AGENT_OPTIONS:-not set}" logdebug "SSH_AGENT_ALLOW_FROM_REMOTE=${SSH_AGENT_ALLOW_FROM_REMOTE:-false}" logdebug " PKCS11_MODULE=${PKCS11_MODULE:-not set}" logdebug " P11M=${P11M:-not set}" From 6a6e60aa5bbdb155466eb0a1aecd5ab6f23b8b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 8 Dec 2023 20:57:27 +0100 Subject: [PATCH 2/3] add vimwiki plugin for vim --- .gitmodules | 3 +++ vim/pack/plugins/start/vimwiki | 1 + vimplugins | 1 + 3 files changed, 5 insertions(+) create mode 160000 vim/pack/plugins/start/vimwiki diff --git a/.gitmodules b/.gitmodules index bc1c951..b05f312 100644 --- a/.gitmodules +++ b/.gitmodules @@ -61,3 +61,6 @@ [submodule "vim/pack/plugins/start/vim-soa"] path = vim/pack/plugins/start/vim-soa url = https://codeberg.org/xundeenergie/vim-soa.git +[submodule "vim/pack/plugins/start/vimwiki"] + path = vim/pack/plugins/start/vimwiki + url = https://github.com/vimwiki/vimwiki.git diff --git a/vim/pack/plugins/start/vimwiki b/vim/pack/plugins/start/vimwiki new file mode 160000 index 0000000..0bb1b49 --- /dev/null +++ b/vim/pack/plugins/start/vimwiki @@ -0,0 +1 @@ +Subproject commit 0bb1b4945bb205a076a35b66174e5d66be8eaafe diff --git a/vimplugins b/vimplugins index 88e56ad..7b387d5 100644 --- a/vimplugins +++ b/vimplugins @@ -18,3 +18,4 @@ install plugins https://github.com/airblade/vim-gitgutter.git remove plugins https://github.com/Lokaltog/powerline.git install plugins https://github.com/jamessan/vim-gnupg install plugins https://git.schuerz.at/public/vim-soa.git +install plugins https://github.com/vimwiki/vimwiki.git From 73821828b45518fc8c068f5ff0933d74975ff480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 10 Jan 2024 21:22:12 +0100 Subject: [PATCH 3/3] Merged detached head into master --- PS1 | 42 +++++++++++++++++++++++++++++------------- bashrc_add | 13 ++++++------- functions.sh | 24 +++++++++++++++++++++++- myshell_load_defaults | 13 ++++--------- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/PS1 b/PS1 index b6457d5..1a6fd95 100644 --- a/PS1 +++ b/PS1 @@ -9,6 +9,7 @@ parse_git_branch() { [ -z "${RBRANCH-x}" ] && unset RBRANCH local BRANCH="${LBRANCH}${RBRANCH+ -> }${RBRANCH}" [ -z "${BRANCH-x}" ] || echo "($BRANCH)"|tr -s '()' + return 0 } set_label() { @@ -127,26 +128,41 @@ case "$TERM" in *) SCREEN="";; esac - # Base prompt - 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\]# " - 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\]\$ " - fi +# # 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 RETVAL0="\342\234\223" RETVALN0="\342\234\227 " ;; *) - # Base prompt - 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\]" - 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\]" - fi +# # Base prompt +# 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\]" +# 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\]" +# fi RETVAL0=":)" RETVALN0=":(" ;; esac -PS1="( \$? \$(if [[ \$? == 0 ]]; then echo \"\[$Green\]${RETVAL0}\"; else echo \"\[$Red\]${RETVALN0}\"; fi )\[\e[m\]) ${PS1}\[\e[m\]" + +# 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\]" + #trap 'echo -ne "\e[0m"' DEBUG diff --git a/bashrc_add b/bashrc_add index 32e7645..be3fbcc 100755 --- a/bashrc_add +++ b/bashrc_add @@ -199,19 +199,18 @@ EOF _tmux_hook _umask_hook #_pkcs11module_hook - promptcommandmunge "_tmux_hook" - promptcommandmunge "_umask_hook" - #promptcommandmunge "_pkcs11module_hook" - promptcommandmunge "_bashrc_tmp_hook" - promptcommandmunge "_remote_ssh_agent_hook" + [[ $(type -t _umask_hook) == function ]] && promptcommandmunge "_umask_hook" + [[ $(type -t _tmux_hook) == function ]] && promptcommandmunge "_tmux_hook" + #[[ $(type -t _pkcs11module_hook) == function ]] && promptcommandmunge "_pkcs11module_hook" + [[ $(type -t _bashrc_tmp_hook) == function ]] && promptcommandmunge "_bashrc_tmp_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)" cat << EOF >> "${MSC_LOGFILE}" ==8<=== finished configure new shell ================ $(date) ===============8<== EOF - #else - # echo "non-interactive shell" >&2 SCRIPTEXIT # Start tmux if not defined as STARTTMUX in bashrc diff --git a/functions.sh b/functions.sh index 928788c..94bac0e 100755 --- a/functions.sh +++ b/functions.sh @@ -21,6 +21,29 @@ promptcommandmunge () { 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() { if [ ! -z "${bashrctmp:-x}" ]; then @@ -96,7 +119,6 @@ function _tmux_hook() { if [ -n "${TMUX:-}" ]; then eval "$(tmux show-environment -s)" fi - } function _umask_hook { diff --git a/myshell_load_defaults b/myshell_load_defaults index e35cd6d..1679c6f 100644 --- a/myshell_load_defaults +++ b/myshell_load_defaults @@ -1,8 +1,10 @@ #!/bin/bash -# if we are root, exit after 5 Minutes case $(tty) in + # if we run on console, then terminate shell /dev/tty[0-9]*) + # if we are root, exit after 5 minutes + # if we are user, exit after 10 minutes case $(id -u) in 0) TMOUT=${MSC_ROOT_TMOUT:-500} @@ -104,14 +106,7 @@ if ! $SSHS; then 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 -# : # STARTTMUXDEFAULT=${STARTTMUXREMOTEDEFAULT} -# logwarn "TEST1" -# else -# logwarn "TEST2" -# STARTTMUXDEFAULT=${STARTTMUXREMOTEDEFAULT} -# fi - logdebug "${STARTTMUXDEFAULT}" + logdebug "STARTTMUXDEFAULT: ${STARTTMUXDEFAULT}" unset -f pathmunge