Skip to content

Instantly share code, notes, and snippets.

@sirkkalap
Forked from kissgyorgy/tmux_takeover.sh
Created May 29, 2014 10:04
Show Gist options
  • Save sirkkalap/117da6e2794451a71b68 to your computer and use it in GitHub Desktop.
Save sirkkalap/117da6e2794451a71b68 to your computer and use it in GitHub Desktop.
# 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