Say, I have a python script named hello.py, which I run on mac as:
$ python hello.py
What do I need to do to run it as:
$ hello
Add a "shebang" to the top of the file to tell it how to run your script.
#!/usr/bin/env python
Then you need to mark the script as "executable":
chmod +x hello.py
Then you can just run it as ./hello.py instead of python hello.py.
To run it as just hello, you can rename the file from hello.py to hello and then copy it into a folder in your $PATH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With