repos / zmx

session persistence for terminal processes
git clone https://github.com/neurosnap/zmx.git

commit
370157c
parent
e08583b
author
Eric Bower
date
2026-01-08 23:36:08 -0500 EST
fix: spawn as login shell

The `-{shell}` convention signals to most shells that they should behave as if invoked as a login
shell, loading appropriate startup files (like .bash_profile or .zprofile).

Reference: https://github.com/neurosnap/zmx/issues/41
1 files changed,  +4, -1
M src/main.zig
+4, -1
 1@@ -1195,7 +1195,10 @@ fn spawnPty(daemon: *Daemon) !c_int {
 2             std.posix.exit(1);
 3         } else {
 4             const shell = std.posix.getenv("SHELL") orelse "/bin/sh";
 5-            const argv = [_:null]?[*:0]const u8{ shell, null };
 6+            // Use "-shellname" as argv[0] to signal login shell (traditional method)
 7+            var buf: [64]u8 = undefined;
 8+            const login_shell = try std.fmt.bufPrintZ(&buf, "-{s}", .{std.fs.path.basename(shell)});
 9+            const argv = [_:null]?[*:0]const u8{ login_shell, null };
10             const err = std.posix.execveZ(shell, &argv, std.c.environ);
11             std.log.err("execve failed: err={s}", .{@errorName(err)});
12             std.posix.exit(1);