Launch terminals from the current file or the root project folder
Python Shell PowerShell Batchfile
Latest commit 1a99e6a Jan 5, 2017 @twolfson twolfson committed on GitHub Fixed up unicode environment variable issue (#156)
We improperly eagerly closed #154 with a separate issue. It turns out our injection of `sublime_terminal_path` in Python 2 (ST2) as a unicode string was causing issues as `Popen` only wants `str` strings. In this PR:

- Added normalization for environment from `unicode` to `str`

**Notes:**

We could move from `create_unicode_buffer` to `create_string_buffer` but I have a feeling that could undo existing patched regressions and this seems like it should work fine. Tested on ST2 on Windows and ST3 on Linux
Permalink
Failed to load latest commit information.
messages Documented iTerm2-v3 support Aug 24, 2016
.gitignore Fixed executing open terminal at project folder when no files are ope… Aug 30, 2011
.no-sublime-package Fixed some ST3 issues on Windows Aug 8, 2013
Context.sublime-menu "Open terminal here" should probably be in the same section as "Open … Oct 14, 2011
Default (Linux).sublime-keymap Made line endings consistent across source files Aug 8, 2013
Default (OSX).sublime-keymap Made line endings consistent across source files Aug 8, 2013
Default (Windows).sublime-keymap Made line endings consistent across source files Aug 8, 2013
Default.sublime-commands Cleaned up excess whitespace from PR Sep 11, 2015
LICENSE Replaced readme.creole with readme.md based off of website Nov 14, 2015
Main.sublime-menu Fixed up hyphen/dash typo in settings Jul 5, 2015
PS.bat Revert permissions change to PS.bat Jun 17, 2015
PS.ps1 Updated Windows platform to launch PowerShell with a reasonable size … Aug 2, 2011
Side Bar.sublime-menu Removed an extraneous side bar menu entry Nov 6, 2011
Terminal.py Fixed up unicode environment variable issue (#156) Jan 5, 2017
Terminal.sh fish shell compatibility Jul 13, 2015
Terminal.sublime-settings Merge remote-tracking branch 'upstream/master' Jan 2, 2017
changelog.md Release 1.16.2 Jan 5, 2017
iTerm.sh Fix "--open-in-tab" when no terminal is open Jul 14, 2015
iTerm2-v3.sh fix for osx double tabs iterm bug (#138) Oct 17, 2016
messages.json Documented iTerm2-v3 support Aug 24, 2016
readme.md Unset LD_PRELOAD before launch. (#150) Jan 2, 2017
release.sh Added script for consistent releases Aug 28, 2016

readme.md

Sublime Terminal

Shortcuts and menu entries for opening a terminal at the current file, or the current root project folder in Sublime Text.

Features

  • Opens a terminal in the folder containing the currently edited file
  • Opens a terminal in the project folder containing the currently edited file

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 Press ctrl+shift+t on Windows and Linux, or cmd+shift+t on OS X
  • Open Terminal at Project Folder Press ctrl+alt+shift+t on Windows and Linux, or cmd+alt+shift+t on OS X

In addition to the key bindings, terminals can also be opened via the editor context menu and the sidebar context menus.

Package Settings

The default settings can be viewed by accessing the Preferences > Package Settings > Terminal > Settings – Default menu entry. To ensure settings are not lost when the package is upgraded, make sure all edits are saved to Settings – User.

  • terminal
    • The terminal to execute, will default to the OS default if blank. OS X users may enter iTerm.sh to launch iTerm if installed.
    • Default: ""
  • parameters
    • The parameters to pass to the terminal. These parameters will be used if no custom parameters are passed via a key binding.
    • Default: []
  • env
    • The environment variables changeset. Default environment variables used when invoking the terminal are inherited from sublime.
    • The changeset may be used to overwrite/unset environment variables. Use null to indicate that the environment variable should be unset.
    • Default: {}

Examples

Here are some example setups:

Cmder on Windows

{
  // Replace with your own path to cmder.exe
  "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

{
  "terminal": "gnome-terminal",
  // Unset LD_PRELOAD which may cause problems for sublime with imfix
  "env": {"LD_PRELOAD": null}
}

#### iTerm on OS X

```js
{
  "terminal": "iTerm.sh"
}

iTerm on OS X with tabs

{
  "terminal": "iTerm.sh",
  "parameters": ["--open-in-tab"]
}

iTerm2 v3 on OS X

{
  "terminal": "iTerm2-v3.sh"
}

Custom Parameters

With the parameters argument to the open_terminal and open_terminal_project_folder commands, it is possible to construct custom terminal environments.

The following is an example of passing the parameters -T 'Custom Window Title' to a terminal. Please note that this example is just an example, and is tailored to the XFCE terminal application. Your terminal may use the -T option for some other features or setting. Custom key bindings such as this would be added to the file opened when accessing the Preferences > Key Bindings – User menu entry (the file name varies by operating system).

{
  "keys": ["ctrl+alt+t"],
  "command": "open_terminal",
  "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": "open_terminal",
  "args": {
    "parameters": ["-T", "Working in directory %CWD%"]
  }
}