Hi guys, newbie here.
I have trouble passing an argument (usually passed with {query}) to NSAppleScript and I have no idea what I'm doing wrong.
I'm trying to make a script that'll grep for me with "grep keyword" in the current finder window folder. However, I'm not able to pass the keyword to NSAppleScript, I'll illustrate on an example:
What I type in alfred: "grep test"
What I get in Terminal: "grep -inr {query} '/Users/[username_stripped]/Downloads/'"
I've tried playing around with it but nothing seems to work, {query} doesn't seem to be evaluated at all. Is this normal behaviour? I've tried googling for a couple of minutes, but no luck.
.alfredworkflow: https://www.dropbox.com/s/i3v387z01esrqn4/grep%20finder.alfredworkflow?dl=0
on alfred_script(q)
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
end tell
tell application "System Events"
if not (exists (processes where name is "Terminal")) then
do shell script "open -a Terminal " & pathList
else
tell application "Terminal"
activate
tell application "System Events" to tell process "Terminal.app" to keystroke "t" using command down
do script ("grep -inr {query} " & pathList) in first window
end tell
end if
end tell
end alfred_script