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 fcdae70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/termio/Exec.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
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 fcdae70

Please sign in to comment.