I have a simple python script I can run through terminal. Is there a way to put a shortcut on my mac desktop to open terminal and run like "cd ~/Desktop/script.py"? I have tried automator but i couldn't get it to work
3 Answers
Create a file called anyname.command with python ~/Desktop/script.py in it. Then make it executable by running chmod 555 ~/Desktop/anyname.command in terminal. Then when you double-click on anyname.command it should run the python script.
1 Comment
Automator would be your best bet actually, creating Macintosh .app bundles by hand can be annoying.
It's been a long time since I've used automator, but here goes, use the Run Shell Script command from Terminal, and make the script be python ~/Desktop/script.py or maybe use the full path like python /Users/<username>/Desktop/script.py
P.S. cd ~/Desktop/script.py doesn't do what you think it does, you want python ~/Desktop/script.py
Comments
you have to create a samplename.sh file and put the below line and run it ./samplename.sh
~/Desktop/script.py
create symbolic link to that .sh file and place it on desktop.
1 Comment
script.py directly the same way, not from the desktop though.