After switching from Unix, there’s been something missing from my OSX environment, and I had an idea for a drag-n-drop utility that could make the OSX environment a little easier.
I love Mac OSX for my desktop environment, but I do a lot of work in Unix shells on remote servers. Specifically, every time I’m on the network I’ll have at least two terminals open to our co-op Unix server, each running a multi-headed screen looking at either my personal mail in Pine (yes, I know, I need to switch to Mutt) or logged into a very primitive communal chat machine (we all use a derivative of “wall”). Under Unix, a simple script could execute a couple of Xterms with specific -geometry arguments. Under OSX, doing the “new window/new window/position each/ssh twice” dance every time I opened up my computer was a pain in the butt. When whining about this online, some friends’ solution was simply “And Steve created AppleScript”.
Every OSX install should include the Script Editor. I believe there are much more advanced tools on the Developer’s CD, but I’m just doing some quick hacks right now. Here’s the script:
tell application "Terminal" do script with command "ssh radix" do script with command "ssh radix" tell window 3 set custom title to "radix mail" set position to {1, 1} end tell tell window 2 set custom title to "soda" set origin to {1, 1} end tell end tell
I’m sure any old Unix geek will be able to figure out what bits to replace to do whatever you might want.
Now, thanks to LaunchBar, I can execute a very quick Cmd-Space, type “radix”, and hit Enter. Boom, done. I leave Terminal running all the time, even if I close all windows.
OK, now for the new idea. Since I want to transfer files to my account on radix pretty often (posting the the web or what not), I wanted to create an icon that I could just drop files on to and have then securely copied over. I’ve been thinking about setting up a personal WebDAV server on radix, but there are locking and compatibility issues with Apache’s mod_dav implementation (are there any DAV servers that are more compatible with other Unix services?), then I thought about using Fugu to connect via SFTP, but I didn’t see an easy way to create an automatic drag-n-drop icon.
My friend Mark reminded me a of tool that could turn a Unix script into a droplet on OSX, so I could just scp something over. Today, in my Mac OSX Hints RSS feed there was this hint. Basically, it describes an AppleScript app that you can drop items on to and it will execute a script. Here’s the code as I’m using it:
set filecount to 0 on open filelist repeat with i in filelist set filecount to 1 tell application "Terminal" set filename to do shell script "perl -e \"print quotemeta ('" & POSIX path of i & "');\"" do script "scp " & filename & " radix:drop/; exit" end tell end repeat end open
(The “set filename” with the perl command should all be one line)
So I saved this as radix-drop.app and changes to icon to set it on my desktop. This is a bit of a kludge, as it pops up a Terminal window to show progress — it would be nice to find a real app that has a nice progress bar — but it’s fine for what I want.
Still looking for the ideal Unix-shell compatible network file sharing solution to the OSX desktop (and sure, Windows). Any ideas?
This is only tangential, but you should try iTerm – I find it a _WHOLE_ lot better than plain old terminal. One word for you: Tabs!
Forgot one thing re: iTerm – the titles on the tabs will change color if there is any activity occuring in them – ie the title of your radix tab will change color when you get new mail…
More on topic here – take a look at http://www.sanbeiji.com/blog/article.php?articleNum=61 – he talks about Interarchie’s SFTP Disk functionality.
Um, in place of the overhead of making all those applescripts just for your saved terminal sessions, check out the “save” features in Terminal.app…
Actually, I wrote about this in more detail awhile ago. The one thing I didn’t mention at the time is putting that App Support/Terminal folder into your launch bar prefs, and then those files can be launched that way, too. This has the advantage of allowing you to customize a lot more about the terminal session. Check out what’s in that file that you can manually edit, and I think there are more options that aren’t written in the default exported file.
Then, if you still want one command to launch both windows, just make an applescript to open each of those windows.
Benjy tried to paste this link in, but didn’t realize that MT would strip his comments: http://www.linkstew.org/noid/1329.html