iTerm 2 is a powerful replacement for Terminal.app and it has support for AppleScript. You can use AppleScript to tell it to run commands in a new tab or window.
For example, let's make a little AppleScript action that's callable. Enter the following in to the AppleScript Editor:
on run argv
set AppleScript's text item delimiters to {" "}
tell application "iTerm"
make new terminal
tell the current terminal
activate current session
launch session "Default Session"
tell the last session
write text argv as string
end tell
end tell
end tell
end run
and then save it as a Script in ~/Documents/Scripts/run-in-new-iterm-tab.scpt
. We can now call it from the command line like so:
/Users/ian
> osascript ~/Documents/Scripts/run-in-new-iterm-tab.scpt ls ~/Documents/Scripts
/Users/ian
>
and I get a new tab in my iTerm session with:
Last login: Thu Aug 28 22:17:17 on ttys003
ls /Users/ian/Documents/Scripts
/Users/ian
> ls /Users/ian/Documents/Scripts
edit keep_drives_alive.sh run-in-new-iterm-tab.scpt touch-in-order.pl
find-missing-itunes-files.pl keep_drives_alive.sh~ start-utorrent.scpt touch-in-order.pl~
/Users/ian
>
Which is not too bad. There are some refinements you can make to the AppleScript like maintaining the current working directory when you call the command. But that's gets you in the ballpark.
If you use this hint in this question you can turn the whole thing in to a bash-wrapped script that's even easier to execute:
#!/usr/bin/env osascript
on run argv
set AppleScript's text item delimiters to {" "}
tell application "iTerm"
make new terminal
tell the current terminal
activate current session
launch session "Default Session"
tell the last session
write text argv as string
end tell
end tell
end tell
end run
Save that to a spot on your PATH
and make it executable and then you only need to run:
run-in-new-iterm-tab ls ~/Documents/Scripts
to get it to work.
$EDITOR
variable in your~/.bash_profile
or the like. That said, it is possible with nano.man
. Being able to send a manpage to a new tab would be a godsend.