124

GitHub - randy3k/Terminus: Best Terminal Emulator of Sublime Text.

 6 years ago
source link: https://github.com/randy3k/Terminus
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

Bring a real terminal to Sublime Text

The first cross platform terminal for Sublime Text.

Unix shell Cmd.exe 41784539-03534fdc-760e-11e8-845d-3d133a559df5.gif 41786131-a625d870-7612-11e8-882d-f1574184faba.gif Terminal in panel 41784748-a7ed9d90-760e-11e8-8979-dd341933f1bb.gif

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

  • Windows support
  • continuous history
  • easily customizable themes
  • 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.

  • 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

{ 
    "keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
        "cmd": "ipython",
        "cwd": "${file_path:${folder}}"
    }
}

(check the details for the arguments of terminus_open below)

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

  • Bash: add the following in .bash_profile or .bashrc
bind '"\e[1;3C": forward-word'
bind '"\e[1;3D": backward-word'
  • Zsh: add the following in .zshrc
bindkey "\e[1;3C" forward-word
bindkey "\e[1;3D" backward-word

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

[
    { "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"}] }
]

User Commands in Palette

  • run Preferences: Terminus Command Palette and add, for example
    {
        "caption": "Terminus: Open Default Shell at Current Location",
        "command": "terminus_open",
        "args"   : {
            "config_name": "Default",
            "cwd": "${file_path:${folder}}"
        }
    }

or by passing custom cmd

    {
        "caption": "Terminus: Open iPython",
        "command": "terminus_open",
        "args"   : {
            "cmd": "ipython",
            "cwd": "${file_path:${folder}}",
            "title": "iPython"
        }
    }

(check the details for the arguments of terminus_open below)

Note to advance users

  • 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 if config_name is None
        "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 identify the terminal
    }
)

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": None        # or the tag which is passed to "terminus_open"
    }
)

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

  • Terminus as a build system. For example, the following can be added to your project settings to allow "SSH to Remote" build system.
{
    "build_systems":
    [
        {
            "cmd":
            [
                "ssh", "[email protected]"
            ],
            "name": "SSH to Remote",
            "target": "terminus_open",
            "working_dir": "$folder"
        }
    ]
}

FAQ

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.

41728204-31a9a2a2-7544-11e8-9fb6-a37b59da852a.png

{
    "panel_background_color": "$background_color"
}

Acknowledgments

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK