@k-electron/k-bench 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/src/server/tmux.js +32 -3
- package/package.json +1 -1
|
@@ -11,12 +11,39 @@ const BELL_OPTION = "@kb-bell";
|
|
|
11
11
|
const BELL_CHANNEL = "kb-bell-changed";
|
|
12
12
|
/** How long a Bell watch waits before trying again after tmux failed it unexpectedly. */
|
|
13
13
|
const BELL_WATCH_RETRY_MS = 1_000;
|
|
14
|
+
/** The owner's login shell. */
|
|
15
|
+
function ownerShell() {
|
|
16
|
+
return userInfo().shell || "/bin/zsh";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What a Session's pane runs: the owner's shell as a login shell, so their PATH and aliases
|
|
20
|
+
* are present even though launchd provides a bare environment, started in `folder`.
|
|
21
|
+
*
|
|
22
|
+
* The `cd` is needed as well as `new-session -c`: tmux ignores `-c` once the tmux server's own
|
|
23
|
+
* working directory has been deleted, and the shell then starts in that deleted folder. That
|
|
24
|
+
* happens to every server an earlier install started, because upgrading deletes the old app
|
|
25
|
+
* folder, which is the launchd working directory. The folder and shell are passed as
|
|
26
|
+
* arguments, never spliced into the script, so no folder name can break or inject into it.
|
|
27
|
+
* The `cd` runs in zsh with no startup files, not /bin/sh: macOS's /bin/sh is bash, which
|
|
28
|
+
* prints a `getcwd` error when it starts in a deleted folder. A failed `cd` (the folder
|
|
29
|
+
* vanished just now) still starts the shell, as tmux alone would have.
|
|
30
|
+
*/
|
|
31
|
+
function sessionCommand(folder) {
|
|
32
|
+
return [
|
|
33
|
+
"/bin/zsh",
|
|
34
|
+
"-f",
|
|
35
|
+
"-c",
|
|
36
|
+
'cd -- "$1"; exec "$2" -l',
|
|
37
|
+
"zsh",
|
|
38
|
+
folder,
|
|
39
|
+
ownerShell(),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
14
42
|
/** Applied to the instance's tmux server whenever a Session is created (idempotent). */
|
|
15
43
|
function serverConfiguration() {
|
|
16
44
|
return [
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
["set", "-g", "default-shell", userInfo().shell || "/bin/zsh"],
|
|
45
|
+
// The shell for any pane tmux starts without a command of its own (`sessionCommand`).
|
|
46
|
+
["set", "-g", "default-shell", ownerShell()],
|
|
20
47
|
["set", "-g", "default-terminal", "tmux-256color"],
|
|
21
48
|
["set", "-g", "status", "off"],
|
|
22
49
|
["set", "-g", "mouse", "on"],
|
|
@@ -85,6 +112,8 @@ export class TmuxDriver {
|
|
|
85
112
|
PREFIX + id,
|
|
86
113
|
"-c",
|
|
87
114
|
folder,
|
|
115
|
+
"--",
|
|
116
|
+
...sessionCommand(folder),
|
|
88
117
|
]);
|
|
89
118
|
// This may have started the tmux server, which a Bell watch idles without.
|
|
90
119
|
for (const watch of this.bellWatches)
|
package/package.json
CHANGED