├── .npmrc ├── .gitattributes ├── .gitignore ├── index.test-d.ts ├── .github ├── funding.yml ├── security.md └── workflows │ └── main.yml ├── .editorconfig ├── test.js ├── index.d.ts ├── readme.md ├── index.js ├── package.json └── license /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /index.test-d.ts: -------------------------------------------------------------------------------- 1 | import {expectType} from 'tsd'; 2 | import iterm2Version from './index.js'; 3 | 4 | expectType(iterm2Version()); 5 | -------------------------------------------------------------------------------- /.github/funding.yml: -------------------------------------------------------------------------------- 1 | github: sindresorhus 2 | open_collective: sindresorhus 3 | tidelift: npm/iterm2-version 4 | custom: https://sindresorhus.com/donate 5 | -------------------------------------------------------------------------------- /.github/security.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import iTerm2Version from './index.js'; 3 | 4 | test('main', t => { 5 | if (process.env.CI) { 6 | t.pass(); 7 | return; 8 | } 9 | 10 | const version = iTerm2Version(); 11 | t.true(version.length > 0); 12 | t.is(version[0], '3'); 13 | t.true(iTerm2Version().length > 0); 14 | }); 15 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | Get the [iTerm2](https://www.iterm2.com) version. 3 | 4 | @returns The iTerm2 version. If you're running this on a different terminal or operating system, it will return `undefined`. 5 | 6 | @example 7 | ``` 8 | import iterm2Version from 'iterm2-version'; 9 | 10 | iterm2Version(); 11 | //=> '3.0.15' 12 | ``` 13 | */ 14 | export default function iterm2Version(): string | undefined; 15 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # iterm2-version 2 | 3 | > Get the [iTerm2](https://www.iterm2.com) version 4 | 5 | Note: The `2` in iTerm2 is [part of the name](https://en.wikipedia.org/wiki/ITerm2) and does not indicate the version. 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install iterm2-version 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | import iterm2Version from 'iterm2-version'; 17 | 18 | iterm2Version(); 19 | //=> '3.0.15' 20 | ``` 21 | 22 | If you're running this on a different terminal or operating system, it will return `undefined`. 23 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: macos-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 16 14 | - 14 15 | - 12 16 | steps: 17 | - uses: actions/checkout@v2 18 | - uses: actions/setup-node@v2 19 | with: 20 | node-version: ${{ matrix.node-version }} 21 | - run: npm install 22 | - run: npm test 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import fs from 'node:fs'; 3 | import appPath from 'app-path'; 4 | import plist from 'plist'; 5 | 6 | let version; 7 | 8 | export default function iterm2Version() { 9 | if (process.platform !== 'darwin') { 10 | return; 11 | } 12 | 13 | if (!version) { 14 | if (process.env.TERM_PROGRAM === 'iTerm.app' && process.env.TERM_PROGRAM_VERSION) { 15 | version = process.env.TERM_PROGRAM_VERSION; 16 | } else { 17 | const filePath = path.join(appPath.sync('iTerm'), 'Contents/Info.plist'); 18 | version = plist.parse(fs.readFileSync(filePath, 'utf8')).CFBundleVersion; 19 | } 20 | } 21 | 22 | return version; 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iterm2-version", 3 | "version": "5.0.0", 4 | "description": "Get the iTerm2 version", 5 | "license": "MIT", 6 | "repository": "sindresorhus/iterm2-version", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "exports": "./index.js", 15 | "engines": { 16 | "node": ">=12" 17 | }, 18 | "scripts": { 19 | "test": "xo && ava && tsd" 20 | }, 21 | "files": [ 22 | "index.js", 23 | "index.d.ts" 24 | ], 25 | "keywords": [ 26 | "iterm2", 27 | "iterm", 28 | "terminal", 29 | "app", 30 | "version" 31 | ], 32 | "dependencies": { 33 | "app-path": "^4.0.0", 34 | "plist": "^3.0.2" 35 | }, 36 | "devDependencies": { 37 | "ava": "^3.15.0", 38 | "tsd": "^0.14.0", 39 | "xo": "^0.39.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | --------------------------------------------------------------------------------