Skip to content

Instantly share code, notes, and snippets.

@brablc
Created September 15, 2011 14:05
Show Gist options
  • Save brablc/1219314 to your computer and use it in GitHub Desktop.
Save brablc/1219314 to your computer and use it in GitHub Desktop.
mscreen - write into multiple screens at once
#!/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
#!/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