This commit is contained in:
Darren 'Tadgy' Austin 2020-12-02 20:12:06 +00:00
commit e106e8eb5d
12 changed files with 59 additions and 327 deletions

27
.bashrc
View file

@ -153,6 +153,30 @@ _unlock_agents_file() {
fi
}
screen_attach() {
local TTY SCREENS
# Only continue if it's not a remote connection, and not inside screen already.
[[ -z "$SSH_TTY" ]] && [[ -z "$STY" ]] && {
TTY="$(tty | cut -d/ -f3-)"
SCREENS="$(screen -list | fgrep -v "Dead" | fgrep "$HOSTNAME" | fgrep "${TTY//\//-}")"
case "$(echo "${SCREENS:--n}" | wc -l)" in
0)
# No screens found - start a new instance.
screen
;;
1)
# Just one screen - reconnect.
screen -dr "${TTY//\//-}.$HOSTNAME"
;;
*)
# Multiple screens - output a list
echo "Multiple screens found for $TTY:"
echo "$SCREENS" | sed -e 's/^/ /g'
;;
esac
}
}
# Make bash a little more pleasent - these are valid for all versions.
shopt -s cdspell checkhash checkwinsize cmdhist histappend no_empty_cmd_completion
@ -205,7 +229,8 @@ unset _COLOUR
# Set the debugger prompt.
# PS4="+(\\\$? = \$?) \${BASH_SOURCE##*/}\${FUNCNAME:+(\$FUNCNAME)}:\$LINENO: "
PS4="+(\[\e[33m\]\\\$? = \$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
# PS4="+(\[\e[33m\]\\\$? = \$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
export PS4="+(\[\e[33m\]\$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
# The commands to execute before the prompt is displayed.
PROMPT_COMMAND="_agent_prompt_command"