Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a command in a new Mac OS X Terminal window

I've been trying to figure out how to run a bash command in a new Max OS X Terminal.app window. As, an example, here's how I would run my command in a new bash process:

bash -c "my command here" 

But this reuses the existing terminal window instead of creating a new one. I want something like:

Terminal.app -c "my command here" 

But of course this doesn't work. I am aware of the "open -a Terminal.app" command, but I don't see how to forward arguments to the terminal, or even if I did what arguments to use.

like image 631
Walt D Avatar asked Jun 12 '09 22:06

Walt D


People also ask

How do I run a command in new Terminal?

You can also press Alt+F2 to open the Run a Command dialog. Type gnome-terminal here and press Enter to launch a terminal window. You can run many other commands from the Alt+F2 window, too. You won't see any information as you would when running the command in a normal window, however.

How do I open a Terminal window in Mac OS X?

Open TerminalClick the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal. In the Finder , open the /Applications/Utilities folder, then double-click Terminal.


1 Answers

one way I can think to do it off the top of my head is to create a .command file and run it like so:

echo echo hello > sayhi.command; chmod +x sayhi.command; open sayhi.command 

or use applescript:

osascript -e 'tell application "Terminal" to do script "echo hello"' 

although you'll either have to escape a lot of double quotes or not be able to use single quotes

like image 52
cobbal Avatar answered Sep 18 '22 17:09

cobbal