Rework how screen is handled upon login.
This commit is contained in:
parent
352f506851
commit
e2ce961d84
2 changed files with 29 additions and 31 deletions
25
.bashrc
25
.bashrc
|
|
@ -1,28 +1,3 @@
|
|||
# Functions.
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue