From 3ca8b97ca7d18efe763af47cd00b212b4f9d6e07 Mon Sep 17 00:00:00 2001 From: Julian Haag Date: Fri, 16 Jan 2026 10:53:50 +0100 Subject: [PATCH 1/2] fix(zsh): strip control characters from window title The zsh shell integration was using `${(V)1}` parameter expansion to set the window title, which converts control characters to their visible escape sequence representations. This caused commands ending with a newline to display as `command\n` in the title bar. Changed to use `${1//[[:cntrl:]]}` which strips control characters entirely, matching the behavior of the bash integration. --- src/shell-integration/zsh/ghostty-integration | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shell-integration/zsh/ghostty-integration b/src/shell-integration/zsh/ghostty-integration index febf3e59c..3648a80c0 100644 --- a/src/shell-integration/zsh/ghostty-integration +++ b/src/shell-integration/zsh/ghostty-integration @@ -204,8 +204,10 @@ _ghostty_deferred_init() { # Enable terminal title changes. functions[_ghostty_precmd]+=" builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${(%):-%(4~|…/%3~|%~)}\"\$'\\a'" + # Strip control characters from the command to avoid displaying escape + # sequences like \n in the title. functions[_ghostty_preexec]+=" - builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${(V)1}\"\$'\\a'" + builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${1//[[:cntrl:]]}\"\$'\\a'" fi if [[ "$GHOSTTY_SHELL_FEATURES" == *"cursor"* ]]; then From ca924f4f4506e72ddaf40d323932750c2ffbfcff Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 16 Jan 2026 08:53:18 -0500 Subject: [PATCH 2/2] zsh: improve title-related comment --- src/shell-integration/zsh/ghostty-integration | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shell-integration/zsh/ghostty-integration b/src/shell-integration/zsh/ghostty-integration index 3648a80c0..3fb3ec19b 100644 --- a/src/shell-integration/zsh/ghostty-integration +++ b/src/shell-integration/zsh/ghostty-integration @@ -201,11 +201,9 @@ _ghostty_deferred_init() { _ghostty_report_pwd if [[ "$GHOSTTY_SHELL_FEATURES" == *"title"* ]]; then - # Enable terminal title changes. + # Enable terminal title changes, formatted for user-friendly display. functions[_ghostty_precmd]+=" builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${(%):-%(4~|…/%3~|%~)}\"\$'\\a'" - # Strip control characters from the command to avoid displaying escape - # sequences like \n in the title. functions[_ghostty_preexec]+=" builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${1//[[:cntrl:]]}\"\$'\\a'" fi