summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index aaeab5fa..9fa459f2 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -226,6 +226,27 @@ pub const Theme = struct {
}
};
+/// The binary a NEW terminal execs: `Shell fish`, `Shell zsh`,
+/// `Shell /opt/homebrew/bin/bash`. A bare name is looked up on the shells'
+/// side against the handful of directories a shell actually lives in — not
+/// $PATH, because the lookup has to finish BEFORE the fork (a PATH search
+/// allocates, and nothing between fork and exec may).
+///
+/// Takes a NAME, so it has no leader path and none in the topbar, for the same
+/// reason Theme has neither. Panes already open keep the shell they are
+/// running; this is what the next one starts.
+pub const Shell = struct {
+ pub fn run(c: Ctx) void {
+ const want = std.mem.trim(u8, c.arg orelse return, " \t\r\n");
+ // A name too long for the buffer is not silently truncated into a
+ // DIFFERENT binary — `/very/long/path/to/fish` clipped is a path that
+ // either does not exist or, worse, does.
+ if (want.len == 0 or want.len > c.p.shell_buf.len) return;
+ @memcpy(c.p.shell_buf[0..want.len], want);
+ c.p.shell_len = @intCast(want.len);
+ }
+};
+
/// ...and the list of what Theme takes, as a buffer you walk. Its rows are
/// `Theme <name>` COMMANDS rather than locations, so n/N execute them instead
/// of looking them (output_pane.Traits.executes) and stepping the list wears