ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Terminus

by randy3k ST3 Trending

Best Terminal Emulator of Sublime Text.

Details

Installs

  • Total 11K
  • Win 5K
  • OS X 3K
  • Linux 3K
Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9 Feb 8 Feb 7
Windows 5 37 52 53 52 55 47 32 38 62 71 47 25 17 20 34 25 25 42 32 20 18 24 33 29 20 35 19 24 25 31 34 26 42 38 24 19 26 43 40 33 34 17 19 33 37
OS X 2 22 31 42 45 46 35 21 21 31 29 39 13 14 11 7 11 20 12 11 13 11 9 8 12 18 23 14 6 13 14 12 15 13 12 13 11 13 18 17 20 20 7 13 16 20
Linux 2 24 28 28 42 39 33 27 21 27 28 24 20 17 9 22 20 20 21 19 17 13 42 20 16 18 12 12 9 11 13 17 15 19 16 16 12 16 16 23 21 14 11 6 13 22

Readme

Source
raw.​githubusercontent.​com

Bring a real terminal to Sublime Text

The first cross platform terminal for Sublime Text.

Unix shell Cmd.exe
Terminal in panel Support showing images

This package is heavily inspired by TerminalView. Compare with TerminalView, this has

  • Windows support
  • continuous history
  • easily customizable themes (see Terminus Utilities)
  • unicode support
  • 256 colors support
  • better xterm support
  • terminal panel
  • imgcat support (PS: it also works on Linux / WSL)

Installation

Package Control.

Getting started

  • run Terminus: Open Default Shell in View

User Key Bindings

You may find these key bindings useful. To edit, run Preferences: Terminus Key Bindings. Check the details for the arguments of terminus_open below.

  • toggle terminal panel
[
    { "keys": ["alt+`"], "command": "toggle_terminus_panel" }
]
  • open a terminal view at current file directory
[
    { 
        "keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
            "config_name": "Default",
            "cwd": "${file_path:${folder}}"
        }
    }
]

or by passing a custom cmd, say ipython

[
    { 
        "keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
            "cmd": "ipython",
            "cwd": "${file_path:${folder}}"
        }
    }
]
  • open terminal in a split view
[
    {
        "keys": ["ctrl+alt+t"],
        "command": "terminus_open",
        "args": {
            "config_name": "Default",
            "pre_window_hooks": [
                ["set_layout", {
                    "cols": [0.0, 1.0],
                    "rows": [0.0, 0.5, 1.0],
                    "cells": [[0, 0, 1, 1], [0, 1, 1, 2]]
                }],
                ["focus_group", {"group": 1}]
            ]
        }
    }
]

or by applying Origami's carry_file_to_pane

[
    {
        "keys": ["ctrl+alt+t"],
        "command": "terminus_open",
        "args": {
            "config_name": "Default",
            "post_window_hooks": [
                ["carry_file_to_pane", {"direction": "down"}]
            ]
        }
    }
]

User Commands in Palette

  • run Preferences: Terminus Command Palette. Check the details for the arguments of terminus_open below
[
    {
        "caption": "Terminus: Open Default Shell at Current Location",
        "command": "terminus_open",
        "args"   : {
            "config_name": "Default",
            "cwd": "${file_path:${folder}}"
        }
    }
]

or by passing custom cmd, say ipython

[
    {
        "caption": "Terminus: Open iPython",
        "command": "terminus_open",
        "args"   : {
            "cmd": "ipython",
            "cwd": "${file_path:${folder}}",
            "title": "iPython"
        }
    }
]
  • open terminal in a split view
[
    {
        "caption": "Terminus: Open Default Shell in Split View",
        "command": "terminus_open",
        "args": {
            "config_name": "Default",
            "pre_window_hooks": [
                ["set_layout", {
                    "cols": [0.0, 1.0],
                    "rows": [0.0, 0.5, 1.0],
                    "cells": [[0, 0, 1, 1], [0, 1, 1, 2]]
                }],
                ["focus_group", {"group": 1}]
            ]
        }
    }
]

or by applying Origami's carry_file_to_pane

[
    {
        "caption": "Terminus: Open Default Shell in Split View",
        "command": "terminus_open",
        "args": {
            "config_name": "Default",
            "post_window_hooks": [
                ["carry_file_to_pane", {"direction": "down"}]
            ]
        }
    }
]

User Build System

Use Terminus as a build system. For example, the following can be added to your project settings to run a bash command.

{
    "build_systems":
    [
        {
            "cmd":
            [
                "bash", "-c", "echo helloworld"
            ],
            "name": "Hello World",
            "target": "terminus_open",
            "working_dir": "$folder",
            "auto_close": false
        }
    ]
}

Alt-Left/Right to move between words (Unix)

  • Bash: add the following in .bash_profile or .bashrc “ if [ $TERM_PROGRAM == "Terminus-Sublime” ]; then bind '“\e[1;3C”: forward-word' bind '“\e[1;3D”: backward-word' fi
- Zsh: add the following in `.zshrc`

if [ $TERM_PROGRAM == “Terminus-Sublime” ]; then bindkey “\e[1;3C” forward-word bindkey “\e[1;3D” backward-word fi

Some programs, such as julia, does not recognize the standard keycodes for `alt+left` and `alt+right`. You could
bind them to `alt+b` and `alt+f` respectively
```json
[
    { "keys": ["alt+left"], "command": "terminus_keypress", "args": {"key": "b", "alt": true}, "context": [{"key": "terminus_view"}] },
    { "keys": ["alt+right"], "command": "terminus_keypress", "args": {"key": "f", "alt": true}, "context": [{"key": "terminus_view"}] }
]

Terminus API

  • A terminal could be opened using the command terminus_open with
window.run_command(
    "terminus_open", {
        "config_name": None,     # the shell config name, use "Default" for the default config
        "cmd": None,             # the cmd to execute
        "cwd": None,             # the working directory
        "working_dir": None,     # alias of "cwd"
        "env": {},               # extra environmental variables
        "title": None,           # title of the view
        "panel_name": None,      # the name of the panel if terminal should be opened in panel
        "tag": None,             # a tag to idFentify the terminal
        "pre_window_hooks": [],  # a list of window hooks before opening terminal
        "post_window_hooks": [], # a list of window hooks after opening terminal
        "post_view_hooks": [],   # a list of view hooks after opening terminal
        "auto_close": True       # auto close terminal if process exits successfully
    }
)

The fields cmd and cwd understand Sublime Text build system variables.

  • the setting view.settings().get("terminus_view.tag") can be used to identify the terminal and

  • keybind can be binded with specific tagged terminal

{
        "keys": ["ctrl+alt+w"], "command": "terminus_close", "context": [
            { "key": "terminus_view.tag", "operator": "equal", "operand": "YOUR_TAG"}
        ]
    }
  • text can be sent to the terminal with
window.run_command(
    "terminus_send_string", 
    {
        "string": "ls\n",
        "tag": "<YOUR_TAG>"        # ignore this or set it to None to send text to the first terminal found
    }
)

If tag is not provided or is None, the text will be sent to the first terminal found in the current window.

FAQ

Memory issue

It is known that Terminus sometimes consumes a lot of memory after extensive use. It is because Sublime Text keeps an infinite undo stack. There is virtually no fix unless upstream provides an API to work with the undo stack. Meanwhile, users could execute Terminus: Clear History to release the memory.

Terminal panel background issue

If you are using DA UI and your terminal panel has weired background color, try playing with the setting panel_background_color in DA UI: Theme Settings.

{
    "panel_background_color": "$background_color"
}

Acknowledgments

This package won't be possible without pyte, pywinpty and ptyprocess.