User guide / Terminals

Starting a terminal

Development reference · View source

CommandRuns
:terminal (:term, :t), Space t n, Ctrl-w t$SHELL on Unix, %COMSPEC% (else cmd.exe) on Windows, in the editor working directory. Not available in editor mode .
:terminal htopThat command line
:terminal-file-directory [command]From the active file’s parent
:terminal-directory-root [command]From the active explorer’s root
:terminal-selected-directory [command]From the selected directory entry
:terminal-session-directory <number|name>A shell in another terminal’s last safe directory
Tab t in an explorerA terminal in the directory the explorer shows
  • The pane’s own buffer stays where it is; leaving the terminal shows it again.
  • Unix splits command lines shell-style; Windows uses native double-quote/backslash syntax.
  • Directory reports. Shells may report their directory with a bounded local OSC 7 file: URL. Remote hosts, control characters, non-file schemes, and paths that are not existing absolute directories are rejected.

Windows terminals

Windows terminals use ConPTY and need no Bash.

  • Executables are found on absolute PATH entries using PATHEXT. The workspace is not searched implicitly.
  • Quote paths with spaces: :terminal "C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo.
  • Operators and batch files need an explicit shell: :terminal cmd.exe /d /c "echo hello".
  • For cmd.exe /c or /k, give exactly one command-string argument. Runyte adds /s and keeps that string as shell text, nested quotes included:
    • :terminal cmd.exe /d /c "echo \"a b\"" prints "a b";
    • :terminal cmd.exe /d /c "\"C:\scripts\my task.cmd\"" runs a batch file whose path has spaces.
  • PowerShell 7 and Git Bash are optional installations.
  • Each terminal owns an independent process tree; closing it or quitting the editor ends that tree.
  • Working directories need an ordinary Windows path shorter than 260 UTF-16 units; paths needing extended-name semantics are refused before launch. cmd.exe also refuses UNC working directories, so use a shell that supports them. These limits do not affect which files the editor can open.