launch-ide ·
Automatically recognize the editor by running processes and open the specified file in it. It is compatible in Windows, MacOS and Linux.
💡 Why
There are already some tools to open the file in the editor, but launch-ide
has the following advantages:
- Automatically recognize the editor by running processes, you don't need to configure the editor path.
- Launch the ide by the executable file of the editor, so you don't need to install the command line tools of the editor such as
code
. - Support for more editors such as VSCode, Cursor, Windsurf, WebStorm, etc.
- Compatible with platforms such as Windows, MacOS, and Linux.
- Compatible for Chinese characters in the file path.
🛠️ Installation
npm i launch-ide
🚀 Usage
import { launchIDE } from 'launch-ide';
launchIDE({ file: '/Users/zh-lx/Desktop/test.ts', line: 10, column: 20 });
launchIDE({
file: '/Users/zh-lx/Desktop/test.ts',
line: 10,
column: 20,
editor: 'code',
});
📖 Parameters
interface LaunchIDEParams {
file: string;
line?: number;
column?: number;
editor?: string;
format?: string;
method?: 'reuse' | 'new' | 'auto';
onError?: (file: string, error: string) => void;
}
🎨 Supported editors
✍️ Custom editor
There are two ways to specify the editor:
- Specify the editor with IDE encoding name in
launchIDE
.
launchIDE({
file: '/Users/zh-lx/Desktop/test.ts',
line: 10,
column: 20,
editor: 'cursor'
});
- Specify the editor with IDE encoding name in
.env.local
file by CODE_EDITOR
.
CODE_EDITOR=cursor
If you use the editor outside the supported list, you can specify the editor by its executable file path, please refer to Other Editor.