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 iden
npm install detect-terminal> 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:
``sh`
$ npm install --save detect-terminal
`js
import detectTerminal from 'detect-terminal';
// or
import { detectTerminal } from 'detect-terminal';
console.log(detectTerminal()) //=> "iterm" (or whatever terminal you're using)
`
`js
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.
* alacritty
* bash
* cmd
* conhost
* csh
* dopamine
* eterm
* fish
* foot
* ghostty
* gnome_terminal
* hyper
* iterm
* kitty
* konsole
* ksh
* linux_console
* mate_terminal
* node
* powershell
* putty
* qterminal
* rio
* rxvt
* screen
* sh
* tcsh
* terminal
* terminal_app
* terminator
* termux
* tmux
* truecolor_terminal
* vscode
* vt100
* warp
* wezterm
* windows_cmd
* windows_terminal
* xfce4_terminal
* xterm
* zsh
Note:
* Some items are shell names (like 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
* The names are as returned by the detection methods (i.e., , 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.
* Fallback/auto-generated names (using sanitized env values) are also possible in the code but are not explicitly named in the code.
| Terminal | Detection (ENV / Process) | Description |
| --- | --- | --- |
| Alacritty | ALACRITTY_SOCKET, ALACRITTY_LOG, TERM=alacritty, or TERM_PROGRAM=alacritty | Cross-platform, GPU-accelerated terminal emulator |TERM_PROGRAM=Apple_Terminal
| Apple Terminal | | macOS default terminal emulator |process.title=cmd
| Cmd.exe | or COMSPEC=cmd.exe | Windows Command Prompt |TERM_PROGRAM=Eterm
| Eterm | | Enlightened Terminal Emulator |TERM=foot*
| Foot | or process.title=foot | Fast, lightweight Wayland terminal emulator |GHOSTTY_RESOURCES_DIR
| Ghostty | or TERM=ghostty | GPU-accelerated terminal emulator |TERM_PROGRAM=gnome-terminal
| Gnome Terminal | , TERM_PROGRAM=gnome-terminal-server, or VTE_VERSION >= 3803 | GNOME terminal emulator |TERM_PROGRAM=Hyper
| Hyper | | JS/HTML/CSS terminal emulator |TERM_PROGRAM=iTerm.app
| iTerm2 | or iTerm or iTerm2 | Advanced terminal for macOS |KITTY_PID
| Kitty | , TERM_PROGRAM=kitty, or TERM=kitty | GPU-accelerated terminal emulator |TERM_PROGRAM=konsole
| Konsole | or environment variables containing "konsole" | KDE terminal emulator |TERM_PROGRAM=mate-terminal
| MATE Terminal | | MATE terminal emulator |TERM_PROGRAM=powershell
| PowerShell | , process.title=powershell, process.title=pwsh, or COMSPEC=powershell.exe | Powerful Windows/macOS/Linux shell |TERM_PROGRAM=putty
| PuTTY | | Popular SSH/Telnet client for Windows |TERM_PROGRAM=qterminal
| QTerminal | | Lightweight terminal for LXQt |TERM_PROGRAM=rio
| Rio | or TERM=rio* | GPU-accelerated terminal built in Rust |TERM=rxvt*
| rxvt/rxvt-unicode | or TERM_PROGRAM=rxvt | Lightweight terminal emulator and its Unicode variant |TERM=screen*
| screen | | Terminal multiplexer |TERM_PROGRAM=terminator
| Terminator | | Multiple terminals per window |TERM_PROGRAM=termux
| Termux | or TERMUX_VERSION on Android | Android terminal emulator |TERM=tmux*
| tmux | | Terminal multiplexer |TERM_PROGRAM=vscode
| VS Code | , VSCODE_PID, or TERM_PROGRAM_VERSION contains vscode | Visual Studio Code integrated terminal |TERM_PROGRAM=warp
| Warp | | Modern Rust-based terminal |TERM_PROGRAM=wezterm
| WezTerm | | GPU-accelerated terminal emulator |WT_SESSION
| Windows Terminal | present or COMSPEC=wt.exe | Modern tabbed terminal for Windows 10+ |TERM_PROGRAM=xfce4-terminal
| Xfce4 Terminal | | Xfce terminal emulator |TERM=xterm
| Xterm | or TERM=xterm-256color | X Window System terminal emulator |TERM=vt100
| VT100/VT220 | or TERM=vt220 | DEC VT100 and VT220 (and compatible emulators) |TERM=linux
| Linux Console | | Native Linux virtual console |TERM=dopamine
| Dopamine | | Modern terminal emulator |
Notes:
* Detection uses the 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
* Terminal-specific environment variables (like , GHOSTTY_RESOURCES_DIR, ALACRITTY_SOCKET) are checked first as they provide the most reliable detection.COMSPEC
* Variable values are normalized to provide a consistent terminal identifier, regardless of differences in capitalization or formatting.
* Some Windows terminals are detected using Windows-specific variables such as or WT_SESSION.tmux
* Terminal multiplexers such as and GNU Screen are identified through the TERM variable when active. Use preferOuter: true to skip multiplexer detection.unknown
* When running inside Visual Studio Code's integrated terminal, detection relies on specific environment variables set by VS Code.
* Distinctions are maintained between terminal emulators (e.g., iTerm2, Konsole) and shells (e.g., bash, zsh), with shells excluded from the main detection table.
* In the absence of a recognized terminal, a fallback sanitizer produces a normalized identifier or as a last resort.
* The detection logic is designed to cover terminals across UNIX-like systems (Linux, macOS) and Windows, providing broad compatibility for diverse development environments.
* Added preferOuter option to prefer outermost terminal (GUI app) over multiplexers like tmux/screenGHOSTTY_RESOURCES_DIR
* Added Ghostty terminal detection via environment variableALACRITTY_SOCKET
* Added Foot terminal detection (Wayland terminal emulator)
* Added Rio terminal detection (Rust-based GPU-accelerated terminal)
* Improved Alacritty detection with and ALACRITTY_LOG environment variablesKITTY_PID
* Improved Kitty detection with environment variable (most reliable method)TERM=linux
* Added Linux Console detection via TERM_PROGRAM
* Added Dopamine terminal detection
* Reordered detection priority: terminal-specific env vars are now checked before
* Improved terminal detection accuracy with more advanced detection methods
* Added VTE_VERSION detection to properly identify GNOME Terminal when it masquerades as xtermCOLORTERM
* Implemented environment variable scanning to detect Konsole terminals that advertise as xterm
* Enhanced precedence handling for better terminal identificationTERMUX_VERSION
* Added macOS path parsing to extract application names from full paths
* Improved Android/Termux detection with checksWT_SESSION
* Enhanced Windows Terminal detection with prioritization and pwsh support
* Added better error handling with timeouts for shell execution
* Refined process title matching with more precise regex patterns
You might also be interested in:
* cross-capture: Capture screenshots programmatically. Cross-platform, with support for MacOS (Darwin), Windows, and Linux. | homepage, Windows, and Linux.")
* emit-keypress: Drop-dead simple keypress event emitter for Node.js. Create powerful CLI applications and experiences with ease. | homepage
* enquirer: Stylish, intuitive and user-friendly prompt system. Fast and lightweight enough for small projects, powerful and… more | homepage
* open-file-manager-dialog: Cross-platform library for opening a file manager dialog window programmatically on MacOS, Windows, or Linux. | homepage
* open-file-manager: Cross-platform utility to open a file or directory in the system's default file manager (Finder… more | homepage")
* open-finder-dialog: Open a finder dialog window (finder prompt) programmatically. Only works on MacOS. | homepage programmatically. Only works on MacOS.")
* open-linux-file-dialog: Open a file dialog window programmatically to allow the user to select one or more… more | homepage, kdialog (KDE), yad (Yet Another Dialog), qarma (Qt-based), matedialog (MATE), rofi (window switcher wi")
* open-windows-file-dialog: Programmatically open a file dialog window (explorer) for picking files. Only works on Windows. Also… more | homepage for picking files. Only works on Windows. Also see: open-finder-dialog, open-linux-file-dialog, and open-file-manager-dialog for other platforms.")
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
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:
`sh`
$ npm install && npm test
Building docs
_(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:
`sh``
$ npm install -g verbose/verb#dev verb-generate-readme && verb
| Commits | Contributor |
| --- | --- |
| 7 | jonschlinkert |
| 1 | doowb |
Jon Schlinkert
* GitHub Profile
* Twitter Profile
* LinkedIn Profile
Copyright © 2025, Jon Schlinkert.
Released under the MIT License.
*
_This file was generated by verb-generate-readme, v0.8.0, on December 06, 2025._