Launch Mac App From Terminal

Feb 01, 2007  Opening Mac OS X Applications from the Command Line. The Terminal command to launch OS X gui apps is appropriately called ‘open’ and here is how it works at it’s most simple: open -a ApplicationName. That will open the defined app named “ApplicationName”. But open is much more powerful than that. If you’ve gotten some malware installed on your Mac—if, for example, you’re seeing bad pop-ups within your browser or you note that you’ve got one of the not-helpful-or-necessary. The Windows Terminal is a modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and custom themes, styles,.

In some flavors of Unix, you feel as if you've been cast into an alternate universe when you open a terminal window and work on the command line. But with OS X and its Darwin core, there's often an elegant integration between the two. In this how-to I'll show you how to launch an OS X app from the command line with the open command.

[Note: A little bit of prior UNIX experience will be helpful here.]

Mac Terminal Application

First off, I will admit this technique is fairly geeky. In my [Mac] OS X career, I've only used this trick a handful of times. However, it's so darn cool and charming that one just aches to use it at any opportunity.

Actually, upon reflection, there are some useful scenarios for this technique.

  1. The Finder acts up, a terminal window is already open, and you'd like to be able to launch a GUI app that might help you diagnose the problem.
  2. You're a UNIX professional, live and breathe the command line, but you'd rather use a GUI text editor for coding instead of the raw and ugly vi or Emacs editors.
  3. You're writing, say, a Perl or Python script, for another user and, at some point in the script, you'd like to launch a GUI app that carries the workflow forward.
  4. You want to quickly run a utility with admin privileges without the restriction of the account you're logged into. See, for example, 'How to Find & Recover Missing Hard Drive Space.' In that case, you must bypass the open command and drill into the Package Contents to run the app with sudo and admin privileges. But I've digressed.

The Man Page

The terminal app is in the Utilities folder—which is found the Applications folder. Launch it now. The BSD UNIX command we'll be using is open. Below is the manual page ('man' for short), shown by typing:

I've printed most of the man page for the open command here for your perusal, but I'm not going to explore every argument. And feel free to jump right to the examples below to whet your appetite.

For this limited how-to, one interesting way to use the open command in this context is to use the [-a] option. Some other useful variations and arguments are in the examples below.

Typical Examples

Here are some short and sweet examples of the open command with the -a, -e, and -t arguments. They're easy to try. [If you don't have BBEdit installed, use any other favorite a text editor in /Applications.]

Open Doors

These are just a few of the cool things you can do on the command line with the open command. To keep things simple, I haven't delved into creating a search path or other Unix tricks like aliases. All that's been left for you to explore on your own.

I think this is one of the neatest tricks in OS X.

Launch Mac Os X App From Terminal

__________________

Launch button via Shutterstock.

When you download and run apps on Mac OS from not identified developers it's required to trust them by Gatekeeper. Codesign terminal tool allows you to manually sign any app on your MacBook. Using this technique you can for e.g. sign Adobe Zii app. Apple recently revoked TNT’s certificate.

Open apps from anywhere in Gatekeeper

Usually when you will try to run an app downloaded from a different source then AppStore, the system will disallow you to open the application. The one solution is to enable the ability to open apps from anywhere in Gatekeeper using a terminal command. Launch Terminal and enter the code below.

Click enter and type the administrator password to execute the command. Open the crashed app and if it's not running navigate to System Preferences→ Security & Privacy → Allow apps downloaded from and select Anywhere or allow to open the specific app that will show in the selection menu.

Mac Os Launch App From Terminal

Add an app to quarantine on MacOS Catalina

If it does not work on Catalina and app is flagged as “damaged” even with Gatekeeper disabled (sudo spctl –master-disable) use this command.

Sign .app with Codesign

When you launch an app and it will quit unexpectedly on Mac OS a problem report window will display problem details and system configuration. If you find in the report the message 'Termination Reason: Namespace CODESIGNING, Code 0x1' it means that the app certificate was revoked.

There is a quick solution to sign any .app on macOS installing free codesign tool. Open Terminal App and execute the code to start the download and installation process of Xcode and the command line developer tools from the AppStore. Launch Xcode at least once to agree to the license.

Using Terminal Mac

Run application from terminal mac

To sign an .app file launch the Terminal and execute codesign with following parameters. You can easily drag and drop the .app from Finder to Terminal allowing you to paste the file located path. After the .app is signed you will have an option to run it as any other regular application.

Run Application From Terminal Mac

Codesign available parameters