diff --git a/.bash_profile b/.bash_profile index 237c8aa..66bfbf6 100644 --- a/.bash_profile +++ b/.bash_profile @@ -7,7 +7,6 @@ export LANG="en_GB.UTF-8" export LC_COLLATE="POSIX" # 'C' causes issues with some applications # export LC_CTYPE="POSIX" # Not sure why I set this in the first place... export LESS="-RMi -PM?f%F:stdin. -- Page %dt of %D -- %lt/%L (%Pt\%)$" -export MANPAGER="less -Mis -PM'Page %dt$'" export PAGER="less" export PATH="/usr/local/sbin:/usr/sbin:/opt/sbin:/sbin:$PATH" export VISUAL="$EDITOR" @@ -19,10 +18,12 @@ if [[ "$_PLATFORM" = "Linux" ]]; then export I_WANT_A_BROKEN_PS=1 export LYNX_CFG="$HOME/.lynx.cfg" export LYNX_LSS="$HOME/.lynx.lss" + export MANPAGER="most" export MANPATH="$HOME/.local/share/man:$MANPATH" hash dircolors >/dev/null 2>&1 && eval "$(dircolors -b ~/.dir_colors)" elif [[ "$_PLATFORM" = "Darwin" ]]; then export LSCOLORS="ExGxdxdxCxDxDxbcacbeae" + export MANPAGER="less -Mis -PM'Page %dt$'" export MANPATH="/opt/local/share/man:$MANPATH" export PATH="/opt/local/sbin:/opt/local/bin:$PATH" else @@ -116,6 +117,10 @@ unset _OUTPUT _PLATFORM # Screen. hash screen >/dev/null 2>&1 && { + # Reattach existing screens. + screen_attach + + # Output some screen info. export SCREENDIR="$HOME/.screen-$(hostname --short)" if [[ ! -e ~/.hushlogin ]]; then if [[ ! -z "$STY" ]]; then diff --git a/.bashrc b/.bashrc index cd036b9..691948f 100644 --- a/.bashrc +++ b/.bashrc @@ -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" diff --git a/.dmrc b/.dmrc index 2817c51..74e11a4 100644 --- a/.dmrc +++ b/.dmrc @@ -1,2 +1,2 @@ [Desktop] -Session=LXDE +Session=lightdm-xsession