This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

--cwd

Nathan Herald (Apr 13, 2026, 11:05 AM +0200) 80ac3c49 8b1bb701

+14 -3
+4
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 + ## Unreleased 4 + 5 + - Add `--cwd` flag to `pty run` to start a session in a specific directory without needing to `cd` first 6 + 3 7 ## 0.6.0 4 8 5 9 ### Breaking changes
+1 -1
completions/pty.bash
··· 70 70 done 71 71 # Before --, complete flags 72 72 if [[ "${cur}" == -* ]]; then 73 - COMPREPLY=($(compgen -W "--detach -d --attach -a --ephemeral -e --name --tag" -- "${cur}")) 73 + COMPREPLY=($(compgen -W "--detach -d --attach -a --ephemeral -e --name --cwd --tag" -- "${cur}")) 74 74 fi 75 75 ;; 76 76 esac
+1
completions/pty.fish
··· 68 68 complete -c pty -n '__pty_using_command run' -s a -l attach -d 'Attach if already running' 69 69 complete -c pty -n '__pty_using_command run' -s e -l ephemeral -d 'Auto-remove on exit' 70 70 complete -c pty -n '__pty_using_command run' -l name -x -d 'Session name (auto-generated if omitted)' 71 + complete -c pty -n '__pty_using_command run' -l cwd -x -a '(__fish_complete_directories)' -d 'Working directory' 71 72 complete -c pty -n '__pty_using_command run' -l tag -x -d 'Tag session (key=value, repeatable)' 72 73 complete -c pty -n '__pty_using_command run' -F 73 74
+1
completions/pty.zsh
··· 123 123 '(-a --attach)'{-a,--attach}'[Attach if already running]' \ 124 124 '(-e --ephemeral)'{-e,--ephemeral}'[Auto-remove on exit]' \ 125 125 '--name[Session name]:name:' \ 126 + '--cwd[Working directory]:dir:_directories' \ 126 127 '*--tag[Tag session with key=value]:tag:' 127 128 ;; 128 129 esac
+7 -2
src/cli.ts
··· 34 34 pty run -d -- <command> [args...] Create in the background 35 35 pty run -a -- <command> [args...] Create or attach if already running 36 36 pty run --tag key=value -- <command> Tag a session with metadata 37 + pty run --cwd /path -- <command> Run in a specific directory 37 38 pty attach <name> Attach to an existing session 38 39 pty attach -r <name> Attach, auto-restart if exited 39 40 pty peek <name> Print current screen and exit ··· 105 106 let attachExisting = false; 106 107 let ephemeral = false; 107 108 let name: string | null = null; 109 + let cwd: string | null = null; 108 110 const tags: Record<string, string> = {}; 109 111 let i = 1; 110 112 while (i < args.length && args[i] !== "--") { ··· 112 114 else if (args[i] === "-a" || args[i] === "--attach") { attachExisting = true; i++; } 113 115 else if (args[i] === "-e" || args[i] === "--ephemeral") { ephemeral = true; i++; } 114 116 else if (args[i] === "--name" && i + 1 < args.length) { name = args[i + 1]; i += 2; } 117 + else if (args[i] === "--cwd" && i + 1 < args.length) { cwd = args[i + 1]; i += 2; } 115 118 else if (args[i] === "--tag" && i + 1 < args.length) { 116 119 const eq = args[i + 1].indexOf("="); 117 120 if (eq === -1) { ··· 204 207 process.exit(1); 205 208 } 206 209 207 - await cmdRun(name, cmd, cmdArgs, detach, attachExisting, displayCmd, ephemeral, tags); 210 + await cmdRun(name, cmd, cmdArgs, detach, attachExisting, displayCmd, ephemeral, tags, cwd); 208 211 break; 209 212 } 210 213 ··· 476 479 displayCommand: string, 477 480 ephemeral = false, 478 481 tags: Record<string, string> = {}, 482 + explicitCwd: string | null = null, 479 483 ): Promise<void> { 480 484 const session = await getSession(name); 481 485 if (session?.status === "running") { ··· 507 511 508 512 try { 509 513 const tagOpt = Object.keys(tags).length > 0 ? tags : previousTags; 510 - await spawnDaemon({ name, command, args, displayCommand, cwd: previousCwd, ephemeral, tags: tagOpt }); 514 + const cwdOpt = explicitCwd ?? previousCwd; 515 + await spawnDaemon({ name, command, args, displayCommand, cwd: cwdOpt, ephemeral, tags: tagOpt }); 511 516 } finally { 512 517 releaseLock(name); 513 518 }