Skip to content

Instantly share code, notes, and snippets.

@fzerorubigd
Created June 9, 2014 08:40
Show Gist options
  • Save fzerorubigd/cb8252a7d60f9638cea5 to your computer and use it in GitHub Desktop.
Save fzerorubigd/cb8252a7d60f9638cea5 to your computer and use it in GitHub Desktop.
run tmux in all emulated tty and attach to them when exiting the shell
# TMUX
if [ -z `tty | grep tty` ] ; then
if which tmux 2>&1 >/dev/null; then
# if no session is started, start a new session
test -z ${TMUX} && tmux
# when quitting tmux, try to attach
while test -z ${TMUX}; do
echo "Press enter to attach to other tmux instanse, or anything then enter to just leave"
read attachto
if [ -z $attachto ]; then
tmux attach || break
else
break
fi
done
fi;
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment