Coder Social home page Coder Social logo

joaquin6 / terminus-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from randy3k/terminus

0.0 1.0 0.0 553 KB

Best Terminal Emulator of Sublime Text.

Home Page: https://packagecontrol.io/packages/Terminus

License: MIT License

Python 100.00%

terminus-1's Introduction

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": {
            "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 by using Origami's carry_file_to_pane
[
    {
        "keys": ["ctrl+alt+t"],
        "command": "terminus_open",
        "args": {
            "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"   : {
            "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 by using Origami's carry_file_to_pane
[
    {
        "caption": "Terminus: Open Default Shell in Split View",
        "command": "terminus_open",
        "args": {
            "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
        }
    ]
}

Ctrl-W to close terminal

Following keybind can be considered if one wants to use ctrl+w to close terminals.

{ 
    "keys": ["ctrl+w"], "command": "terminus_close", "context": [{ "key": "terminus_view"}]
}

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

[
    { "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 `None` 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, let terminal configures it if leave empty
        "panel_name": None,      # the name of the panel if terminal should be opened in panel
        "tag": None,             # a tag to identify 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
        "visible_only": False      # send to visible panels only, default is `False`. Only relevent when `tag` is None
    }
)

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: Reset to release the memory.

Color issue when maximizing and minimizing terminal

It is known that the color of the scrollback history will be lost when a terminal is maximized or minimized from or to the panel. There is no fix for this issue.

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.

terminus-1's People

Contributors

randy3k avatar blase avatar gobijan avatar frou avatar karissawhiting avatar toph-allen avatar dwkns avatar symera avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.