I'm a heavy UNIX user, so I find myself frequently sshing to other hosts under MacOS X. This leads to having to open Terminal windows, type "ssh hostname" and have a bunch of windows, all with the same or similar titles, logged into several hosts. This can be inconvenient at best once you find yourself logging into more than a couple of hosts.
I discovered yesterday that Terminal.app supports .term files -- basically description files that when launched, give you a Terminal.app window with those specific settings. So I went to work and found an interesting way to organize multiple terminal sessions.
Check out this script, called "s" in my ~/bin directory:
#!/bin/sh cat ~/"Library/Application Support/Terminal/Generic.term" \ | sed -e "s/HOSTNAME/$*/g" > /tmp/sshterm.$$.term ( open /tmp/sshterm.$$.term && sleep 1 && rm /tmp/sshterm.$$.term ) &
This will open a Terminal.app window that is ssh'ed into the host provided as the script's first argument, IE:
s zorin@sarabi.zorin.org
Neat, huh? There is one more piece, though: Generic.term
Here is the one I use; just download it and drop it into ~/Library/Application Support/Terminal. You can generate .term files by saving the configuration of any active terminal window by using File -> Save as... in Terminal.app.
As you can see, the "s" script uses sed to replace HOSTNAME in the term file with the hostname you want to log into, then "open"s the term file and deletes it one second later, to give Terminal.app a chance to read the file before it goes away.
My particular .term file also sets the title of the window to be the hostname you connect to, and has a green-ish color scheme. You can, of course, change this to your liking.
This is a useful trick I'm sure all UNIX-using Macheads will like. I'm just learning about .term files now so as I discover more tricks I'll surely post more.
Recent comments
1 year 40 weeks ago
1 year 42 weeks ago
1 year 44 weeks ago
2 years 47 weeks ago
2 years 48 weeks ago
2 years 48 weeks ago
2 years 48 weeks ago
2 years 50 weeks ago
3 years 4 weeks ago
3 years 9 weeks ago