Skip to content

Instantly share code, notes, and snippets.

@OdatNurd
Created July 12, 2021 07:01
Show Gist options
  • Select an option

  • Save OdatNurd/9ffced9af1aaa34c6b0463330015539e to your computer and use it in GitHub Desktop.

Select an option

Save OdatNurd/9ffced9af1aaa34c6b0463330015539e to your computer and use it in GitHub Desktop.
[
// Toggle the most recently accessed terminus panel open and closed; will
// create a new default panel if there is none currently.
{
"keys": ["alt+`"],
"command": "toggle_terminus_panel"
},
// You can have multiple bindings to toggle multiple panels, but you must
// specify a panel_name for all of them.
{
"keys": ["alt+`"],
"command": "toggle_terminus_panel",
"args": {
"panel_name": "Terminus"
}
},
{
"keys": ["ctrl+alt+g"],
"command": "toggle_terminus_panel",
"args": {
"panel_name": "Git"
}
},
// Close the current terminal; works only in a terminus panel or view.
// You could also bind this to ctrl+w, which is the default key for
// closing a tab.
{
"keys": ["ctrl+d"],
"command": "terminus_close",
"context": [
{ "key": "terminus_view"}
]
}
]
import sublime
import sublime_plugin
import os
class OpenInTerminusCommand(sublime_plugin.WindowCommand):
"""
Drop in replacement for terminus_open that will open the
"""
def run(self, dirs, panel=True, **kwargs):
command = "terminus_open"
kwargs["cwd"] = dirs[0]
if panel:
command = "toggle_terminus_panel"
kwargs["panel_name"] = "Terminus: %s" % os.path.split(dirs[0])[-1]
self.window.run_command(command, kwargs)
def is_enabled(self, dirs, panel=True):
return len(dirs) == 1
def is_visible(self, dirs, panel=True):
return len(dirs) == 1
{
"target": "terminus_open",
// So terminus will re-use the same tab
"tag": "python",
// Provide a tab title
"title": "Python Custom",
// Don't auto-close the tab when the program ends
"auto_close": false,
"timeit": true,
// Make sure that no other tabs are selected, then select the tab to the
// left to create the window split.
"post_window_hooks": [
["unselect_others"],
["select_to_left"]
],
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
"windows": {
"cmd": ["py", "-u", "$file"],
},
"variants":
[
{
"name": "Syntax Check",
"cmd": ["python3", "-m", "py_compile", "$file"],
"windows": {
"cmd": ["py", "-m", "py_compile", "$file"],
}
}
]
}
[
{ "caption": "-", "id": "folder_commands" },
{
"caption": "Open in Terminus (Tab)",
"command": "open_in_terminus",
"args": {
"panel": false,
"dirs": []
}
},
{
"caption": "Open in Terminus (Panel)",
"command": "open_in_terminus",
"args": {
"panel": true,
"dirs": []
}
},
]
@OdatNurd
Copy link
Author

These are the sample files referenced in the video containing Power Tips for Terminus available from my YouTube Channel.

The video demonstrates being able to toggle multiple Terminus panels, open Terminus from the side bar, and using Sublime Text's new Tab MultiSelect feature to easily get a split build with Terminus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment