-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
As a System Administrator, I operate on clusters or groups of machines and I often need to connect to them using SSH. I then fire iTerm2 (the best replacement for the default Terminal.app), and either open as many tabs or split my screen as many times as the number of hosts I need to connect myself to. One of the recurring qualities that you’ll find to a System Administrator is that they all will spent one shot a little time to find out how to automate boring/repetitive things, and this is what I just did in order to connect myself faster than spending 3 minutes to establish a connection to all the concerned hosts.
Working in a single window on different things is something I do all day long. iTerm2 just needs me to press
cmd+d to split my current session vertically, or
cmd+shift+d to split horizontally. What this script will do is to fire iTerm2, connect to the first server, fire
cmd+d (as I rather prefer having my screen splitted vertically) and connect to a second server. You will be able to add several other divisions by repeating the steps or changing what the scripts launches to whatever you prefer.
launch "iTerm" tell application "iTerm" activate set myterm to (make new terminal) tell myterm launch session "web servers" set number of columns to 200 set number of rows to 60 tell the last session to write text "ssh server1.domain.tld" tell i term application "System Events" to keystroke "d" using command down tell the last session to write text "ssh server2.domain.tld" end tell end tell
Let’s do the same thing that before, but instead of splitting the screen, we’ll just fire a new tab
launch "iTerm" tell application "iTerm" activate set myterm to (make new terminal) tell myterm launch session "web servers" set number of columns to 200 set number of rows to 60 tell the last session to write text "ssh server1.domain.tld" launch session "session2" tell the last session to write text "ssh server2.domain.tld" end tell end tell
As double-clicking on a
.applescript file just launches the Applescript editor, it’s not very convenient to click on
execute each time. What we need is our script to behave like a normal application. This can be achieved with Automator. This part is pretty obvious, launch Automator.app, select
Application and choose
Lauch Applescript. Save and you’re good to go.
-----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIcBAEBCAAGBQJW5eRHAAoJEBeKS2x6xuR7+gsP/0v5sAzpAgs4cz7LHth9GlkS HgIHGkzCjLXFNdu4o/Vo/nzPTe9hcTVe3IJYpQw11OHyYkF7LYHFYQ/Vy/juKEWt h6RUWSCk2STtPcRcKZkO4qvy3W4VR9m+C2u+oVgAPgYF6RygpbnGQFXtbKyZhSNE qYGG0JeOV2d+k5pUazfDdYsAT88dauxPuB1PSolzfPRnFnb+y+srYdtQs6F865fV DSD+kiPR95EXSoMeq6hyNSm42sLy7owtEMTPAJkzZLEub9dSnIcrZoxlMrQnNSff oIGGaoaAiJCy6pK/rHdYTAyVXE7ByZkYkNrJsSnkBRR58rXwzQN/Thaj8JzFE5WI TQqX4s96lyk6y9UjNSRQ37BlR2hSQsmoeSvGuHHk0qcYvz/E2pM/TjZHUC0X0h0j BVllTzOlFoarSGwK5ojaQpcMF/2jLHg6FO5duqXsVeZN2vOxLq2avjMtrQW7ip9h zXyN/qICmpDjlSB+UvFgyMyVZnh9MGNyFFzjxONdaiP34g+mX1Gemc/8ynCKHCgO tY+G0MByHb2S3x0zWJF6svor0XFHVRf24kNLO56Q6/eVu7Ilnm92D3EMzx4f8rFB 5QV4XX6dukcKgN+X0KX6HMgAmOabMl405Az9KjDyqeDWVijsUpw7lVP5pL0yvFEg kODCFZss70U6sKnL8Fo5 =XSc+ -----END PGP SIGNATURE-----
Created the 2012-01-26