canadaduane Posted January 24, 2013 Share Posted January 24, 2013 I'm building a workflow that uses "double-shift" as a hotkey to do things with selected text. For example, at work I have two different ticket systems, one prefixes IDs with "CNVS" (e.g. CNVS-1234) and the other with "g/" (e.g. "g/54321"). I'd like to be able to highlight either of these, tap "double-shift" and have it send me in a browser to the correct ticketing system. What's the best way to achieve this with workflows? Can I avoid making a script in this case? Thanks, Duane Johnson Link to comment
canadaduane Posted January 24, 2013 Author Share Posted January 24, 2013 What's the best way to achieve this with workflows? Can I avoid making a script in this case? Just to be clear, I understand how to do this with ONE ticket prefix... it's a simple matter of connecting the Hotkey trigger to the Open URL action. What I'm trying to understand is how Alfred might be able to help me in pattern matching the prefixes so it can choose the correct Open URL action. Link to comment
canadaduane Posted January 24, 2013 Author Share Posted January 24, 2013 def notify(msg, title = "Tell Me More") begin require 'rubygems' require 'terminal-notifier' TerminalNotifier.notify msg, :title => title rescue `growlnotify -n "#{title}" -m "#{msg}"` end end url = case "{query}".strip when /^CNVS-(\d+)$/ then "https://mycompany.atlassian.net/browse/CNVS-#{$1}" when /^g\/(\d+)$/ then "https://gerrit.mycompany.com/#/c/#{$1}" else notify "I can't tell you more about {query}" end `open "#{url}"` # Log of IDs we've recently visited `echo "#{url}" >> ~/.tellmemore` For posterity, the above script accomplished my aims. In workflows, I connected "Hotkey" to "Run Script" and chose Ruby as the language. It uses an optional TerminalNotifier ruby gem [1], or if unavailable, tries to use growlnotify. [1] https://github.com/alloy/terminal-notifier Link to comment
jdfwarrior Posted January 24, 2013 Share Posted January 24, 2013 Yeah Alfred itself doesn't do pattern matching. You would have to do as you say, you do the matching, build a URL then you could make the script return a URL and that pass to a "Open URL" action Link to comment
canadaduane Posted January 24, 2013 Author Share Posted January 24, 2013 you could make the script return a URL and that pass to a "Open URL" action I tried this, but it doesn't seem that I can connect the output of a "Run Script" to the input of an "Open URL" action? Duane Link to comment
jdfwarrior Posted January 25, 2013 Share Posted January 25, 2013 Yeah my bad you're right, but depending on the script language and such you could probably do a system call to do: open "<url>" which would work 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