MacOS – generic approach to finding the correct name to run an app from the command line

bashcommand linemacos

Whenever I am not in a browser or in my text editor, most of my time on my mac is spent on the terminal.

What's a quick, generic way to figure out how to run a gui program from the bash shell? It seems like we always need to run around and find out that program xyz can be called as 'abc'.

For example, Sublime Text's is 'subl', Kaleidoscope is 'ksdiff'. Great, but you need to look these up for each and every program. And there are lots of identical questions, about Finder for example.

What is the best Mac approach to figuring out the command line "alias" for an any app? Can I make use of the Activity Monitor if the program is open? Do I have to go nose around in the Applications folder? If so, how can I tell the "command line alias file" from the others?

Or can I use "ps aux" in bash? For example, on Linux or on Windows, "foo.exe" in the list of processes means that you could just type "foo.exe" to launch that program. But Sublime shows up as Sublime Text, not 'subl', so don't think that would work.

Best Answer

Bot Sublime Text and Kaleidoscope are special cases as they install either a helper utility or themselves somewhere in your $PATH.

The easiest way to open any application from /Applications is to run

open -a APPNAME

in Terminal, e.g.

open -a Pages       # opens Pages
open -a "App Store" # opens the App Store