create unix alias using a python3 script
问题 Well, as we all known, creating an alias in a terminal shell is quite easy: ZZ:~ zhangzhao$ alias c='uname' ZZ:~ zhangzhao$ c Darwin ZZ:~ zhangzhao$ But now I want to do the same thing through a Python3 script. I've checked the ref manual and found these sort of command work can be solved using subprocess module. Then I write the script below: import subprocess subprocess.call(["alias", "c=\'uname\'"]) But note that this operation will not take effect to the shell you are currently using,