- commit
- d0683a3
- parent
- 1fc6306
- author
- Eric Bower
- date
- 2026-03-11 10:10:31 -0400 EDT
chore(history): bare `zmx history` should try to use `ZMX_SESSION`
2 files changed,
+7,
-2
+3,
-2
1@@ -92,7 +92,8 @@ pub fn main() !void {
2 session_name = arg;
3 }
4 }
5- const sesh = try socket.getSeshName(alloc, session_name orelse "");
6+ const sesh_env = socket.getSeshNameFromEnv();
7+ const sesh = try socket.getSeshName(alloc, session_name orelse sesh_env);
8 defer alloc.free(sesh);
9 return history(&cfg, sesh, format);
10 } else if (std.mem.eql(u8, cmd, "attach") or std.mem.eql(u8, cmd, "a")) {
11@@ -967,7 +968,7 @@ fn history(cfg: *Cfg, session_name: []const u8, format: util.HistoryFormat) !voi
12 }
13
14 fn attach(daemon: *Daemon) !void {
15- if (std.posix.getenv("ZMX_SESSION")) |_| {
16+ if (socket.getSeshNameFromEnv()) |_| {
17 return error.CannotAttachToSessionInSession;
18 }
19
+4,
-0
1@@ -5,6 +5,10 @@ pub fn seshPrefix() []const u8 {
2 return std.posix.getenv("ZMX_SESSION_PREFIX") orelse "";
3 }
4
5+pub fn getSeshNameFromEnv() []const u8 {
6+ return std.posix.getenv("ZMX_SESSION") orelse "";
7+}
8+
9 pub fn getSeshName(alloc: std.mem.Allocator, sesh: []const u8) ![]const u8 {
10 const prefix = seshPrefix();
11 if (prefix.len == 0 and sesh.len == 0) {