DEV Community

Bret
Bret

Posted on

Apple/Mac Automator ...how do you create a shortcut to run a terminal script/code?

I’m wanting to create a shortcut for entering in the terminal:
“Python manage.py runserver” and also “make migrations”

How would you use Automator, to create a touchbar shortcut to run the commands???

Discussion (7)

Collapse
damjand profile image
Damjan Dimitrov

In Automator there is a "Run Shell Script" workflow. You can write those commands into the prompt or you can create a custom bash script and run it via automator.

Collapse
yobretyo profile image
Bret Author

I saw it, but I don't know what to enter in it. I tried one but, it opens a box, not entering text when I click on the terminal

Collapse
damjand profile image
Damjan Dimitrov

You can write those two commands separated by a logical AND operator (&&), which will run both commands as you would like. This is how it should look like: sample

While of course firstly you may need to change the directory to where the python script is located

Thread Thread
yobretyo profile image
Bret Author

i tried the first part, but it came back as a error and said the "exe" in manage.py was a error

Thread Thread
yobretyo profile image
Bret Author

I just tried it, but it didn't do anything. I want it to enter the command into terminal when I have it open.

Collapse
yobretyo profile image
Bret Author

I’m trying to make use of the touchbar. I have a “hot key” on my Logitech keyboard that enters in “python manage.py runserver” and it’s nice to just press a button. Also for “makemigrations”

Collapse
damjand profile image
Damjan Dimitrov

I'm not sure what else you can do here. Perhaps you should look it up, surely there are many other solutions to your requirement