diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 1a3b8cad00..4acb327ccf 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -875,7 +875,7 @@ const Subprocess = struct { }; const force: ?shell_integration.Shell = switch (cfg.shell_integration) { - .none => break :shell .{ null, default_shell_command }, + .none => null, .detect => null, .bash => .bash, .elvish => .elvish, @@ -888,6 +888,12 @@ const Subprocess = struct { default_shell_command, }; + // Even if shell integration is none, we still want to set up the feature env vars + if (cfg.shell_integration == .none) { + try shell_integration.setup_features(&env, cfg.shell_integration_features); + break :shell .{ null, default_shell_command }; + } + const integration = try shell_integration.setup( alloc, dir, diff --git a/src/termio/shell_integration.zig b/src/termio/shell_integration.zig index 8cd2a92ae2..3386fa42d7 100644 --- a/src/termio/shell_integration.zig +++ b/src/termio/shell_integration.zig @@ -114,9 +114,7 @@ pub fn setup( }; // Setup our feature env vars - if (!features.cursor) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR", "1"); - if (!features.sudo) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_SUDO", "1"); - if (!features.title) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_TITLE", "1"); + try setup_features(env, features); return result; } @@ -138,6 +136,17 @@ test "force shell" { } } +/// Setup shell integration feature environment variables without +/// performing full shell integration setup. +pub fn setup_features( + env: *EnvMap, + features: config.ShellIntegrationFeatures, +) !void { + if (!features.cursor) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR", "1"); + if (!features.sudo) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_SUDO", "1"); + if (!features.title) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_TITLE", "1"); +} + /// Setup the bash automatic shell integration. This works by /// starting bash in POSIX mode and using the ENV environment /// variable to load our bash integration script. This prevents