Terminal
Launch terminals from the current file or the root project folder
Installations minus removals
Upgrades
- 951,804 installs
- 21 stars
Links
Version
3.0.0
·
Terminal package for Sublime Text
Shortcuts and menu entries for opening a terminal at the current file, or any directory in Sublime Text.
Note that as of build 4213 Sublime Text itself has a open_terminal command. It has a terminal_command setting, and takes a dir argument. It can be used for instance in keybindings as follows, and might suit your needs as well as this package does:
[
{ "keys": ["super+ctrl+t"], "command": "open_terminal", "args": {"dir": "$file_path"} },
{ "keys": ["super+ctrl+alt+t"], "command": "open_terminal", "args": {"dir": "$folder"} },
]
Installation
Download Package Control and use the Package Control: Install Package command from the command palette. Using Package Control ensures Terminal will stay up to date automatically.
Usage
- Open Terminal at File Opens a terminal in the folder containing the currently opened file.
- Open Terminal at Project Folder Opens a terminal in the project folder containing the currently opened file.
Terminals can be opened via the command palette, the editor context menu and the sidebar context menus. Additionally, you can set up key bindings.
Key bindings
To create keyboard shortcuts, open the Preferences > Package Settings > Terminal > Key Bindings menu entry. Our suggested key bindings are on the left, you can copy these over to your personal bindings on the right and tweak them to your liking. Example:
[
{ "keys": ["ctrl+shift+t"], "command": "terminal_open" },
{ "keys": ["ctrl+alt+t"], "command": "terminal_open_project_folder" },
{ "keys": ["ctrl+shift+alt+t"], "command": "terminal_switch" }
]
Terminal 2.0
Note that in version 2 of this package, we stopped enabling these bindings by default. They conflicted with built-in bindings of Sublime Text, and users might have different preferences.
Terminal 3.0
In version 3 of this package the commands have been renamed, to avoid conflict with Sublime Text's new built-in open_terminal command (as of build 4213).
open_terminaltoterminal_openopen_terminal_project_foldertoterminal_open_project_folderswitch_to_terminaltoterminal_switch
Package Settings
The settings can be viewed and edited by accessing the Preferences > Package Settings > Terminal > Settings menu entry.
- terminal
- The terminal to execute, will default to the OS default if blank.
- Default:
""
- parameters
- The parameters to pass to the terminal. These parameters will be used if no custom parameters are passed.
- Default:
[]
- env
- The environment variables changeset. Default environment variables used when invoking the terminal are inherited from Sublime Text.
- The changeset may be used to overwrite/unset environment variables. Use
nullto indicate that the environment variable should be unset. - Default:
{}
Custom Parameters
By passing parameters argument to the terminal_open or terminal_open_project_folder commands, it is possible to construct custom terminal environments. You can do so by creating custom key bindings that call these commands with the arguments you want, as we'll document here, or by adding custom command palette or menu entries.
The following is an example, of passing the parameters `-T 'Custom Window Title'`` to an XFCE terminal.
{
"keys": ["ctrl+alt+t"],
"command": "terminal_open",
"args": {
"parameters": ["-T", "Custom Window Title"]
}
}
A parameter may also contain the %CWD% placeholder, which will be substituted with the current working directory the terminal was opened to.
{
"keys": ["ctrl+alt+t"],
"command": "terminal_open",
"args": {
"parameters": ["-T", "Working in directory %CWD%"]
}
}
Example configurations
Here are some example configurations calling different terminals. Note that paths to executables might differ on your machine.
Cmder on Windows
{
"terminal": "C:\\Program Files\\cmder_mini\\cmder.exe",
"parameters": ["/START", "%CWD%"]
}
xterm on GNU/Linux
{
"terminal": "xterm"
}
gnome-terminal for CJK users on GNU/Linux
We unset LD_PRELOAD, as it may cause problems for Sublime Text with imfix.
{
"terminal": "gnome-terminal",
"env": {"LD_PRELOAD": null}
}
iTerm on MacOS.
{
"terminal": "iTerm.sh"
}
iTerm on MacOS. with tabs
{
"terminal": "iTerm.sh",
"parameters": ["--open-in-tab"]
}
iTerm2 v3 on MacOS.
{
"terminal": "iTerm2-v3.sh"
}
Hyper on MacOS.
{
"terminal": "hyper.sh"
}
Kitty on OS X
{
"terminal": "/opt/homebrew/bin/kitty",
"parameters": ["-d", "%CWD%"]
}
Windows Terminal
{
"terminal": "C:/Users/yourusername/AppData/Local/Microsoft/WindowsApps/wt.exe",
"parameters": ["-d", "."]
}