From 89ac7ac5f6ea3c0d7b69252f09d3ba45f75d24c8 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 3 Jul 2024 10:32:08 -0400 Subject: [PATCH 1/3] termio: add man pages to MANPATH on macOS --- src/termio/Exec.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 0ecde4937..da9ac82c0 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -991,6 +991,26 @@ const Subprocess = struct { } } + // Add the man pages from our application bundle to MANPATH. + if (comptime builtin.target.isDarwin()) { + if (opts.resources_dir) |resources_dir| { + var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; + const dir = try std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir}); + + if (env.get("MANPATH")) |manpath| { + // Append to the existing MANPATH. It's very unlikely that our bundle's + // resources directory already appears here so we don't spend the time + // searching for it. + try env.put( + "MANPATH", + try internal_os.appendEnv(alloc, manpath, dir), + ); + } else { + try env.put("MANPATH", dir); + } + } + } + // Set environment variables used by some programs (such as neovim) to detect // which terminal emulator and version they're running under. try env.put("TERM_PROGRAM", "ghostty"); From 691319f6d72d2837da089a1397652e49a5f339d8 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 3 Jul 2024 10:32:50 -0400 Subject: [PATCH 2/3] termio: remove unnecessary resources_key const --- src/termio/Exec.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index da9ac82c0..fab56576b 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -923,10 +923,9 @@ const Subprocess = struct { errdefer env.deinit(); // If we have a resources dir then set our env var - const resources_key = "GHOSTTY_RESOURCES_DIR"; if (opts.resources_dir) |dir| { log.info("found Ghostty resources dir: {s}", .{dir}); - try env.put(resources_key, dir); + try env.put("GHOSTTY_RESOURCES_DIR", dir); } // Set our TERM var. This is a bit complicated because we want to use From 4d2c98afeae93219aefb5ad2847692e0b58ac8b7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 3 Jul 2024 09:28:50 -0700 Subject: [PATCH 3/3] termio: allow failing to build manpath string --- src/termio/Exec.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index fab56576b..aeff1f0dd 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -992,9 +992,12 @@ const Subprocess = struct { // Add the man pages from our application bundle to MANPATH. if (comptime builtin.target.isDarwin()) { - if (opts.resources_dir) |resources_dir| { + if (opts.resources_dir) |resources_dir| man: { var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; - const dir = try std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir}); + const dir = std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir}) catch |err| { + log.warn("error building manpath, man pages may not be available err={}", .{err}); + break :man; + }; if (env.get("MANPATH")) |manpath| { // Append to the existing MANPATH. It's very unlikely that our bundle's