-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (39 loc) · 1.59 KB
/
main.py
File metadata and controls
52 lines (39 loc) · 1.59 KB
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
import sublime
import sublime_plugin
from os.path import expandvars
def get_file_location(identifier):
settings = sublime.load_settings('SSH Config.sublime-settings')
user_setting = settings.get('file_locations')
if user_setting:
if identifier in user_setting:
return expandvars(user_setting[identifier])
else:
print('Could not find {} key in "file_locations"'
''.format(identifier))
return expandvars(settings.get(
'default_file_locations')[sublime.platform()][identifier])
def open_new_view(instance, identifier):
window = instance.view.window()
if not window:
print('Missing window for view')
return
view = window.open_file(get_file_location(identifier))
return view
class OpenSshConfigFileCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = open_new_view(self, 'ssh_config')
if not view:
return
if sublime.load_settings('SSH Config.sublime-settings').get(
'force_ssh_config_syntax'):
syntax = 'Packages/SSH Config/syntax/SSH Config.sublime-syntax'
view.settings().set('syntax', syntax)
class OpenSshdConfigFileCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = open_new_view(self, 'sshd_config')
class OpenKnownHostsFileCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = open_new_view(self, 'known_hosts')
class OpenAuthorizedKeysFileCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = open_new_view(self, 'authorized_keys')