( terminal: TerminalInfo, claudePath: string, claudeArgs: string[], cwd?: string, )
| 357 | } |
| 358 | |
| 359 | async function launchLinuxTerminal( |
| 360 | terminal: TerminalInfo, |
| 361 | claudePath: string, |
| 362 | claudeArgs: string[], |
| 363 | cwd?: string, |
| 364 | ): Promise<boolean> { |
| 365 | // All Linux paths are pure argv. Each terminal's --working-directory |
| 366 | // (or equivalent) sets cwd natively; the command is exec'd directly. |
| 367 | // For the few terminals without a cwd flag (xterm, and the opaque |
| 368 | // x-terminal-emulator / $TERMINAL), spawn({cwd}) sets the terminal |
| 369 | // process's cwd — most inherit it for the child. |
| 370 | |
| 371 | let args: string[] |
| 372 | let spawnCwd: string | undefined |
| 373 | |
| 374 | switch (terminal.name) { |
| 375 | case 'gnome-terminal': |
| 376 | args = cwd ? [`--working-directory=${cwd}`, '--'] : ['--'] |
| 377 | args.push(claudePath, ...claudeArgs) |
| 378 | break |
| 379 | case 'konsole': |
| 380 | args = cwd ? ['--workdir', cwd, '-e'] : ['-e'] |
| 381 | args.push(claudePath, ...claudeArgs) |
| 382 | break |
| 383 | case 'kitty': |
| 384 | args = cwd ? ['--directory', cwd] : [] |
| 385 | args.push(claudePath, ...claudeArgs) |
| 386 | break |
| 387 | case 'wezterm': |
| 388 | args = cwd ? ['start', '--cwd', cwd, '--'] : ['start', '--'] |
| 389 | args.push(claudePath, ...claudeArgs) |
| 390 | break |
| 391 | case 'alacritty': |
| 392 | args = cwd ? ['--working-directory', cwd, '-e'] : ['-e'] |
| 393 | args.push(claudePath, ...claudeArgs) |
| 394 | break |
| 395 | case 'ghostty': |
| 396 | args = cwd ? [`--working-directory=${cwd}`, '-e'] : ['-e'] |
| 397 | args.push(claudePath, ...claudeArgs) |
| 398 | break |
| 399 | case 'xfce4-terminal': |
| 400 | case 'mate-terminal': |
| 401 | args = cwd ? [`--working-directory=${cwd}`, '-x'] : ['-x'] |
| 402 | args.push(claudePath, ...claudeArgs) |
| 403 | break |
| 404 | case 'tilix': |
| 405 | args = cwd ? [`--working-directory=${cwd}`, '-e'] : ['-e'] |
| 406 | args.push(claudePath, ...claudeArgs) |
| 407 | break |
| 408 | default: |
| 409 | // xterm, x-terminal-emulator, $TERMINAL — no reliable cwd flag. |
| 410 | // spawn({cwd}) sets the terminal's own cwd; most inherit. |
| 411 | args = ['-e', claudePath, ...claudeArgs] |
| 412 | spawnCwd = cwd |
| 413 | break |
| 414 | } |
| 415 | |
| 416 | return spawnDetached(terminal.command, args, { cwd: spawnCwd }) |
no test coverage detected