Jump to content

Run a shell command installed with homebrew


Recommended Posts

Hello, I'm trying to create a simple workflow that saves to disk the image that is in the clipboard. I found pngpaste a library to do just that.

 

Now I created the workflow with a keyword trigger named pasteimage and an action "Run Script"

 

query=$1

pngpaste $query

 

I get this error:

 

Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/546DD210-2D7D-4CED-AA58-DAB4B0F6EE89:3: command not found: pngpaste

How can I run this command from Run Script?

 

Thank you

Link to comment
  • 7 months later...

Yes, but you need to update $PATH to include any directories you want which to look in. And if you do that, you don’t need which any more: you can just run the command by name if it’s on your $PATH.


To change your $PATH, use export before calling which/your other command:

export PATH=/usr/local/bin:$PATH
which pngpaste
# -> /usr/local/bin/pngpaste

 

Edited by deanishe
Link to comment
  • 1 year later...

`$PATH` doesn't even have everything in my `/etc/paths`, why would that be?  It would be nice not to have to set `PATH` in every single run script action we make.

 

I'm also trying to use a file in my `~/Library/LaunchAgents` to add to my `PATH` for all programs, not just shells.  I haven't confirmed that file is working right, but should I expect Alfred to run scripts with the same `PATH` it was run with?

Edited by jedwards
Link to comment
1 hour ago, jedwards said:

`$PATH` doesn't even have everything in my `/etc/paths`, why would that be?

 

2 hours ago, jedwards said:

should I expect Alfred to run scripts with the same `PATH` it was run with?

 

Alfred does run scripts with the same PATH it was run with.

 

But /etc/path and /etc/path.d/ are used by shells, and your login session and Mac applications aren't launched from a shell.

 

If you must change the environment for your entire login session, you need to do it with launchctl.

Link to comment

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
×
×
  • Create New...