summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-05 19:32:30 -0300
committerGabriel Schneider <[email protected]>2026-08-10 09:17:07 -0300
commit8aafc3fa24c7475a07259eb06cd5d217f510df98 (patch)
tree62115e1ef1f15c57022060124c5ff934b778e169 /src/builtins.zig
parent30a44a55232b829866bc3554647de21929276d1a (diff)
downloadpardes-8aafc3fa24c7475a07259eb06cd5d217f510df98.tar.gz
pardes-8aafc3fa24c7475a07259eb06cd5d217f510df98.zip
add a Shell builtin, default fish, with per-family prompt integration
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