forked from gcollazo/BrowserRefresh-Sublime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BrowserRefresh.py
33 lines (26 loc) · 981 Bytes
/
BrowserRefresh.py
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
import sublime_plugin
from subprocess import call
class BrowserRefreshCommand(sublime_plugin.TextCommand):
def run(self, args, activate_browser=True, browserName="Google Chrome"):
if self.view and self.view.is_dirty():
self.view.run_command("save")
activate = ""
if(activate_browser == True):
activate = "activate"
if(browserName == "Google Chrome"):
command = """
tell application "Google Chrome"
%s
reload active tab of window 1
end tell
""" % (activate)
elif(browserName == "Safari"):
command = """
tell application "Safari"
%s
tell its first document
set its URL to (get its URL)
end tell
end tell
""" % (activate)
call(['osascript', '-e', command])