How do I install a script to run anywhere from the command line?

后端 未结 10 1158
梦谈多话
梦谈多话 2020-12-04 10:14

If I have a basic Python script, with it\'s hashbang and what-not in place, so that from the terminal on Linux I can run

/path/to/file/MyScript [args]
         


        
10条回答
  •  情书的邮戳
    2020-12-04 10:28

    Putting the script somewhere in the PATH (like /usr/local/bin) is a good solution, but this forces all the users of your system to use/see your script.

    Adding an alias in /etc/profile could be a way to do what you want allowing the users of your system to undo this using the unalias command. The line to be added would be:

    alias MyScript=/path/to/file/MyScript
    

提交回复
热议问题