macos 如何使用 Spotlight 运行 shell 脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2877741/
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
How to run a shell script using Spotlight?
提问by theactiveactor
Is there a way to run a shell script using Spotlight on Mac OS X 10.6? I would like to be able to invoke a shell script directly from Spotlight without opening up a terminal.
有没有办法在 Mac OS X 10.6 上使用 Spotlight 运行 shell 脚本?我希望能够在不打开终端的情况下直接从 Spotlight 调用 shell 脚本。
回答by Paul R
Save your shell script with a .command
suffix - this makes it double-clickable and you should also be able to run it directly from Spotlight too.
使用.command
后缀保存您的 shell 脚本- 这使得它可以双击并且您也应该能够直接从 Spotlight 运行它。
回答by Shaolo
I would also like to add, if you need the terminal window to disappear after running the command, you can set the terminal settings to do just that.
我还想补充一点,如果您需要在运行命令后终端窗口消失,您可以设置终端设置来做到这一点。
It's under settings >> shell >> when the shell exits.
当 shell 退出时,它位于 settings >> shell >> 下。
This will still leave Terminal running but the script will at least clean up after itself.
这仍然会使终端运行,但脚本至少会在其自身之后进行清理。
I used this for writing a script to hide and show desktop icons.
我用它来编写一个脚本来隐藏和显示桌面图标。