Permalink
Browse files

Add open command for issue URLs

The command will read the TM_ISSUE_URL variable from the current environment so you should set this in your project’s .tm_properties file.

The value should use ‘%s’ for where the issue should be inserted. E.g. for TextMate/.tm_properties we set:

    TM_ISSUE_URL = 'https://github.com/textmate/textmate/issues/%s'
  • Loading branch information...
sorbits committed Aug 15, 2012
1 parent 10fb149 commit 570d25795d4c68d0ac809073a238c40dabe26ccc
Showing with 46 additions and 0 deletions.
  1. +46 −0 Commands/Open Issue Link.tmCommand
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
abort "The TM_ISSUE_URL variable is unset for this project.\n\nThis needs to be set to a URL template (using %s) that translates the issue link to one that works in a browser." unless ENV.has_key? 'TM_ISSUE_URL'
link = STDIN.read
if link =~ %r{issue://(.+)}
url = ENV['TM_ISSUE_URL'] % $1
%x{ /usr/bin/open #{e_sh url} }
else
abort "Not an issue link: ‘#{link}’"
end
</string>
<key>fallbackInput</key>
<string>scope</string>
<key>hideFromUser</key>
<string>1</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string></string>
<key>name</key>
<string>Open Issue Link</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>scope</key>
<string>markup.underline.link.issue</string>
<key>uuid</key>
<string>D01C6CD1-A0CF-46AF-AB0E-DF8C5CAB1B36</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>

5 comments on commit 570d257

@skurfer

This comment has been minimized.

Show comment
Hide comment
@skurfer

skurfer Aug 16, 2012

Wouldn't it be nicer to use #157 instead of issue://157? That would allow direct pasting to/from a comment on GitHub and it would all just work. Bonus points if you can add support for GitHub's syntax for links to issues in other repos. :-) i.e. user/Repository#123

skurfer replied Aug 16, 2012

Wouldn't it be nicer to use #157 instead of issue://157? That would allow direct pasting to/from a comment on GitHub and it would all just work. Bonus points if you can add support for GitHub's syntax for links to issues in other repos. :-) i.e. user/Repository#123

@sorbits

This comment has been minimized.

Show comment
Hide comment
@sorbits

sorbits Aug 16, 2012

Member

I think that would clash a lot with other uses of the hash-character followed by a number.

Syntax for referring to other repositories might be useful, but personally I don’t need it — when I do, I might add it :)

Member

sorbits replied Aug 16, 2012

I think that would clash a lot with other uses of the hash-character followed by a number.

Syntax for referring to other repositories might be useful, but personally I don’t need it — when I do, I might add it :)

@skurfer

This comment has been minimized.

Show comment
Hide comment
@skurfer

skurfer Aug 16, 2012

I think that would clash a lot with other uses of the hash-character followed by a number.

How so? We're just talking about the assigned scope, right? So as long as you don't take away or override an existing scope for those strings, all the existing stuff should continue to work, would it not?

Syntax for referring to other repositories might be useful, but personally I don’t need it — when I do, I might add it :)

We use it quite a bit for Quicksilver (with all the plug-in repos, etc.) Seems like you would to, considering all the bundle repos. :-) In any case, one nice thing about that syntax is that you wouldn't even need to define $TM_ISSUE_URL to make it work. Not that I'm suggesting using that syntax all the time. I'd much rather just type/read #XXX (or even issue://XXX) if that works in the current context.

skurfer replied Aug 16, 2012

I think that would clash a lot with other uses of the hash-character followed by a number.

How so? We're just talking about the assigned scope, right? So as long as you don't take away or override an existing scope for those strings, all the existing stuff should continue to work, would it not?

Syntax for referring to other repositories might be useful, but personally I don’t need it — when I do, I might add it :)

We use it quite a bit for Quicksilver (with all the plug-in repos, etc.) Seems like you would to, considering all the bundle repos. :-) In any case, one nice thing about that syntax is that you wouldn't even need to define $TM_ISSUE_URL to make it work. Not that I'm suggesting using that syntax all the time. I'd much rather just type/read #XXX (or even issue://XXX) if that works in the current context.

@sorbits

This comment has been minimized.

Show comment
Hide comment
@sorbits

sorbits Aug 16, 2012

Member

As for clash, I mean if you have some commented CSS with hex colors (e.g. #000) then that would be underlined as a clickable issue.

As for issue://XXX that does work (i.e. w/o the brackets).

Member

sorbits replied Aug 16, 2012

As for clash, I mean if you have some commented CSS with hex colors (e.g. #000) then that would be underlined as a clickable issue.

As for issue://XXX that does work (i.e. w/o the brackets).

@skurfer

This comment has been minimized.

Show comment
Hide comment
@skurfer

skurfer Aug 17, 2012

I see your point. I think the small distraction with be worth it, but OK.

skurfer replied Aug 17, 2012

I see your point. I think the small distraction with be worth it, but OK.

Please sign in to comment.