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"



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

Share this post

Link to post

Applications do not use your shell's environment, and /usr/local/bin is not on $PATH. Use the full path to the program.


/usr/local/bin/pngpaste $query

Share this post

Link to post

@deanishe Is it possible to get the full path of a brew command programmatically though? 
I tried to use $(which pngpaste), but running that in an Alfred bash script can't find it.

Share this post

Link to post

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

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...