84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
比如我写好了一个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/