macos Mac OS X - 从桌面 GUI 运行 shell 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3016337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:59:54  来源:igfitidea点击:

Mac OS X - run shell script from the desktop GUI

shellscriptingmacosdesktop

提问by dreftymac

You can create a shell script or a Python or Ruby script and run it on the Mac by using "Terminal" ... if you have Finder open, and you click on the icon for the file containing the source code of a saved shell script, is there a way to have that script run, instead of opening in my text editor ?

您可以创建一个 shell 脚本或 Python 或 Ruby 脚本,然后使用“终端”在 Mac 上运行它……如果您打开 Finder,然后单击包含已保存 shell 脚本源代码的文件的图标, 有没有办法让脚本运行,而不是在我的文本编辑器中打开?

回答by Paul R

Yes - just put a .commandsuffix on the script.

是的 - 只需.command在脚本上添加后缀即可。

Note: make sure the script is executable, e.g.

注意:确保脚本是可执行的,例如

$ chmod +x myscript.command

回答by alexrjs

Just another quick alternative is the tool platypus (http://sveinbjorn.org/platypus/). Free and good, but you can donate, if you want.

另一个快速选择是鸭嘴兽工具(http://sveinbjorn.org/platypus/)。免费和好,但你可以捐赠,如果你愿意。

Platypus is a developer tool for the Mac OS X operating system. It creates native Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs. This is done by wrapping the script in an application bundle along with a native executable binary that runs the script.

Platypus 是 Mac OS X 操作系统的开发工具。它从解释过的脚本(如 shell 脚本或 Perl、Ruby 和 Python 程序)创建原生 Mac OS X 应用程序。这是通过将脚本与运行脚本的本机可执行二进制文件一起包装在应用程序包中来完成的。

回答by namon

just associate .sh files with Terminal.app

只需将 .sh 文件与 Terminal.app 相关联