🔌 Toolbox of short, reusable pieces of code and knowledge.
Say you have the script script.py
that you run frequently. Instead of having to type python3 script.py
everytime, you can make the script file executable.
For Python scripts:
cd
into the directory of the script.script.py
(e.g. #!/usr/bin/python3
). Your Python install location might be somewhere else however. To find its location, type which python
.chmod 755 script.py
.You can now run the script via ./script.py
. You can remove the .py
extension now.
This is generalizable to non-Python files as well.