- commit
- 62d03a0
- parent
- 220db23
- author
- Eric Bower
- date
- 2025-10-13 11:47:19 -0400 EDT
fix: forward TERM to pty
1 files changed,
+8,
-33
+8,
-33
1@@ -621,25 +621,6 @@ fn handlePtyInput(client: *Client, text: []const u8) !void {
2 _ = written;
3 }
4
5-fn respondToDeviceAttributes(session: *Session, data: []const u8) bool {
6- // Primary Device Attributes: CSI c or ESC [ c
7- if (std.mem.indexOf(u8, data, "\x1b[c")) |_| {
8- // VT220 with color and clipboard support
9- const response = "\x1b[?62;22;52c";
10- _ = posix.write(session.pty_master_fd, response) catch return false;
11- std.debug.print("Responded to Primary DA query\n", .{});
12- return true;
13- }
14- // Secondary Device Attributes: CSI > c or ESC [ > c
15- if (std.mem.indexOf(u8, data, "\x1b[>c")) |_| {
16- const response = "\x1b[>1;10;0c";
17- _ = posix.write(session.pty_master_fd, response) catch return false;
18- std.debug.print("Responded to Secondary DA query\n", .{});
19- return true;
20- }
21- return false;
22-}
23-
24 fn handleWindowResize(client: *Client, rows: u16, cols: u16) !void {
25 const session_name = client.attached_session orelse {
26 std.debug.print("Client fd={d} not attached to any session\n", .{client.fd});
27@@ -857,20 +838,6 @@ fn readPtyCallback(
28
29 const valid_data = data[0..valid_len];
30
31- // Intercept Device Attribute queries from shell and respond
32- if (respondToDeviceAttributes(session, valid_data)) {
33- // Query was handled, don't forward to clients or store in buffer
34- stream.read(
35- loop,
36- completion,
37- .{ .slice = &session.pty_read_buffer },
38- PtyReadContext,
39- pty_ctx,
40- readPtyCallback,
41- );
42- return .disarm;
43- }
44-
45 // Store PTY output in buffer for session restore
46 session.buffer.appendSlice(session.allocator, valid_data) catch |err| {
47 std.debug.print("Buffer append error: {s}\n", .{@errorName(err)});
48@@ -1082,6 +1049,14 @@ fn createSession(allocator: std.mem.Allocator, session_name: []const u8) !*Sessi
49 };
50 _ = c.putenv(@ptrCast(zmx_session_var.ptr));
51
52+ // Forward TERM from host machine
53+ if (std.posix.getenv("TERM")) |term| {
54+ const term_var = std.fmt.allocPrint(allocator, "TERM={s}\x00", .{term}) catch {
55+ std.posix.exit(1);
56+ };
57+ _ = c.putenv(@ptrCast(term_var.ptr));
58+ }
59+
60 const shell = std.posix.getenv("SHELL") orelse "/bin/sh";
61 execShellWithPrompt(allocator, session_name, shell);
62 }