forked from klaascuvelier/SublimeCommandOnSave
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommandOnSave.py
More file actions
21 lines (18 loc) · 821 Bytes
/
Copy pathCommandOnSave.py
File metadata and controls
21 lines (18 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sublime
import sublime_plugin
import subprocess
import re
class CommandOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
settings = sublime.load_settings('CommandOnSave.sublime-settings').get('commands')
file = view.file_name()
if not settings == None:
for path in settings.keys():
commands = settings.get(path)
if re.match(path, file) is not None and len(commands) > 0:
print("Command on Save:")
for command in commands:
command = command.format(filename=file)
p = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
print (out.decode('utf-8'))