UNPKG

detect-terminal

Version:

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

148 lines (147 loc) 3.79 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/process-title.ts var process_title_exports = {}; __export(process_title_exports, { detectFromProcessTitle: () => detectFromProcessTitle, detectFromProcessTitleResult: () => detectFromProcessTitleResult }); module.exports = __toCommonJS(process_title_exports); var detectFromProcessTitleResult = /* @__PURE__ */ __name((options = {}) => { const processTitle = (options.processTitle ?? process.title)?.toLowerCase() ?? ""; if (/^alacritty/.test(processTitle)) { return { terminal: "alacritty", source: "process_title" }; } if (/^kitty/.test(processTitle)) { return { terminal: "kitty", source: "process_title" }; } if (/^wezterm/.test(processTitle)) { return { terminal: "wezterm", source: "process_title" }; } if (/^hyper/.test(processTitle)) { return { terminal: "hyper", source: "process_title" }; } if (/^foot/.test(processTitle)) { return { terminal: "foot", source: "process_title" }; } if (/^rio/.test(processTitle)) { return { terminal: "rio", source: "process_title" }; } if (/^ghostty/.test(processTitle)) { return { terminal: "ghostty", source: "process_title" }; } if (/bash/.test(processTitle)) { return { terminal: "bash", source: "process_title" }; } if (/zsh/.test(processTitle)) { return { terminal: "zsh", source: "process_title" }; } if (/ksh/.test(processTitle)) { return { terminal: "ksh", source: "process_title" }; } if (/fish/.test(processTitle)) { return { terminal: "fish", source: "process_title" }; } if (/csh/.test(processTitle)) { return { terminal: "csh", source: "process_title" }; } if (/tcsh/.test(processTitle)) { return { terminal: "tcsh", source: "process_title" }; } if (/pwsh/.test(processTitle)) { return { terminal: "powershell", source: "process_title" }; } if (/powershell/.test(processTitle)) { return { terminal: "powershell", source: "process_title" }; } if (/cmd/.test(processTitle)) { return { terminal: "cmd", source: "process_title" }; } if (/sh$/.test(processTitle)) { return { terminal: "sh", source: "process_title" }; } if (/^node/.test(processTitle)) { return { terminal: "node", source: "process_title" }; } return null; }, "detectFromProcessTitleResult"); var detectFromProcessTitle = /* @__PURE__ */ __name(() => { return detectFromProcessTitleResult()?.terminal ?? null; }, "detectFromProcessTitle"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { detectFromProcessTitle, detectFromProcessTitleResult }); //# sourceMappingURL=process-title.js.map