I would like to have an item in the /Applications
folder that will open a new terminal window and run a specific command inside. How can I create this?
5 Answers
Create a new text file starting by
#!/bin/bash
and followed by your command#!/bin/bash echo 'Hello world'
Save with
.command
or.tool
as extension likemyEchoCommand.command
- Set execute right on this file with
chmod
command. - You just have to double-click this newly created file, Terminal will open and execute it's content.
Use Automator which Apple made part of OSX..
Create a workflow
In the workflow choose Utilities/Run Shell Script
Save as changing the File format to application - this will give a .app and choose the directory to be /Applications
EDIT to show the output. The workflow need sto consist of three steps
1) Text->Create New TextEdit Document
2) The Utilities/Run Shell Script
3) Text->Set Contents of Textedit Document
-
... and copy the resulting
.app
file into the folder/Applications
so it shows up where you (op) said– PetruzaCommented May 11, 2011 at 17:41 -
It's not clear to me how to cause the Automator workflow to open a new terminal window and run the command inside. Can you please elaborate on this?– ændrükCommented May 11, 2011 at 19:06
It can be used to create native, flawlessly integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl and Python programs.
Most people just put a shell script in whatever folder they desire and make is executable with chomd a+x
. You can use any old text editor and save the script as plain text. If you don't want to store the scripts in the /Applications
folder that's fine as well - it won't matter where you store them as long as they are readable and executable.
If you save the file as script.bash.command
- you won't have to associate terminal with .sh or .bash since it runs command files by default. When the script ends, the terminal session is logged out, so it will run the command and exit letting you see the results but if you want a working window you have to open another window in terminal.
Will that work for you?
Maybe you need something like DTerm? It's just a shortcut away to invoke and freely installable from the AppStore. You can include it in your startup items and use it when you need it. If your command gives some output DTerm shows that in a floating window.
-
-
I know that, but if you check the 2nd comment to the question you would think that the person needs to see an outcome of a command not a program/app. In that light this solution could be useful without running an Automator script. Commented May 11, 2011 at 19:04
/Applications
folder. (no trolling or patronizing intended)