对于任何其他原因,将自定义shell脚本放到/ usr / bin并将/ usr / bin添加到$ PATH以便在不带./和/文件扩展名?
奖金问题:我可以将自定义图标分配给自定义可执行脚本吗?
Is it dangerous, insecure or not-so-smart for any other reason to put a custom shell script to /usr/bin and add /usr/bin to $PATH in order to make a custom script executable from everywhere without ./ and the file extension?
Bonus question: can I assign custom icons to custom executable scripts?
最满意答案
传统上,/ usr / bin是存储操作系统二进制文件的地方之一。 对于自定义脚本,您可以使用/ usr / local / bin。 如你所说,你必须创建自己,如果它不存在并添加到$ PATH。
图标是GUI的事情,shell脚本是CLI的一件事。 他们生活在不同的宇宙中。 没有什么能阻止你创建一座桥。 例如,您可以创建一个shell脚本并将其命名为foo.command。 从GUI中打开它将启动终端并运行脚本。 由于您在Finder中看到该文件,因此可以通过“信息”窗格为其分配一个新图标。
此外,你可能想看看免费的Platypus应用程序。 它允许您围绕脚本创建一个完整的应用程序包。 该包将包含脚本,因此您不必将其放在一些不明确的目录中并修改$ PATH。 如果您还需要CLI访问,则此选项不太理想。
Traditionally, /usr/bin is one of the places where operating system binaries are stored. For custom scripts, you'd use /usr/local/bin. This you have to create yourself if it does not exist and add to $PATH, as you mentioned.
Icons are a GUI thing, shell scripts are a CLI thing. They live in separate universes. Nothing prevents you from creating a bridge though. For instance, you can make a shell script and call it foo.command. Opening this from the GUI starts Terminal and runs the script. Since you see the file in the Finder, you can assign it a new icon through the Info pane.
Also, you may want to take a look at the free Platypus application. It allows you to create a full-blown application bundle around a script. The bundle will contain the script, so you won't have to put it in some obscure directory and modify $PATH. If you also need CLI access, this option is less desirable.
更多推荐
发布评论