3

I've been searching and searching for a process on OS X that creates something as simple and elegant as Windows shortcuts. At the user's direction on install, I need to create a shortcut-like item that contains command-line arguments to the installed application, and that can be placed in the Dock like a normal application with an icon.

I have found that I can do exactly what I want to do from the Automator application: Select "Application", enter the command line, save it, copy and paste the icon, etc. However, the process is all manual. I can't do that in an automated install of the application.

I cannot seem to find a way to do these Automator steps from the command line (which would be required during installation of my application) using something like Apple Script (osacript).

In what is more of a hack than an actual solution, I have also found that I can manipulate the installed application's Info.plist file, replacing the CFBundleExecutable value with a shell script that does an "open -a ... --args ...", but this requires some rather unbelievable hoops just to make it work.

I am also aware of Finder aliases (Can I create a Desktop Shortcut/Alias to a Folder from the Terminal?), which might also solve the problem, however there doesn't appear to be a way to add command-line arguments.

Everything seems to require either user interaction, or hackish file moving and manipulation. So the question is: How do I achieve this simple and elegant Windows-like shortcut mechanism under OS X without requiring these things?

Just to be clear, launching the application with arguments is not a problem (e.g., "open -a <apppath> --args ..."). Creating something that the user can manage like an application (i.e., Dock) that actually launches the app with arguments doesn't seem to be something very easily accomplished under OS X.

  • 1
    See this answer: apple.stackexchange.com/questions/260467/… – Allan Jun 2 '18 at 15:10
  • 1
    Thanks for the link, Allan. I did not know about ".command" files. However, this is yet just another partial solution to this problem. I can create the ".command" file on the Desktop, but it displays the ".command" extension, it will not Dock (like an alias or an Automator "Application"), and it flashes a terminal window when you double-click on it to launch. This is really not much different that just creating a regular shell script. – Bob H. Jun 2 '18 at 18:52
  • 1
    It doesn't need to have the .command extension. It could be .sh or nothing at all. Bash is a flexible thing. – Allan Jun 2 '18 at 19:42
  • Then I'm not sure what adding the ".command" extension to the script even achieves here (according to the sited article). I know how to write Bash scripts, and I can achieve what I need from there. However, that was not the gist of my post. My question was about Windows-like shortcuts that behave like applications on the OS X desktop. I'm guessing at this point that it's simply not possible to automate this process under OS X like you can under Windows. – Bob H. Jun 5 '18 at 18:41
  • A Windows shortcut is nothing more than a file with a command on it. In macOS (and any *NIX for that matter), everything is a file, so if you want a "shortcut" you need to create a file with the commands you want to execute. So, can you get what you are looking for in macOS like in Windows? Yes. Is it the same way Windows does it? No. macOS is not Windows. – Allan Jun 5 '18 at 18:58

You must log in to answer this question.

Browse other questions tagged .