Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add open-in-editor feature with Cmd+O shortcut #2

Mergedjuliusmarmingemerged 5 commits intomain fromjuliusmarminge/open-in-editormerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 4 changed files with 124 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
25 additions and 1 deletionapps/desktop/src/main.tsModified
View file
@@ -3,9 +3,10 @@
​
import { spawn } from "node:child_process";
import path from "node:path";
-import { BrowserWindow, app, dialog, ipcMain, session } from "electron";
+import { BrowserWindow, app, dialog, ipcMain, session, shell } from "electron";
​
import {
+ EDITORS,
IPC_CHANNELS,
type TerminalCommandInput,
type TerminalCommandResult,
@@ -125,6 +126,29 @@
}),
​
+ // Shell handlers
+ ipcMain.handle(
+ IPC_CHANNELS.shellOpenInEditor,
+ async (_event, cwd: string, editor: string) => {
+ if (!cwd) throw new Error("cwd is required");
+ const editorDef = EDITORS.find((e) => e.id === editor);
+ if (!editorDef) throw new Error(`Unknown editor: ${editor}`);
+ if (!editorDef.command) {
+ const error = await shell.openPath(cwd);
+ if (error) throw new Error(error);
+ return;
+ }
+ const child = spawn(editorDef.command, [cwd], {