leej0nes Posted October 17, 2015 Share Posted October 17, 2015 (edited) I bet there's already a way around it but if not the benefit I see is that I instead of having a NSAppleScript for each of my keywords such as sc name io which via a script produces example.io and writes it into the active text field of the active application. I could have the one script instead who's q value would be what I've specified. I hope this makes sense?!?! If the script grows to do more then I have to copy and paste to replace the rest of the scripts in my current workflow (6 so far). I'm totally loving Alfred 2 today. That's the rest of my work out the window. Next up is to find if I can create a keyword named Bookmark which takes an argument and adds the site to to the bookmark name provided by the arguments because my bookmarks are in such mess I haven't used them in years. Time to clear them all down and either find a Workflow for this of write one. Safari only for now and can only run if Safari is the active window of course. EDIT To expand on this I've found another instance where this would be useful. I've added a Keyword to the workflow named sc lua and connected it to a Reveal in Finder action but this action doesn't know where to go because I'm not accepting arguments so there are none passed to it. I want to add an sc lua terminal but see there's no Reveal in Terminal action. I'll figure something out. More things are planned related to GitHub and this project too. Disclaimer: I suspect that the way I'm doing things is probably very noobish and goes against the grain of how Alfred or parts of it are meant to be used. I apologise if so and look forward to learning better ways to do things and as such being able to do more things. Edited October 17, 2015 by Lee Link to comment Share on other sites More sharing options...
deanishe Posted October 17, 2015 Share Posted October 17, 2015 (edited) This isn't really how you'd go about implementing this. If you're using a lot of almost-identical scripts, write one script that can handle the different input and save it in your workflow's directory. Then call that script from your Run Script actions, e.g. osascript myscript.scpt name "{query}" If you want to write nested keywords (sc > lua > ...), a Script Filter is the best way if you have a lot of keywords. You can pass as much or as little data as you want via {query}, but this sometimes means parsing the input yourself. There isn't a Reveal in Terminal action. Here's one: on run (argv) set thePath to first item of argv openTerminalAtPath(thePath) end run on alfred_script(q) openTerminalAtPath(q) end alfred_script on openTerminalAtPath(thePath) tell application "Terminal" activate tell application "System Events" to keystroke "t" using command down repeat while contents of selected tab of window 1 starts with linefeed delay 0.01 end repeat do script "cd " & quoted form of thePath & " && clear" in window 1 end tell end openTerminalAtPath Edited October 17, 2015 by deanishe Link to comment Share on other sites More sharing options...
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