- commit
- dc63137
- parent
- a65a2b0
- author
- Jesse Farebrother
- date
- 2025-12-05 16:39:19 -0500 EST
feat: add version command
3 files changed,
+19,
-1
+1,
-0
1@@ -48,6 +48,7 @@ Commands:
2 [d]etach Detach all clients from current session (ctrl+\ for current client)
3 [l]ist List active sessions
4 [k]ill <name> Kill a session and all attached clients
5+ [v]ersion Show version information
6 [h]elp Show this help message
7 ```
8
+3,
-0
1@@ -21,6 +21,7 @@ pub fn build(b: *std.Build) void {
2
3 const options = b.addOptions();
4 options.addOption([]const u8, "version", version);
5+ options.addOption([]const u8, "ghostty_version", @import("build.zig.zon").dependencies.ghostty.hash);
6
7 const exe_mod = b.createModule(.{
8 .root_source_file = b.path("src/main.zig"),
9@@ -146,3 +147,5 @@ pub fn build(b: *std.Build) void {
10 upload_step.dependOn(&rsync_docs.step);
11 upload_step.dependOn(&rsync_dist.step);
12 }
13+
14+
+15,
-1
1@@ -1,10 +1,14 @@
2 const std = @import("std");
3 const posix = std.posix;
4 const builtin = @import("builtin");
5+const build_options = @import("build_options");
6 const ghostty_vt = @import("ghostty-vt");
7 const ipc = @import("ipc.zig");
8 const log = @import("log.zig");
9
10+pub const version = build_options.version;
11+pub const ghostty_version = build_options.ghostty_version;
12+
13 var log_system = log.LogSystem{};
14
15 pub const std_options: std.Options = .{
16@@ -175,7 +179,9 @@ pub fn main() !void {
17 return list(&cfg);
18 };
19
20- if (std.mem.eql(u8, cmd, "help") or std.mem.eql(u8, cmd, "h") or std.mem.eql(u8, cmd, "-h")) {
21+ if (std.mem.eql(u8, cmd, "version") or std.mem.eql(u8, cmd, "v") or std.mem.eql(u8, cmd, "-v") or std.mem.eql(u8, cmd, "--version")) {
22+ return printVersion();
23+ } else if (std.mem.eql(u8, cmd, "help") or std.mem.eql(u8, cmd, "h") or std.mem.eql(u8, cmd, "-h")) {
24 return help();
25 } else if (std.mem.eql(u8, cmd, "list") or std.mem.eql(u8, cmd, "l")) {
26 return list(&cfg);
27@@ -220,6 +226,13 @@ pub fn main() !void {
28 }
29 }
30
31+fn printVersion() !void {
32+ var buf: [256]u8 = undefined;
33+ var w = std.fs.File.stdout().writer(&buf);
34+ try w.interface.print("zmx {s}\nghostty-vt {s}\n", .{ version, ghostty_version });
35+ try w.interface.flush();
36+}
37+
38 fn help() !void {
39 const help_text =
40 \\zmx - session persistence for terminal processes
41@@ -231,6 +244,7 @@ fn help() !void {
42 \\ [d]etach Detach all clients from current session (ctrl+\ for current client)
43 \\ [l]ist List active sessions
44 \\ [k]ill <name> Kill a session and all attached clients
45+ \\ [v]ersion Show version information
46 \\ [h]elp Show this help message
47 \\
48 ;