I\'ve been Googling for a while looking for a simple way to do this, and I can\'t find one.
I have a custom terminal environment set up (zsh) with various aliases and fu
OK, so as is my way I am answering my own question again (well at least getting close to answering it anyway)
I have found a less verbose script to the one above (courtesy of Dan Benjamin) that seems to do the trick, although both scripts output a similar error before successfully completing. I have dealt with that by adding clear to the end of the script so that's no big problem.
I say that I have nearly solved my own problem because my objective was to find a way to accomplish this with the Apple-t key command that has been burnt into my muscle memory as the shortcut for a new tab in anything, thanks to countless hours in various web browsers. The best I can manage with a script such as Dan's is t-return which isn't the biggest difference, but big enough that I will be slightly irked every time I issue said command. I know, I should let it go..... But I can't, which is probably how I got into this mess in the first place, endlessly fiddling with computers. I digress, here is the script I am using:
#!/bin/sh
# Make a new OS X Terminal tab with the current working directory.
if [ $# -ne 1 ]; then
PATHDIR=`pwd`
else
PATHDIR=$1
fi
/usr/bin/osascript <
For completeness here is the error that gets spat out on the soliciting window if the trailing clear is omitted:
2009-10-20 01:30:38.714 osascript[20862:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tab 2 of window id 13942