-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathosx_utils.py
More file actions
31 lines (23 loc) · 1.08 KB
/
osx_utils.py
File metadata and controls
31 lines (23 loc) · 1.08 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
import sublime
import os
def call_terminal(run_command=None, new_tab=False):
call_terminal = """osascript -e 'tell application "Terminal" to activate' """
if new_tab:
call_terminal += ("""-e 'tell application "System Events" """
"""to tell process "Terminal" """
"""to keystroke "t" using command down' """)
if run_command:
call_terminal += ("""-e 'tell application "Terminal" """
"""to do script "{}" """
"""in selected tab of the front window' """.format(run_command))
os.system(call_terminal)
def open_terminal_with_new_window(init_path=None):
init_path = init_path if init_path is not None else '~'
os.system('open -a /System/Applications/'
'Utilities/Terminal.app {}'.format(init_path))
def osx_only():
if sublime.platform() != 'osx':
sublime.error_message(
'Currently this plugin is only supported in macOS')
raise NotImplementedError(
'expected osx system, got {}'.format(sublime.platform()))