feat: add SSH integration wrapper for shell integration

- Implements opt-in SSH wrapper following sudo pattern
- Supports term_only, basic, and full integration levels
- Fixes xterm-ghostty TERM compatibility on remote systems
- Propagates shell integration environment variables
- Allows for automatic installation of terminfo if desired
- Addresses GitHub discussions #5892 and #4156
This commit is contained in:
Jason Rayne
2025-06-13 16:11:46 -07:00
parent fa47db5363
commit 142e07c502
9 changed files with 496 additions and 372 deletions

View File

@@ -45,6 +45,7 @@ pub fn setup(
env: *EnvMap,
force_shell: ?Shell,
features: config.ShellIntegrationFeatures,
ssh_integration: config.SSHIntegration,
) !?ShellIntegration {
const exe = if (force_shell) |shell| switch (shell) {
.bash => "bash",
@@ -70,8 +71,9 @@ pub fn setup(
exe,
);
// Setup our feature env vars
// Setup our feature env vars and SSH integration
try setupFeatures(env, features);
try setupSSHIntegration(env, ssh_integration);
return result;
}
@@ -159,6 +161,7 @@ test "force shell" {
&env,
shell,
.{},
.off,
);
try testing.expectEqual(shell, result.?.shell);
}
@@ -224,6 +227,15 @@ test "setup features" {
}
}
pub fn setupSSHIntegration(
env: *EnvMap,
ssh_integration: config.SSHIntegration,
) !void {
if (ssh_integration != .off) {
try env.put("GHOSTTY_SSH_INTEGRATION", @tagName(ssh_integration));
}
}
/// 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