Skip to content

Instantly share code, notes, and snippets.

@curi1119
Last active August 29, 2015 14:02
Show Gist options
  • Save curi1119/05b9416c9435b5efbfa4 to your computer and use it in GitHub Desktop.
Save curi1119/05b9416c9435b5efbfa4 to your computer and use it in GitHub Desktop.
cubewatch.rb
# -*- coding: utf-8 -*-
def cmd(target, pane, remote_command)
command = "tmux send-keys -t:#{target}.#{pane} #{remote_command} C-m"
system command
end
def window(window_name)
system "tmux new-window -a -n #{window_name}"
end
def cube(size)
size.times do |i|
system "tmux split; tmux select-layout tiled"
end
end
def usage
puts "Usage: $0 \'command --options arg1 arg2 ...\' host1 [host2 host3...host9]"
end
if ARGV.size < 2
usage
exit 1
end
remote_cmd = ARGV.shift
hosts = ARGV
pane_size = hosts.size
window_name = remote_cmd
window(window_name)
cube(pane_size)
hosts.each_with_index do |host, i|
cmd(window_name, i, "ssh #{host}")
cmd(window_name, i, remote_cmd)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment