Created
September 15, 2011 14:05
-
-
Save brablc/1219314 to your computer and use it in GitHub Desktop.
mscreen - write into multiple screens at once
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/bash | |
if [ $# -lt 1 ]; then | |
echo "Usage: mscreen [hostname1] [hostname2] ..." | |
exit 1 | |
fi | |
TMPFILE="/tmp/mscreen-$$" | |
echo "source $HOME/.screenrc" >$TMPFILE | |
CNT=0 | |
for HOST in $*; do | |
echo " | |
screen -t $HOST ssh $HOST | |
split | |
focus | |
select $CNT | |
stuff \"export TERM=xterm\\012\" | |
" >>$TMPFILE | |
CNT=$((CNT+1)) | |
done | |
echo " | |
screen -t sys mscreen-stuff | |
select $CNT | |
resize = | |
" >>$TMPFILE | |
screen -c $TMPFILE | |
rm -f $TMPFILE |
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
#!/usr/bin/perl | |
use Term::ReadKey; | |
use strict; | |
my $key; | |
my $window = $ENV{'WINDOW'}; | |
ReadMode 'cbreak'; | |
while ($key = ReadKey(0)) { | |
print $key; | |
# Send from the highest window - to handle properly exit or ^D | |
for (my $i=$window-1; $i>=0; $i--) { | |
system("screen -X at $i stuff \$'$key'"); | |
} | |
} | |
ReadMode 'normal'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment