10

I'm trying to open an app in the background from the Terminal by using the -g or --background flags like so

open -g -a Franz

Unfortunately, the app isn't opening in the background. I've also tried the j flag, which is supposed to hide the app, according to the help:

Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
Help: Open opens files from a shell.
      By default, opens each file using the default application for that file.  
      If the file is in the form of a URL, the file will be opened as a URL.
Options: 
      -a                Opens with the specified application.
      -b                Opens with the specified application bundle identifier.
      -e                Opens with TextEdit.
      -t                Opens with default text editor.
      -f                Reads input from standard input and opens with TextEdit.
      -F  --fresh       Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
      -R, --reveal      Selects in the Finder instead of opening.
      -W, --wait-apps   Blocks until the used applications are closed (even if they were already running).
          --args        All remaining arguments are passed in argv to the application's main() function instead of opened.
      -n, --new         Open a new instance of the application even if one is already running.
      -j, --hide        Launches the app hidden.
      -g, --background  Does not bring the application to the foreground.
      -h, --header      Searches header file locations for headers matching the given filenames, and opens them.

The app opens in the foreground as if the I had simply called

open -a Franz

Any idea why this doesn't work and an alternative?

  • I've tested it with several applications on macOS 10.12.5 and it works well. The problem is maybe related to the Franz application. – Ortomala Lokni Jun 16 '17 at 20:34
  • I’m having the same issue, where certain apps don’t respect the flags. I can open Messages in the background, but trying to open Books with the same flags opens it in the foreground. Annoying that Apple’s own apps don’t work with this… – elstgav Feb 9 at 19:52
5

If you call the command open with --hide it works (at least in Sierra MacOs). For instance

open -a /Applications/Skype.app --hide 

Also, the j flag helps some

open -gj -a /Applications/Skype.app
| improve this answer | |
  • Unfortunately it seems that this answer does not work for more recent versions of MacOs, as Catalina – Galuoises Apr 15 at 16:40
4

As of writing (10.14.3 Mojave), the correct answer is:

open -a /Applications/Skype.app -gj

If you do

man open

you can see that

-g Do not bring the application to the foreground.

-j Launches the app hidden.

| improve this answer | |
  • Thanks. Not on Mojave yet, but will keep in mind for when I upgrade. – willlma Mar 21 '19 at 19:36
  • Does not work for me (10.14.6 Mojave) – milushov Dec 30 '19 at 14:35
  • That doesn’t really address the question—they’re trying to open the app in the background, not hidden. – elstgav Feb 9 at 19:53
  • 1
    Works for me with macOS 10.14.6 (18G3020) for NetNewsWire.app: The app is launched and immediately hidden without the screen flickering or something like that. – NSSynapse Mar 6 at 11:22
1

you have to specify the J before the a

example: open -ja /Applications/Calendar.app

| improve this answer | |
  • OP states very clearly that the -j flag does not work. – IconDaemon Apr 7 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .