Executing Shell Scripts from the OS X Dock?

前端 未结 9 1729
自闭症患者
自闭症患者 2020-12-22 17:15

How do I set up a shell script to execute from the Mac OSX dock? It seems that simply creating a shortcut will open the file in my editor. Is there a flag I need to set som

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 17:56

    If you don't need a Terminal window, you can make any executable file an Application just by creating a shell script Example and moving it to the filename Example.app/Contents/MacOS/Example. You can place this new application in your dock like any other, and execute it with a click.

    NOTE: the name of the app must exactly match the script name. So the top level directory has to be Example.app and the script in the Contents/MacOS subdirectory must be named Example, and the script must be executable.

    If you do need to have the terminal window displayed, I don't have a simple solution. You could probably do something with Applescript, but that's not very clean.

提交回复
热议问题