Skip to content

Commit

Permalink
Fix shell-integration-features being ignored when `shell-integratio…
Browse files Browse the repository at this point in the history
…n` is `none`
  • Loading branch information
liby committed Jan 14, 2025
1 parent d1fd22a commit f0a83f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/termio/Exec.zig
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,11 @@ const Subprocess = struct {
};

const force: ?shell_integration.Shell = switch (cfg.shell_integration) {
.none => break :shell .{ null, default_shell_command },
.none => {
// Even if shell integration is none, we still want to set up the feature env vars
try shell_integration.setup_features(&env, cfg.shell_integration_features);
break :shell .{ null, default_shell_command };
},
.detect => null,
.bash => .bash,
.elvish => .elvish,
Expand Down
15 changes: 12 additions & 3 deletions src/termio/shell_integration.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down

0 comments on commit f0a83f8

Please sign in to comment.