Skip to content

Commit 570d257

Browse files
committed
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'
1 parent 10fb149 commit 570d257

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Commands/Open Issue Link.tmCommand

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>beforeRunningCommand</key>
6+
<string>nop</string>
7+
<key>command</key>
8+
<string>#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -wKU
9+
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
10+
11+
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'
12+
13+
link = STDIN.read
14+
if link =~ %r{issue://(.+)}
15+
url = ENV['TM_ISSUE_URL'] % $1
16+
%x{ /usr/bin/open #{e_sh url} }
17+
else
18+
abort "Not an issue link: ‘#{link}’"
19+
end
20+
</string>
21+
<key>fallbackInput</key>
22+
<string>scope</string>
23+
<key>hideFromUser</key>
24+
<string>1</string>
25+
<key>input</key>
26+
<string>selection</string>
27+
<key>inputFormat</key>
28+
<string>text</string>
29+
<key>keyEquivalent</key>
30+
<string></string>
31+
<key>name</key>
32+
<string>Open Issue Link</string>
33+
<key>outputCaret</key>
34+
<string>afterOutput</string>
35+
<key>outputFormat</key>
36+
<string>text</string>
37+
<key>outputLocation</key>
38+
<string>discard</string>
39+
<key>scope</key>
40+
<string>markup.underline.link.issue</string>
41+
<key>uuid</key>
42+
<string>D01C6CD1-A0CF-46AF-AB0E-DF8C5CAB1B36</string>
43+
<key>version</key>
44+
<integer>2</integer>
45+
</dict>
46+
</plist>

0 commit comments

Comments
 (0)