apermanentwreck Posted March 15, 2013 Share Posted March 15, 2013 So I have a bash script below, that I run that allows me to pass in 2 - 3 arguments that will then download a dummy image from lorempixel.com. #!/bin/bash if [ $3 ] then wget http://lorempixel.com/$1/$2/$3'>http://lorempixel.com/$1/$2/$3 -O $1x$2-$3.jpg else wget http://lorempixel.com/$1/$2/ -O $1x$2.jpg fi I want to set this up as a workflow, but not sure how to deal with the {query} part in the script. Right now I have a keyword that links to the "Run Script" action that breaks when it gets there. I realize I can probably tweak this script so that the query matches the output path, but I want to keep it readable. Please help?! Link to comment
apermanentwreck Posted March 15, 2013 Author Share Posted March 15, 2013 Additionally, I'd like to be able to feed this back into Alfred so it that its asks where to download this image to, so that I can have it put in any project I'm working on. I assume there is a way to do this, by having it download to a tmp directory and then moving the path to whatever the new {query} would be, iI just need some help walking through it. Link to comment
Florian Posted March 15, 2013 Share Posted March 15, 2013 To answer your first question, {query} will be replaced by the content typed in alfred. If you want it to be several arguments, you'll have to find a way to parse it (with spaces, comas, or whatever suits you). As for your second question, I don't understand what it is that you want to feed back into alfred. Link to comment
phallstrom Posted March 17, 2013 Share Posted March 17, 2013 In Alfred, create a run script action, and be sure to uncheck "escape spaces". Then use this to get {query} into arguments you can use. #!/bin/bash read a1 a2 a3 <<< "{query}" if [ $a3 ] then wget http://lorempixel.com/$a1/$a2/$a3'>http://lorempixel.com/$a1/$a2/$a3 -O $a1x$a2-$a3.jpg else wget http://lorempixel.com/$a1/$a2/ -O $a1x$a2.jpg fi I'm not sure how you'd then get Alfred to prompt you for where to save it. Link to comment
Lexyz Posted May 3, 2022 Share Posted May 3, 2022 On 3/18/2013 at 4:56 AM, phallstrom said: In Alfred, create a run script action, and be sure to uncheck "escape spaces". Then use this to get {query} into arguments you can use. #!/bin/bash read a1 a2 a3 <<< "{query}" if [ $a3 ] then wget http://lorempixel.com/$a1/$a2/$a3'>http://lorempixel.com/$a1/$a2/$a3 -O $a1x$a2-$a3.jpg else wget http://lorempixel.com/$a1/$a2/ -O $a1x$a2.jpg fi I'm not sure how you'd then get Alfred to prompt you for where to save it. @phaistonian how would you pass that a1, a2, etc up to another action say Open URL action? Link to comment
vitor Posted May 3, 2022 Share Posted May 3, 2022 @Lexyz echo -n "Whatever text you want to pass along" Lexyz 1 Link to comment
Lexyz Posted May 3, 2022 Share Posted May 3, 2022 (edited) 1 hour ago, vitor said: @Lexyz echo -n "Whatever text you want to pass along" @vitor Right i c Also wonder how would you access the actual keyword in bash? `$X` gives you a params, but what I really need is a real keyword 👇 Edited May 3, 2022 by Lexyz Link to comment
Andrew Posted May 3, 2022 Share Posted May 3, 2022 @Lexyz Use an environment variable for the keyword: https://www.alfredapp.com/help/workflows/advanced/variables/ Then it'll be available as an environment variable in the script you run too. Lexyz 1 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