I’m on a mac, and I write quite a bit of python scripts.
Every time I need to run them, I have to type ‘python script_name.py‘. Is there I way to make it so I only have to type like ‘p script_name.py‘? It would save some time 😀
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I am assuming you are running your script from the command line right? If so, add the following line as the first line in your script:
or alternatively
in case the python command is not located in
/usr/bin, and then issue the following command once at the Unix/terminal prompt (it makes your script “executable”):from then on you only need to type the name of the script at the command prompt to run it. No
pythonpart of the command needed. I.e., simplywill run the script.
You can also of course go with the
alias, but the above is a cleaner solution in my opinion.For the alias
should go into your
~/.bashrcfile