Jan 23, 2016

Mac OS X: launching an application from the terminal window

Ever wondered how you can start an application from the terminal command line in Mac OS? Graphical applications come packaged (typically with the .app extension). Besides the actual binary executable, the package contains any additional resources (e.g. libraries) that the application might require to run. The executable can be found in the /Applications/NameOfApp.app/Contents/MacOS folder.
It is however not advisable to launch it with this fully qualified path, as the program wild be started as a child process to your current terminal session. If you close the terminal window, the application will be terminated, too. Mac OS'es resume features might also be troubled with this approach.
There is however a utitliy named open that you can use for this purpose. I am for instance using the Atom editor for simple edits, and I have added a corresponding alias in my .bash_profile file in order to be able to launch it while working the terminal command line:
alias atom='open -a Atom'
The above open command mimics launching the application from within the graphical user interface.

No comments:

Post a Comment