Detect the terminal program currently being used, with support for iTerm, Terminal.app, Hyper, iTerm2, ConEmu, Cmde,r Alacritty, Xterm, Terminator, Termux, Kitty, and others. Detection is based on environment variables and process-level indicators to identify the terminal in use. This can't be done reliably in all cases, but it's useful when available.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save detect-terminal
import detectTerminal from 'detect-terminal';
// or
import { detectTerminal } from 'detect-terminal';
console.log(detectTerminal()) //=> "iterm" (or whatever terminal you're using)
import detectTerminal from 'detect-terminal';
// By default, multiplexers like tmux/screen are detected first
console.log(detectTerminal()); //=> "tmux" (if running inside tmux)
// With preferOuter: true, prefer the outermost terminal (GUI app)
console.log(detectTerminal({ preferOuter: true })); //=> "iterm" (the actual terminal app)
| Option | Type | Default | Description |
|---|---|---|---|
preferOuter | boolean | false | When true, prefer the outermost terminal (GUI app) over multiplexers like tmux/screen |
The following terminals are supported. Detection is based on environment variables and process-level indicators to identify the terminal in use.
Note:
cmd, sh (Bourne Shell), bash, zsh, fish, etc.) because the code's process-title detection maps those as possible values, and the code wasn't able to find a better terminal identifier.terminal_app, gnome_terminal, etc.) and not the terminal program's real executable names. This approach was takenn to avoid confusion with the actual executable names, which can vary across platforms and installations.| Terminal | Detection (ENV / Process) | Description |
|---|---|---|
| Alacritty | ALACRITTY_SOCKET, ALACRITTY_LOG, TERM=alacritty, or TERM_PROGRAM=alacritty | Cross-platform, GPU-accelerated terminal emulator |
| Apple Terminal | TERM_PROGRAM=Apple_Terminal | macOS default terminal emulator |
| Cmd.exe | process.title=cmd or COMSPEC=cmd.exe | Windows Command Prompt |
| Eterm | TERM_PROGRAM=Eterm | Enlightened Terminal Emulator |
| Foot | TERM=foot* or process.title=foot | Fast, lightweight Wayland terminal emulator |
| Ghostty | GHOSTTY_RESOURCES_DIR or TERM=ghostty | GPU-accelerated terminal emulator |
| Gnome Terminal | TERM_PROGRAM=gnome-terminal, TERM_PROGRAM=gnome-terminal-server, or VTE_VERSION >= 3803 | GNOME terminal emulator |
| Hyper | TERM_PROGRAM=Hyper | JS/HTML/CSS terminal emulator |
| iTerm2 | TERM_PROGRAM=iTerm.app or iTerm or iTerm2 | Advanced terminal for macOS |
| Kitty | KITTY_PID, TERM_PROGRAM=kitty, or TERM=kitty | GPU-accelerated terminal emulator |
| Konsole | TERM_PROGRAM=konsole or environment variables containing "konsole" | KDE terminal emulator |
| MATE Terminal | TERM_PROGRAM=mate-terminal | MATE terminal emulator |
| PowerShell | TERM_PROGRAM=powershell, process.title=powershell, process.title=pwsh, or COMSPEC=powershell.exe | Powerful Windows/macOS/Linux shell |
| PuTTY | TERM_PROGRAM=putty | Popular SSH/Telnet client for Windows |
| QTerminal | TERM_PROGRAM=qterminal | Lightweight terminal for LXQt |
| Rio | TERM_PROGRAM=rio or TERM=rio* | GPU-accelerated terminal built in Rust |
| rxvt/rxvt-unicode | TERM=rxvt* or TERM_PROGRAM=rxvt | Lightweight terminal emulator and its Unicode variant |
| screen | TERM=screen* | Terminal multiplexer |
| Terminator | TERM_PROGRAM=terminator | Multiple terminals per window |
| Termux | TERM_PROGRAM=termux or TERMUX_VERSION on Android | Android terminal emulator |
| tmux | TERM=tmux* | Terminal multiplexer |
| VS Code | TERM_PROGRAM=vscode, VSCODE_PID, or TERM_PROGRAM_VERSION contains vscode | Visual Studio Code integrated terminal |
| Warp | TERM_PROGRAM=warp | Modern Rust-based terminal |
| WezTerm | TERM_PROGRAM=wezterm | GPU-accelerated terminal emulator |
| Windows Terminal | WT_SESSION present or COMSPEC=wt.exe | Modern tabbed terminal for Windows 10+ |
| Xfce4 Terminal | TERM_PROGRAM=xfce4-terminal | Xfce terminal emulator |
| Xterm | TERM=xterm or TERM=xterm-256color | X Window System terminal emulator |
| VT100/VT220 | TERM=vt100 or TERM=vt220 | DEC VT100 and VT220 (and compatible emulators) |
| Linux Console | TERM=linux | Native Linux virtual console |
| Dopamine | TERM=dopamine | Modern terminal emulator |
Notes:
TERM and TERM_PROGRAM environment variables, as well as process-level indicators such as process.title on some platforms, to identify the running terminal.KITTY_PID, GHOSTTY_RESOURCES_DIR, ALACRITTY_SOCKET) are checked first as they provide the most reliable detection.COMSPEC or WT_SESSION.tmux and GNU Screen are identified through the TERM variable when active. Use preferOuter: true to skip multiplexer detection.unknown as a last resort.preferOuter option to prefer outermost terminal (GUI app) over multiplexers like tmux/screenGHOSTTY_RESOURCES_DIR environment variableALACRITTY_SOCKET and ALACRITTY_LOG environment variablesKITTY_PID environment variable (most reliable method)TERM=linuxTERM_PROGRAMVTE_VERSION detection to properly identify GNOME Terminal when it masquerades as xtermCOLORTERM precedence handling for better terminal identificationTERMUX_VERSION checksWT_SESSION prioritization and pwsh supportYou might also be interested in:
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
| Commits | Contributor |
|---|---|
| 7 | jonschlinkert |
| 1 | doowb |
Jon Schlinkert
Copyright © 2025, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on December 06, 2025.