Last active
September 23, 2020 01:06
-
-
Save kirelagin/bbb182e6102116c3d984fd630e24abe4 to your computer and use it in GitHub Desktop.
Mirror a tmux session in two terminals.
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
#!/bin/sh | |
# SPDX-FileCopyrightText: 2018 Kirill Elagin <https://kir.elagin.me/> | |
# SPDX-License-Identifier: MPL-2.0 | |
### | |
# | |
# Mirror a tmux session in two terminals. | |
# | |
# This script is ideal for all kinds of demonstrations, lectures, talks, etc. | |
# The idea is that you connect a projector (or a large display) as a second | |
# screen to your laptop, open two terminal windows – one on your laptop’s screen, | |
# other on the projector, and then you “tie” them together with a tmux session. | |
# | |
# Use: | |
# | |
# * Download this script and put it on your $PATH | |
# (or use its full path when invoking it) | |
# | |
# * Open two terminal windows. | |
# | |
# * Run `tmuxshow` in one window. Then run `tmuxshow` in the other. | |
# | |
# * All set! Now both terminals will always show the same content. | |
# | |
# Dependencies: | |
# | |
# * tmux | |
# | |
# e.g. `nix-shell -p tmux | |
# | |
# https://gist.github.com/kirelagin/bbb182e6102116c3d984fd630e24abe4 | |
### | |
command -v &> /dev/null || { echo "Need tmux"; exit 1; } | |
read -r -d '' initCmd << EOM | |
set default-command /bin/zsh; | |
set default-terminal screen-256color; | |
set status off; | |
set escape-time 0; | |
set bell-action current; | |
set renumber-windows on; | |
new-window; | |
kill-window -a; | |
EOM | |
tmux -f /dev/null new-session -s tmuxshow \; $initCmd 2> /dev/null || tmux -f /dev/null attach-session -t tmuxshow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment