Well, I've written a script that kind of solves this problem, and adds some extra functionality that I find really helpfull.
#!/bin/bash
COMMAND=$1
if [ -z "$1" ]
then
COMMAND="cd $(pwd)"
fi
/usr/bin/osascript 2>/dev/null <<EOF
activate application "Terminal"
tell application "System Events"
keystroke "t" using {command down}
end tell
tell application "Terminal"
activate
do script "$COMMAND" in window 1
end tell
return
EOF
First let's take a look at the applescript part (that's the part between EOF). Applescript code is very readable, but what it does is to open a new tab in the terminal, and then run the code in the COMMAND variable in that newly open window.
Then, there is that little bit of bash code, that assigns the string passed as an argument to be run or, if none is provided, it changes the directory to the one you were in.
So, you can open a new tab, by calling the script or, and this is the very handy thing for writing other scripts, open a new tab and run code in that tab, by calling the script with the string as an argument.
1 comment:
http://iterm.sourceforge.net/
Much better terminal, just drag and drop the folder on the iTerm icon/window and it opens... also has lots of more features like cmd+c/v, better readability and so on...
The only thing it's worst is the icon but you can easily copy the icon from Terminal with 'Get Info' and copy on the icon :)
Post a Comment