{"id":13448364,"url":"https://github.com/Wramberg/TerminalView","last_synced_at":"2025-03-22T09:31:16.783Z","repository":{"id":79709818,"uuid":"89509294","full_name":"Wramberg/TerminalView","owner":"Wramberg","description":"Terminal inside Sublime Text 3 view","archived":false,"fork":false,"pushed_at":"2019-09-10T05:08:38.000Z","size":2207,"stargazers_count":897,"open_issues_count":34,"forks_count":37,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-28T14:27:22.665Z","etag":null,"topics":["bash","console","shell","terminal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wramberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-26T17:35:28.000Z","updated_at":"2024-10-24T11:51:36.000Z","dependencies_parsed_at":"2023-05-15T00:15:11.708Z","dependency_job_id":null,"html_url":"https://github.com/Wramberg/TerminalView","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wramberg%2FTerminalView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wramberg%2FTerminalView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wramberg%2FTerminalView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wramberg%2FTerminalView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wramberg","download_url":"https://codeload.github.com/Wramberg/TerminalView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244937751,"owners_count":20535124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","console","shell","terminal"],"created_at":"2024-07-31T05:01:43.359Z","updated_at":"2025-03-22T09:31:16.009Z","avatar_url":"https://github.com/Wramberg.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# TerminalView\n\n[![Build Status](https://travis-ci.org/Wramberg/TerminalView.svg?branch=master)](https://travis-ci.org/Wramberg/TerminalView)\n\n## THIS PLUGIN IS DEAD!\n\nI am no longer using Sublime Text and do not have the time to support this plugin. There is a new alternative called Terminus (https://github.com/randy3k/Terminus) which is active at the time of writing.\n\nA Linux/macOS plugin for Sublime Text 3 that allows for terminals inside editor views.\n\n![example.gif](https://raw.githubusercontent.com/Wramberg/TerminalView/master/example.gif \"TerminalView Demonstration\")\n\nThe plugin uses a pseudo-terminal to start the underlying shell which means it supports\n\n* Interactive applications (less, man, ipython, ssh, etc.)\n* Auto-completion\n* Terminal shortcuts (`ctrl`+`c`, etc.)\n* Basically everything you would expect from a terminal\n\nIn addition it also supports\n\n* Integration with the Sublime Text build system\n* Shell colors (8 color support for now - development for 256 is planned)\n* Scrollback history\n* Copy/Pasting\n* Static syntax highlighting (as an addition to shell colors)\n* Integration with other plugins\n\n**Note, if you encounter any issues please check the \"Common problems\" section at the bottom for a solution.**\n\n## Dependencies\nTo run this plugin you need\n\n* Linux-based OS\n* Sublime Text 3 (build 3092 or newer)\n* bash (this is not required but recommended, see \"Changing shell\" below for details)\n\n## Installation\nTo install from https://packagecontrol.io/packages/TerminalView\n\n1. Open the command palette (`ctrl`+`shift`+`p` by default) and find \"Package Control: Install Package\"\n2. Search for TerminalView and hit `enter` to install.\n\nTo install manually from github run\n\n```\ngit clone https://github.com/Wramberg/TerminalView.git $HOME/.config/sublime-text-3/Packages/TerminalView\n```\n\n## Usage\nSimply bring up your command palette (`ctrl`+`shift`+`p` by default) and search for \"Terminal View: Open Bash\". This opens a terminal using 'bash -l' as shell. By default there is no keybinding for opening a terminal view but you can bind a key in your keymap to the *terminal_view_open* command:\n\n```\n{ \"keys\": [\"ctrl+alt+t\"], \"command\": \"terminal_view_open\" },\n```\n\nwhich does the same. All configuration for TerminalView is available through the command palette by searching for \"Terminal View\". Alternatively, it can also be accessed through the menu: *Preferences-\u003ePackage Settings-\u003eTerminalView*. The configuration includes\n\n* Keybindings\n* Settings\n* Palette commands\n* Color scheme\n\nThese are all discussed further in the remainder of this readme.\n\n## Keybindings\nThe following keys are forwarded to the shell by default:\n\n* All single characters and numbers\n* All signs (create an issue if some are missing)\n* Arrow keys\n* `home`, `end`, `delete`, `insert`, `pageup`, `pagedown`\n* `escape`, `tab`, `space`, `backspace`, `enter`\n* Any `ctrl`+`\u003cchar\u003e` combination except `ctrl`+`k` (see below if you want this to go to the shell instead of ST3)\n* Any `alt`+`\u003cchar\u003e` combination\n* Any `ctrl`+`\u003carrow key\u003e` combination\n\nNote that `ctrl`+`\u003csign\u003e` combinations are not forwarded as they depend on keyboard layout. The keybindings can be configured through the menu or the command palette.\n\n**If some of the keybindings are not working they are probably shadowed by keybindings in your user keymap.** To fix this find the missing keybindings in the default keymap and copy them into your user keymap. For example, if you have bound `alt`+`f` in your user keymap you need to insert the following in your user keymap:\n\n```\n{\"keys\": [\"alt+f\"], \"command\": \"terminal_view_keypress\", \"args\": {\"key\": \"f\", \"alt\": true}, \"context\": [{\"key\": \"setting.terminal_view\"}]},\n```\n\nSimilarly, if you want to override some of the default TerminalView keybindings like e.g. `ctrl`+`w` move the following into your user keymap\n\n```\n{ \"keys\": [\"ctrl+w\"], \"command\": \"close\" },\n```\n\nLastly TerminalView also includes a few utility keybindings:\n\nShortcut | Description\n--- | ---\n`ctrl` + `shift` + `c` | Copy the selection/line in the terminal into the clipboard\n`ctrl` + `shift` + `v` | Paste the contents of the clipboard into the terminal\n`alt` + `mouse wheel up` / `mouse wheel down` | Scroll back/forward in terminal history (only works on Linux - see [#28](../../issues/28) for details)\n`shift` + `pageup` / `pagedown` | Scroll back/forward in terminal history\n`ctrl` + `shift` + `t` / `n` | Open a new file\n`ctrl` + `shift` + `w` / `q` | Close the terminal view\n`ctrl` + `shift` + `up` / `down` / `left` / `right` | Move the ST3 cursor (not the terminal cursor)\n`ctrl` + `shift` + `home` / `end` | Move the ST3 cursor to beginning/end of line\n`escape` | If ST3 cursor is located elsewhere than the terminal cursor move it back - otherwise send escape to shell.\n\nNote that standard ST3 keybindings for selection are **not** shadowed which mean you can use `shift` + `keys` for selection in the terminal in case you prefer to use the keyboard. These keybindings do not move the actual terminal cursor however so whenever the terminal is updated the cursor will snap back to its point of origin.\n\n## Settings\nThe settings are available in the menu or through the command palette. The settings include options for adjusting colors, scrollback history and margins (to avoid scrollbars). Simply copy the settings you want to change into your user settings.\n\n## Changing shell\nIf you want to use another shell it is highly recommended to do this through bash with the -c command line argument. You can control the shell command through the *cmd* argument to the *terminal_view_open* command. In addition, you can also alter the title of the terminal view to reflect which shell is running.\n\nIf you e.g. want to run an IPython shell when hitting `ctrl`+`alt`+`t`, add the following to your keymap file:\n\n```\n{ \"keys\": [\"ctrl+alt+t\"], \"command\": \"terminal_view_open\", \"args\": {\"cmd\": \"/bin/bash -l -c /usr/bin/ipython\", \"title\": \"Terminal (IPython)\"}},\n```\n\nIf you really want to avoid using bash you can also run your shell directly:\n\n```\n{ \"keys\": [\"ctrl+alt+t\"], \"command\": \"terminal_view_open\", \"args\": {\"cmd\": \"/usr/bin/ipython\", \"title\": \"Terminal (IPython)\"}},\n```\n\nbut this is **experimental**. Some future development regarding this is planned, but at the moment only bash is tested.\n\nWhen you are done you can close the terminal by closing the view (`ctrl`+`shift`+`q` or `ctrl`+`shift`+`w` as default) or exiting the shell (by e.g. hitting `ctrl`+`d`).\n\n## Palette Commands\nAdditional palette commands can be added through the menu or the command palette. These are simply included as an alternative to keybindings.\n\n## Color scheme\nThe color scheme is used for both dynamic coloring (colors set by the shell) and static coloring (colors set by syntax highlighting). The color scheme itself can be tweaked by copying the default color scheme into the user color scheme file. Both of these files are available in the menu or through the command palette.\n\n## Syntax highlighting\nThe plugin supports user provided syntax highlighting for static coloring. To use this feature create a *\\\u003cname\\\u003e.sublime-syntax* file in your *Packages/User* folder. The *packages* folder can accessed through the menu: *Preferences-\u003eBrowse Packages*. The content of the file depends entirely on your needs - see https://www.sublimetext.com/docs/3/syntax.html for details. As an example consider the following which highlights the prompt in bash.\n\n```\n%YAML 1.2\n---\nname: TerminalViewBash\nhidden: true\nfile_extensions:\n  - terminal_view\nscope: text.terminal_view\ncontexts:\n  main:\n    - match: '\\w+@[A-z,\\-_]+(?=:)'\n      scope: terminalview.black_green\n    - match: '([A-z,\\-_/~0-9.]+\\$)'\n      scope: terminalview.black_blue\n```\n\nThe matching could be improved upon but it will do for the purpose of this example. Note that the scope names are chosen so they match with scopes that are already defined in the color scheme. To change the color scheme see the \"color scheme\" section above. In this example the syntax file was saved as *bash.sublime-syntax* under the *Packages/User* folder. To use it when opening a bash terminal pass it to the *terminal_view_open* command with the *syntax* argument:\n\n```\n{ \"keys\": [\"ctrl+alt+t\"], \"command\": \"terminal_view_open\", \"args\": {\"cmd\": \"/bin/bash -l\", \"title\": \"Bash Terminal\", \"syntax\": \"bash.sublime-syntax\"}},\n```\n\nThere are currently no syntax-files provided with the plugin so users must create their own. Note that any colors set by shell (except the black/white default) override colors set by the syntax highlighting.\n\n## Project switching and ST3 startup\nWhen switching projects or (re)starting ST3 the plugin restarts all terminals views. Unfortunately, there is no obvious way of restoring earlier sessions so the views are completely reset.\n\n## Integrating with Sublime Text build system\nIn a Sublime Text build system, you can use the `terminal_view_exec` command as a `\"target\"` key. This allows you to parse input to the command you are running which is not possible in the standard build system.\n\nFor example, consider this `.sublime-project`:\n\n```\n{\n  \"build_systems\":\n  [\n    {\n      \"name\": \"My Build\",\n      \"shell_cmd\": \"c++ program.c -o program\",\n      \"working_dir\" \"$project_path\"\n      \"variants\":\n      [\n        {\n          \"name\": \"Run program\",\n          \"shell_cmd\": \"./program\",\n          \"working_dir\": \"$project_path\"\n        }\n      ]\n    }\n  ],\n  // Irrelevant code omitted\n}\n```\n\nWhen you click on *Tools* -\u003e *Build With...* in the menu, you may select the *My Build - Run program* variant. This opens an output panel and runs your program. Unfortunately, if the program requires input from the user it cannot be provided. To solve this you can change the variant to:\n\n```\n{\n  \"name\": \"Run program\",\n  \"target\": \"terminal_view_exec\",\n  \"shell_cmd\": \"./program\",\n  \"working_dir\": \"$project_path\"\n}\n```\n\nThis runs your program inside a TerminalView instead where you can interact with it.\n\n## Integration with other plugins\nTerminalView supports integration with other plugins through the *terminal\\_view\\_send\\_string* and *terminal\\_view\\_exec* commands. The former can be used to send a string to a running terminal while the latter opens a new terminal. For example, to run 'ls' in a terminal that is already open run\n\n```\nwindow.run_command(\"terminal_view_send_string\", {\"string\": \"ls\\n\"})\n```\n\nTo run a command in a new terminal run\n\n```\nwindow.run_command(\"terminal_view_exec\", {\"cmd\": \"a.out\"})\n```\n\nFor details refer to the source code for now.\n\n## List of plugins that integrate with TerminalView\nThe following is a list of known plugins that integrate with TerminalView.\n\n* SendCode by randy3k (https://github.com/randy3k/SendCode)\n* ShellVE by bfelder (https://github.com/bfelder/ShellVE)\n\n## Common problems\nList of common problems you may encounter when using this plugin.\n\n#### A keybinding is not working even though it is listed in the keybindings section\nThis is most likely because you have the key bound to something else in your user keymap file. To make it work find the missing keybinding in the TerminalView keymap and copy it to your user keymap. For details see the keybindings section above.\n\n#### The terminal is responsive but acts weird (prints weird sequences, cursor located in the wrong place, etc.)\nEnsure you do not have a bash_profile file or similar that changes the value of the `TERM` environment variable. This is set to \"linux\" by the plugin and must stay that way. You can check it by calling `env | grep TERM` inside the terminal view in ST3. If the `TERM` value is correct feel free to open an issue for further investigation.\n\n#### The terminal is sluggish and/or uses a lot of memory\nYou may have other plugins that conflict with TerminalView. TerminalView does a lot of modifications to the buffer which can conflict with plugins like e.g. GotoLastEditEnhanced. In this particular case a history of all modifications are saved causing unbound memory usage. Please test TerminalView in isolation to see if the issue persists.\n\n## Acknowledgments\nThe pyte terminal emulator (https://github.com/selectel/pyte) is an integral part of this plugin and deserves some credit for making this plugin possible.\n\nDuring development the SublimePTY plugin (https://github.com/wuub/SublimePTY) was a good source of inspiration for some of the problems that occurred. You can probably find a few bits and pieces from it in this plugin.\n\nFor testing stubs and general test structure the Javatar plugin (https://github.com/spywhere/Javatar) was a good point of origin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWramberg%2FTerminalView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWramberg%2FTerminalView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWramberg%2FTerminalView/lists"}