-
-
Save sirkkalap/117da6e2794451a71b68 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
# http://stackoverflow.com/a/7819465/720077 | |
takeover() { | |
# create a temporary session that displays the "how to go back" message | |
tmp='takeover temp session' | |
if ! tmux has-session -t "$tmp"; then | |
tmux new-session -d -s "$tmp" | |
tmux set-option -t "$tmp" set-remain-on-exit on | |
tmux new-window -kt "$tmp":0 \ | |
'echo "Use Prefix + L (i.e. ^B L) to return to session."' | |
fi | |
# switch any clients attached to the target session to the temp session | |
session="$1" | |
for client in $(tmux list-clients -t "$session" | cut -f 1 -d :); do | |
tmux switch-client -c "$client" -t "$tmp" | |
done | |
# attach to the target session | |
tmux attach -t "$session" | |
} | |
takeover 'original session' # or the session number if you do not name sessions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment