From 0bcf59865d316f929e4b32e691ae1bce8f665d0b Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Wed, 25 Mar 2026 01:16:20 -0400 Subject: [PATCH] fix: hide OSC 7 hook injection from terminal output The CWD hook command was visible to the user. Now wrapped in stty -echo/echo to suppress echo, followed by clear to wipe the screen. Space prefix prevents history recording in most shells. Co-Authored-By: Claude Opus 4.6 (1M context) --- src-tauri/src/ssh/session.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/ssh/session.rs b/src-tauri/src/ssh/session.rs index c36be93..7a0b965 100644 --- a/src-tauri/src/ssh/session.rs +++ b/src-tauri/src/ssh/session.rs @@ -160,15 +160,17 @@ impl SshService { // Inject OSC 7 CWD reporting hook into the user's shell. // This enables SFTP CWD following on all platforms (Linux, macOS, FreeBSD). // Sent via the PTY channel so it configures the interactive shell. + // Wrapped in stty -echo/echo so the command is invisible to the user, + // then clear the line with \r and overwrite with spaces. { let osc7_hook = concat!( - // Detect shell and inject the appropriate hook silently + " stty -echo; ", r#"if [ -n "$ZSH_VERSION" ]; then "#, r#"precmd() { printf '\033]7;file://%s%s\033\\' "$HOST" "$PWD"; }; "#, r#"elif [ -n "$BASH_VERSION" ]; then "#, r#"PROMPT_COMMAND='printf "\033]7;file://%s%s\033\\\\" "$HOSTNAME" "$PWD"'; "#, - r#"fi"#, - "\n" + r#"fi; "#, + "stty echo; clear\n" ); let h = handle.lock().await; let _ = h.data(channel_id, CryptoVec::from_slice(osc7_hook.as_bytes())).await;