def run(self,
cmd="/bin/bash -l",
title="Terminal",
cwd=None,
syntax=None,
keep_open=False):
"""
Open a new terminal view
Args:
cmd (str, optional): Shell to execute. Defaults to 'bash -l.
title (str, optional): Terminal view title. Defaults to 'Terminal'.
cwd (str, optional): The working dir to start out with. Defaults to
either the currently open file, the currently
open folder, $HOME, or "/", in that order of
precedence. You may pass arbitrary snippet-like
variables.
syntax (str, optional): Syntax file to use in the view.
keep_open (bool, optional): Keep view open after cmd exits.
"""
if sublime.platform() not in ("linux", "osx"):
sublime.error_message("TerminalView: Unsupported OS")
return
st_vars = self.window.extract_variables()
if not cwd:
cwd = "${file_path:${folder}}"
cwd = sublime.expand_variables(cwd, st_vars)
if not cwd:
cwd = os.environ.get("HOME", None)
if not cwd:
# Last resort
cwd = "/"
args = {"cmd": cmd, "title": title, "cwd": cwd, "syntax": syntax, "keep_open": keep_open}
self.window.new_file().run_command("terminal_view_activate", args=args)
评论列表
文章目录