forked from jocelynmallon/sublime-text-2-marked
-
Notifications
You must be signed in to change notification settings - Fork 7
/
marked.py
29 lines (24 loc) · 768 Bytes
/
marked.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
import os
import sys
import subprocess
import sublime_plugin
class MarkedCommand(sublime_plugin.WindowCommand):
def run(self):
filename = self.window.active_view().file_name()
if filename is None:
return
proc_env = os.environ.copy()
encoding = sys.getfilesystemencoding()
for k, v in proc_env.items():
proc_env[k] = os.path.expandvars(v).encode(encoding)
for app in ('Marked 2', 'Marked'):
try:
subprocess.check_call(
['open', '-a', app, filename],
env=proc_env
)
break
except subprocess.CalledProcessError:
pass
def is_enabled(self):
return True