pablojimeno Posted November 8, 2018 Share Posted November 8, 2018 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
deanishe Posted November 8, 2018 Share Posted November 8, 2018 Applications do not use your shell's environment, and /usr/local/bin is not on $PATH. Use the full path to the program. query=$1 /usr/local/bin/pngpaste $query Link to comment
pablojimeno Posted November 13, 2018 Author Share Posted November 13, 2018 Thanks @deanishe Link to comment
himat Posted July 9, 2019 Share Posted July 9, 2019 @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. Link to comment
deanishe Posted July 9, 2019 Share Posted July 9, 2019 (edited) 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 July 9, 2019 by deanishe Link to comment
jedwards Posted November 13, 2020 Share Posted November 13, 2020 (edited) `$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 November 13, 2020 by jedwards Link to comment
deanishe Posted November 13, 2020 Share Posted November 13, 2020 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now