Jump to content

How can I run a simple terminal command without opening terminal.app ?


Recommended Posts

Hi, new alfred user, non-programmer here innocently raising the white flag. 

 

Alfred: Ver 4

Workflow: Reduce file size with query (cd desktop || sips -s formatOptions {query} *.jpg)

Status: Works perfectly but using the 'terminal command' 

 

Goal: Run the same script but using the action 'run script' (so I can get the same result without opening the terminal app.)

 

I can't find the solution anywhere on the web (maybe it's that obvious, nobody felt the need to explain haha). I have pasted the exact command in the 'run script' action but it returns nothing for me. 

 

Could someone please point out where I'm going wrong, please? If I can do this one script then I will be able apply the same principles to all my other terminal workflows.

 

Thanks.

(screenshots attached for reference (2 similar scripts with one that takes an argument))

 

Screenshot 2021-06-06 at 17.09.39.jpg

Screenshot 2021-06-06 at 17.09.51.jpg

Screenshot 2021-06-06 at 17.10.00.jpg

Screenshot 2021-06-06 at 17.23.44.jpg

Screenshot 2021-06-06 at 17.23.53.jpg

Link to comment
Share on other sites

Hi @westbrook366, welcome to the forum.

 

When you have an issue with a workflow you're working on, please don't just post pictures of it. Upload the workflow somewhere (e.g. Dropbox) and post a link to it, so we can see the workflow for ourselves.

 

In any case, in a Run Script action, you shouldn’t use {query}. It’s very hard to get right. Choose “with input as argv” instead and use "$1" as the placeholder in your script.

 

Also be mindful that Alfred (like all Mac apps) isn’t launched from your shell, so it doesn’t use your shell environment. If you’re trying to run a program that isn’t on the default PATH (/usr/bin:/bin:/usr/sbin:/sbin), you need to call it by its full path (e.g. /usr/local/bin/myprogram, not just myprogram).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...