1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/// Terminal launcher implementations.
/// Wrap a command line so that, after it exits, the pane/window/tab keeps a
/// fresh interactive login shell instead of closing.
///
/// The tmux and zellij launchers (session, window/tab, panes) run the command
/// *as* the pane's program (`bash -lc <cmd>`), so when the AI tool exits the
/// pane/tab/session closes with it — you lose the worktree context and can't
/// run follow-up commands. WezTerm and iTerm don't have this problem because
/// they type the command into an already-running shell; tmux's own session
/// launcher sidesteps it by `send-keys`-ing into a pre-spawned shell.
///
/// Appending `; exec "${SHELL:-bash}" -l` makes the affected launchers behave
/// the same way: the command runs, then — regardless of its exit code (`;`,
/// not `&&`) — control drops to a fresh login shell in the same cwd. A
/// non-zero exit leaves the user at a prompt with the context intact rather
/// than closing the pane.
///
/// `${SHELL:-bash}` honors the user's login shell when the env var is present
/// (the common case when `gw` is run from an interactive session) and falls
/// back to `bash` otherwise. The result is still meant to be passed to
/// `bash -lc`, so `<cmd>` keeps whatever quoting it already carries.