Is there a way of opening a new terminal from the command line, and running a command on that new terminal (on a Mac)?
e.g., Something like:
Terminal -e ls
where ls is run in the new terminal.
|
Is there a way of opening a new terminal from the command line, and running a command on that new terminal (on a Mac)? e.g., Something like:
where |
|||||
|
This opens a new terminal and executes the command "echo hello" inside it. |
|||
|
This works, at least under Mountain Lion. It does initialize an interactive shell each time, although you can replace that after-the-fact by invoking it as "macterm exec your-command". Store this in bin/macterm in your home directory and chmod a+x bin/macterm:
|
|||
|
|
You need ruby 1.9 or you will need to add line I named this script |
|||
|
|
|
I would do this with AppleScript. You can streamline it by using the osascript command. Your script would be something like:
If you're only going to ever access it in terminal, then you can omit all but the middle tell statement. If you want a new window instead of a new tab, replace the t keystroke with n. I'm not an experienced enough AppleScripter to know how to get command-line arguments and then retype them in the new window, but I'm sure it's possible and not too difficult. Also, I think this works and I'm not able to test right now, but I'm pretty sure you can start a shell script with some variant on #!/usr/bin/osascript -e and then save it as an executable however you want. Which, at least in my head, would make it possible for you to type something like $ runinnewterm ls /Applications |
|||
|
|
|
You can do it in a roundabout way:
Shell scripts which have the extension Slightly twisted, but it does appear to work. I feel sure there must be a more direct route to this (what is it you're actually trying to do?), but it escapes me right now. |
|||||||
|