As was mentioned in the question here, the open command in 10.6 now has an args flag, so you can call:
open -n ./AppName.app --args -AppCommandLineArg
As was mentioned in the question here, the open command in 10.6 now has an args flag, so you can call:
open -n ./AppName.app --args -AppCommandLineArg
In OS X 10.6, the open command was enhanced to allow passing of arguments to the application:
open ./AppName.app --args -AppCommandLineArg
But for older versions of Mac OS X, and because app bundles aren't designed to be passed command line arguments, the conventional mechanism is to use Apple Events for files like here for Cocoa apps or here for Carbon apps. You could also probably do something kludgey by passing parameters in using environment variables.
How do I run my C program in Mac Terminal?
How to use terminal and commands on mac
How to create a keyboard shortcut to run file in terminal?
How to run Javascript on a mac?
Videos
Open Terminal, type in sh /path/to/file and press enter.
Faster is to type sh and a space and then drag the file to the window and release the icon anywhere on the window.
Alternatively, you could also do
cd /directory/with/executable
chmod +x executable # only required if your file is not already executable
./executable
which will also run the executable file with its specified shell (if specified in the shebang #!/bin/(shell)
This answer is obsolete.
Refer to other answers for modern Mac OS.
Here's my best solution: Create an Applescript with:
do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -P default -no-remote & killall Firefox.app"
And save it as an application.
You can put whatever application with whatever args in the first part. The part after the & needs to kill whatever you have named your script + .app. You'll see the script app flash up in the dock, but it will then disappear.
Note: The script will not work properly when run from Script Editor, only when run from the script application you have created.
Starting in OS X 10.6.2, the open command can pass arguments to the application it opens by way of the --args flag. An AppleScript to use it looks like this:
do shell script "open -a /Applications/Firefox.app --args -P default -no-remote"
That should give you all the behavior you want.
I recommend you use:
alias atom="open -a Atom\ Nightly"
The open -a $APPNAME command is smart about finding GUI apps based on their user-visible name.
macOS GUI apps are packaged as ".app bundles" or "packages", which are actually special directory hierarchies. A traditional Unix shell like bash or zsh expect the file you invoke to be executable; either a shell script or an executable machine code binary file; you can't execute a directory. So if you want to invoke a GUI app from the command line, you must invoke its actual executable buried inside the .app bundle, which would usually be something like this:
/Applications/Atom\ Nightly.app/Contents/MacOS/Atom\ Nightly
The reason you were getting that permission denied error was you were asking your shell to execute a directory, which is not executable (the "x" permissions bit on directories means it's traversable, but that's beyond the scope of this question).
Note that launching GUI apps from a shell only works when the shell lives inside a GUI session, such as a shell running within a terminal emulator app. It doesn't work from a shell that's not associated with any GUI session, such as when you've SSH'd into the Mac from some other machine.
Why not use Spotlight?
Cmd/Space, start to type, hit Return when the correct name is selected [which you can do with arrows if you don't want to click.] If you don't have many things with 'atom' in the name, you're probably down to 4 or 5 keystrokes to open it from anywhere in the OS.
I don't have Atom Nightly, but here's an example for FaceTime, which everyone has. 5 keystrokes from start to finish, Cmd/Space, F, A, C, Return.

No pre-programming or aliases required. Using the system for what it's made for, rather than constructing elaborate hacks which take longer & need doing for every app.
I'm trying to run a file that I made in the Mac Terminal. How do I do this? I don't really understand how to. I wrote my file in emacs in the terminal, if that makes sense/helps.
Hi just got a mac this year and im very interested in learning how to use terminal and commands through thier I have no programing experience do any of you know where I could learn to use Terminal