Created
December 1, 2009 23:30
-
-
Save dennyhalim/246751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ "$TERM" != vt320 ]]; then | |
if ! which screen|grep "no screen"; then | |
if screen -ls|head -n3|tail -n2|cut -f2|cut -d. -f2-|grep -q | |
'^'main'$'; then | |
exec screen -r main | |
else | |
exec screen -S main | |
fi | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## The naive "chsh -s /usr/bin/screen" breaks scp (and other things). | |
## Have sh start screen automatically "when appropriate". That is, | |
## 1) not in a screen window (STY); | |
## 2) stdin is a tty; | |
## 3) screen is installed; and | |
## 4) terminal is capable of displaying screen. | |
## Replace "$STY" with "$STY$SSH_CLIENT$SSH_ORIGINAL_COMMAND" to avoid | |
## nesting screens when sshing (untested). | |
test -z "$STY" -a -t 0 && | |
{ which screen && tput clear && tput cup && ! tput hc && ! tput os | |
} &>/dev/null && # ignore boring, expected error messages | |
{ | |
## Set the window title to the host name. | |
## Note that using echo -e \e for ^[ is not portable. | |
case "$TERM" in | |
screen*) printf %bk%s%b%b \\033 "${HOSTNAME%%.*}" \\033 \\0134;; | |
esac | |
## If new session, start agents. | |
screen -ls | grep -qi 'No Sockets found' && | |
eval "$(twb-agents)" | |
## Start screen. | |
exec screen -DRR | |
} | |
## If execution reaches this point, screen isn't the login shell. In | |
## that case, if this is a bash shell, it's a good idea to do the | |
## bashisms in .bashrc. | |
test -n "$BASH" && | |
test -f ~/.bashrc && | |
. ~/.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment