-
Notifications
You must be signed in to change notification settings - Fork 82
/
Preview in All Active Browsers.plist
65 lines (58 loc) · 2.17 KB
/
Preview in All Active Browsers.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?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>saveActiveFile</string>
<key>command</key>
<string>#!/usr/bin/env ruby -wKU
#
# Open Document in Running Browser(s)
# v3 - November 22, 2007
#
# Now supports multiple running versions of a single browser along
# with a range of new/old browsers. Bring back support for Firefox.
#
# Options: Set TM_PROJECT_SITEURL in your TM Project Window Info Button
# in the following form: "http://example.com/"
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape.rb"
if ENV['TM_PROJECT_SITEURL']
url = "#{ENV['TM_PROJECT_SITEURL']}" + ENV['TM_FILEPATH'].sub(/^#{Regexp.escape(ENV['TM_PROJECT_DIRECTORY'])}\//, '')
else
url = "file://#{ENV['TM_FILEPATH']}"
end
proclist = `ps -x -o command`
active = []
os = `defaults read /System/Library/CoreServices/SystemVersion ProductVersion`
browsers = %w[ Safari OmniWeb Camino Shiira firefox-bin Xyle\ scope Opera Internet\ Explorer flock-bin iCab Sunrise seamonkey-bin navigator-bin ].join('|')
# Build paths to each active browser
#
# Notes:
# - 'WebKit' look ahead is to rule it out so we can use the working
# rule below.
# - 'LaunchCFMApp' portion is so iCab works.
active = proclist.scan(%r{^(?:/.*LaunchCFMApp )?(/.*\.app)(?=/Contents/MacOS/(?:#{browsers})\b(?!\s-WebKit))})
# Special check for WebKit as it appears as Safari
# Note: Only supports one running instance of WebKit, picked at random.
if proclist =~ %r{/Contents/MacOS/Safari.*-WebKit(DeveloperExtras|ScriptDebuggerEnabled)}
active << "WebKit"
end
# TODO: Change when Leopard Only
# On Leopard use the -g option to open in background.
if os =~ /^10\.(5|6)/
active.each {|p| `open -g -a #{e_sh(p)} #{e_sh(url)}` }
else
active.each {|p| `open -a #{e_sh(p)} #{e_sh(url)}` }
end</string>
<key>input</key>
<string>none</string>
<key>name</key>
<string>Open Document in Running Browser(s)</string>
<key>output</key>
<string>discard</string>
<key>scope</key>
<string>text.html</string>
<key>uuid</key>
<string>970EE6B4-A091-11D9-A5A2-000D93C8BE28</string>
</dict>
</plist>