Skip to content

Instantly share code, notes, and snippets.

@remy
Created January 23, 2014 11:21
Show Gist options
  • Save remy/8576990 to your computer and use it in GitHub Desktop.
Save remy/8576990 to your computer and use it in GitHub Desktop.
An Alfred 2 workflow to let me jump directly to jsbin issues, either by issue number, searching issues or creating new issues. Make sure to change to your own repo. Also, disclaimer, I don't write or use ruby, so this is pretty much just clobbered together.
# change this...unless you're in to jsbin issues :)
repo = "remy/jsbin"
require 'cgi'
v = ARGV[0] || "{query}"
url = "";
text = "";
if v.to_s =~ /\A[-+]?\d*\.?\d+\z/ || v == "new"
url = "https://github.com/#{repo}/issues/#{v}"
text = "Open #{v}"
else
url = "https://github.com/#{repo}/search?type=Issues&q=#{CGI.escape(v)}"
text = "Search for #{v}"
end
xml = <<EOF
<?xml version="1.0"?>
<items>
<item uid="" arg="#{CGI.escapeHTML(url)}">
<title>Issue #{v}</title>
<subtitle>#{text}</subtitle>
<valid>yes</valid>
<icon>icon.png</icon>
</item>
</items>
EOF
puts "#{xml}"

Create a new Alfred workflow. Add a script filter, and set the language to Ruby, and paste the gitissues.rb file in this gist. I set the script filter's keyword to "issue", you can use what you like.

http://d.pr/i/Nejf+

Then pipe this input to a new "action", specifically "Open URL" and setup with {query}:

http://d.pr/i/55Qv+

Now I can jump straight to jsbin issues with three key commands:

  1. Issue number: "issue 123"
  2. Issue search: "issue pro users"
  3. New issue: "issue new"

Then it'll open my browser at that page. Pretty sweet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment