比如我写好了一个test.py脚本,通常都要这样调用:
$ python3 test.py -h
我想问大家如何实现下面的这样:
$ test -h
alias别名不算哈。
认证高级PHP讲师
Create a file such as /usr/sbin/test
Test code
#! /usr/bin/python3 print('my test')
Give the file executable permission
chmod +x /usr/sbin/test
In this way, you can directly access the test command in any directory in the consoleIf your directory is not in $PATH, add it yourself
py file first line:
#! /usr/bin/python3
chmod +x test.py ./test.py
You can add alias in .bash_profile or establish a soft connection in /usr/bin/
Create a file such as /usr/sbin/test
Test code
Give the file executable permission
In this way, you can directly access the test command in any directory in the console
If your directory is not in $PATH, add it yourself
py file first line:
You can add alias in .bash_profile or
establish a soft connection in /usr/bin/