Make file to be run on Terminal

Hi, how can a make a file or an app to run a code with Terminal?

I have to make this string << cd /Users/leo/Documents/Python && python3 aggiorna_giorni.py >> as a file so that if I open that, the code runs automatically.


P.S. = Do you know any program or function that can make a keyboard shortcut to open a file ?

MacBook Pro 13″, macOS 11.4

Posted on Jun 14, 2021 9:27 AM

Reply
2 replies

Jun 14, 2021 9:59 AM in response to ileonemil

Use Automator to make that a Service, and you get all of what you are asking.

It is very easy too.


In Automator, choose File->New and choose Quick Action.

Set it to receive no input.

Add a single action "Run Shell Script" and select the desired shell. It does not matter much which one, in this case.


Save it with a name that is meaningful to you.

It will become immediately available from the Services menu in any application (for example, if you are on Safari, just go to Safari->Services)

To add a keyboard shortcut is easy too.

Just go to System Preferences->Keyboard->Shortcuts, select Services, locate your Service and add a shortcut.

Be careful not to choose one that is used for something else.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Make file to be run on Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.