Get started with Terminus
masterTo open your default shell in a new tab, run the following command from the Command Palette:
Terminus: Open Default Shell in Tab
repository·master·Indexed 23 days ago
https://github.com/randy3k/terminusA cross-platform terminal emulator for Sublime Text that supports unicode, 256 colors, and imgcat. It provides a real terminal experience directly within the editor, including a Python API for programmatic control, a drop-in replacement for the default build system via terminus_exec, and a comprehensive set of commands for terminal management, shell execution, and UI rendering.
To open your default shell in a new tab, run the following command from the Command Palette:
Terminus: Open Default Shell in Tab
You can add custom Terminus commands to your Command Palette by running Preferences: Terminus Command Palette. This allows you to trigger specific shell configurations or custom commands (like ipython) with a title and specific working directory.
[
{
"caption": "Terminus: Open iPython",
"command": "terminus_open",
"args": { "cmd": "ipython", "cwd": "${file_path:${folder}}", "title": "iPython" }
}
]Terminus provides terminus_exec as a drop-in replacement for the default exec target. It accepts the same arguments as terminus_open. To allow users to cancel a running build (e.g., via ctrl+c), use the terminus_cancel_build command assigned to the cancel key.
You can define these in your project settings or in a .sublime-build file. You can use either cmd or shell_cmd (which invokes bash on Unix and cmd.exe on Windows).
{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"shell_cmd": "python helloworld.py",
"working_dir": "$folder"
}You can customize how you interact with Terminus by adding key bindings. To edit them, run Preferences: Terminus Key Bindings.
Common useful bindings include:
toggle_terminus_panel.terminus_open with the cwd argument set to ${file_path:${folder}}.terminus_close with a context check for terminus_view to allow using ctrl+w specifically for terminals.// Toggle terminal panel
[
{ "keys": ["alt+`"], "command": "toggle_terminus_panel" }
]
// Open terminal at current file directory
[
{
"keys": ["ctrl+alt+t"],
"command": "terminus_open",
"args": { "cwd": "${file_path:${folder}}" }
}
]
// Close terminal with ctrl+w (only when in a terminus view)
{
"keys": ["ctrl+w"],
"command": "terminus_close",
"context": [{ "key": "terminus_view" }]
}To enable standard Unix word movement (Alt+Left/Right) within Terminus, add the following snippets to your shell configuration files. This checks if the terminal program is Terminus-Sublime before applying the bindings.
# Add to .bash_profile or .bashrc
if [ "$TERM_PROGRAM" == "Terminus-Sublime" ]; then
bind '"\e[1;3C": forward-word'
bind '"\e[1;3D": backward-word'
fi
# Add to .zshrc
if [ "$TERM_PROGRAM" = "Terminus-Sublime" ]; then
bindkey "\e[1;3C" forward-word
bindkey "\e[1;3D" backward-word
fiTerminus may consume significant memory due to Sublime Text's infinite undo stack. If memory usage becomes too high, run Terminus: Reset to release it. (Note: This issue is addressed in Sublime Text >= 4114 and Terminus v0.3.20).
Colors in the scrollback history may be lost when maximizing or minimizing the terminal panel. This is a known limitation.
If using DA UI and the terminal panel has incorrect background colors, adjust the following settings in DA UI: Theme Settings:
panel_background_colorpanel_text_output_background_color (to keep Find/Replace panels unchanged){
"panel_background_color": "$background_color"
}Terminus can be controlled via the Sublime Text Python API using window.run_command.
terminus_openUse this to programmatically launch shells with specific configurations, environments, or tags.
terminus_send_stringSend strings (including newlines) to a specific terminal using its tag.
Use view.settings().get("terminus_view.tag") to retrieve the tag of a view. You can then use this tag in key bindings to target specific terminals.
# Open a terminal
window.run_command(
"terminus_open", {
"cmd": None,
"shell_cmd": None,
"cwd": None,
"env": {},
"title": "My Terminal",
"tag": "MY_TAG",
"auto_close": False
}
)
# Send text to a specific tagged terminal
window.run_command(
"terminus_send_string",
{
"string": "ls\n",
"tag": "MY_TAG"
}
)Terminus uses a debug setting in Terminus.sublime-settings to control the verbosity of its logs.
Terminus provides a wide range of Sublime Text commands to manage terminal views, shell execution, and terminal-specific interactions. These commands can be invoked via the Command Palette, Key Bindings, or the Context Menu.
terminus_open: Opens a new terminal view.terminus_activate: Activates a terminal view.terminus_close: Closes the current terminal view.terminus_close_all: Closes all open terminal views across all windows.terminus_maximize: Maximizes the terminal view.terminus_minimize: Minimizes the terminal view.terminus_toggle_panel: Toggles the Terminus panel.terminus_reset: Resets the terminal view.terminus_nuke: Forcefully destroys a terminal view.terminus_exec: Executes a command in a terminal.terminus_send_string: Sends a string of text to the terminal.terminus_cancel_build: Cancels the current build process.terminus_initialize_view: Initializes a view for terminal use.terminus_copy: Copies text from the terminal.terminus_paste: Pastes text into the terminal.terminus_paste_from_history: Pastes text from the Terminus clipboard history.terminus_paste_text: Pastes specific text into the terminal.terminus_insert: Inserts text into the terminal.terminus_delete_word: Deletes the word at the cursor (Unix-style).terminus_trim_trailing_lines: Trims trailing lines in the view.terminus_render: Triggers a terminal render.terminus_show_cursor: Controls cursor visibility.terminus_cleanup: Performs cleanup operations.terminus_rename_title: Renames the terminal title.terminus_select_theme: Opens the theme selection interface.terminus_generate_theme: Generates a new theme.terminus_click: Handles mouse clicks within the terminal.terminus_open_context_url: Opens a URL found in the terminal context.terminus_open_image: Opens an image found in the terminal context.