From 9434203725f68283b8346705bd1a339b18eabf85 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sun, 11 Jan 2026 17:05:08 -0500 Subject: [PATCH] shell-integration: always set up XDG_DATA_DIRS for nushell This makes our 'ghostty' module available even if the rest of our automatic integration steps fail, which is convenient for manual "use"-age. This is safe because autoload-ing our module doesn't have any side effects other than cleaning up the XDG_DATA_DIRS environment variable. --- src/termio/shell_integration.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/termio/shell_integration.zig b/src/termio/shell_integration.zig index 94000110a..ab6dcd6ff 100644 --- a/src/termio/shell_integration.zig +++ b/src/termio/shell_integration.zig @@ -732,6 +732,11 @@ fn setupNushell( resource_dir: []const u8, env: *EnvMap, ) !?config.Command { + // Add our XDG_DATA_DIRS entry (for nushell/vendor/autoload/). This + // makes our 'ghostty' module automatically available, even if any + // of the later checks abort the rest of our automatic integration. + if (!try setupXdgDataDirs(alloc, resource_dir, env)) return null; + var stack_fallback = std.heap.stackFallback(4096, alloc); var cmd = internal_os.shell.ShellCommandBuilder.init(stack_fallback.get()); defer cmd.deinit(); @@ -783,8 +788,6 @@ fn setupNushell( } } - if (!try setupXdgDataDirs(alloc, resource_dir, env)) return null; - // Return a copy of our modified command line to use as the shell command. return .{ .shell = try alloc.dupeZ(u8, try cmd.toOwnedSlice()) }; } @@ -836,7 +839,8 @@ test "nushell: unsupported options" { defer env.deinit(); try testing.expect(try setupNushell(alloc, .{ .shell = cmdline }, res.path, &env) == null); - try testing.expectEqual(0, env.count()); + try testing.expect(env.get("XDG_DATA_DIRS") != null); + try testing.expect(env.get("GHOSTTY_SHELL_INTEGRATION_XDG_DIR") != null); } }