开发者

Is moving custom shell script to /usr/bin problematic?

Is it dangerous, insecure or not-so-smart for any other reason to put a custom shell script to /usr/bin and add /usr/开发者_C百科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?


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.


I wrote a command line tool for setting the custom icon of a file. You can grab it here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜