···2424 COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
2525 fi
2626 ;;
2727+ run)
2828+ # After --, fall back to default file completion
2929+ local i
3030+ for (( i=2; i < COMP_CWORD; i++ )); do
3131+ if [[ "${COMP_WORDS[i]}" == "--" ]]; then
3232+ COMPREPLY=($(compgen -o default -- "${cur}"))
3333+ return
3434+ fi
3535+ done
3636+ # Before --, complete flags
3737+ if [[ "${cur}" == -* ]]; then
3838+ COMPREPLY=($(compgen -W "--detach -d --attach -a" -- "${cur}"))
3939+ fi
4040+ ;;
2741 esac
2842}
2943
+11-2
completions/pty.zsh
···5454 _arguments '1:session:_pty_sessions'
5555 ;;
5656 run)
5757+ # After --, fall back to normal (command + file) completion
5858+ local -i i
5959+ for (( i=1; i <= $#words; i++ )); do
6060+ if [[ "${words[$i]}" == "--" ]]; then
6161+ shift $i words
6262+ (( CURRENT -= i ))
6363+ _normal
6464+ return
6565+ fi
6666+ done
5767 _arguments \
5868 '(-d --detach)'{-d,--detach}'[Create in background]' \
5969 '(-a --attach)'{-a,--attach}'[Attach if already running]' \
6060- '1:name:' \
6161- '*:command:_command_names -e'
7070+ '1:name:'
6271 ;;
6372 esac
6473 ;;
+4-2
src/cli.ts
···258258 process.exit(1);
259259 }
260260261261- // Clean up any dead session with the same name
261261+ // Clean up any dead session with the same name, but preserve cwd
262262+ // so that `run -a` re-creates the session in the original directory.
263263+ const previousCwd = session?.status === "exited" ? session.metadata?.cwd : undefined;
262264 if (session?.status === "exited") {
263265 cleanupAll(name);
264266 }
265267266268 try {
267267- await spawnDaemon(name, command, args, displayCommand);
269269+ await spawnDaemon(name, command, args, displayCommand, previousCwd);
268270 } finally {
269271 releaseLock(name);
270272 }