From d7ccf454bf7f6962958c509e32a78aebf2caa18a Mon Sep 17 00:00:00 2001 From: Lachlan Donald Date: Mon, 9 Mar 2026 12:09:29 +1100 Subject: [PATCH 1/2] fix(zsh): reset mouse tracking modes in ghostty prompt Amp-Thread-ID: https://ampcode.com/threads/T-019ccf5c-54e4-70dd-a500-fb75d29a883c --- zsh/ghostty.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zsh/ghostty.zsh b/zsh/ghostty.zsh index 4da79a2..eb61301 100644 --- a/zsh/ghostty.zsh +++ b/zsh/ghostty.zsh @@ -10,3 +10,11 @@ set-window-title() { PR_TITLEBAR='' set-window-title # add-zsh-hook precmd set-window-title + +# Reset terminal mouse tracking modes before each prompt. +# Prevents garbage escape sequences after an SSH/tmux session dies. +_reset_mouse_tracking() { + printf '\e[?1000l\e[?1002l\e[?1003l\e[?1006l' +} +autoload -Uz add-zsh-hook +add-zsh-hook precmd _reset_mouse_tracking From 4abe54140128bbfb7ffeb6183486e6bd06b1117d Mon Sep 17 00:00:00 2001 From: Lachlan Donald Date: Mon, 9 Mar 2026 12:13:09 +1100 Subject: [PATCH 2/2] fix(zsh): gate ghostty hooks to ghostty sessions Amp-Thread-ID: https://ampcode.com/threads/T-019ccf5c-54e4-70dd-a500-fb75d29a883c --- zsh/ghostty.zsh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/zsh/ghostty.zsh b/zsh/ghostty.zsh index eb61301..c9269f4 100644 --- a/zsh/ghostty.zsh +++ b/zsh/ghostty.zsh @@ -7,14 +7,16 @@ set-window-title() { echo -ne "$window_title" } -PR_TITLEBAR='' -set-window-title -# add-zsh-hook precmd set-window-title +if [[ "${TERM_PROGRAM:-}" == "ghostty" ]]; then + PR_TITLEBAR='' + set-window-title + # add-zsh-hook precmd set-window-title -# Reset terminal mouse tracking modes before each prompt. -# Prevents garbage escape sequences after an SSH/tmux session dies. -_reset_mouse_tracking() { - printf '\e[?1000l\e[?1002l\e[?1003l\e[?1006l' -} -autoload -Uz add-zsh-hook -add-zsh-hook precmd _reset_mouse_tracking + # Reset terminal mouse tracking modes before each prompt. + # Prevents garbage escape sequences after an SSH/tmux session dies. + _reset_mouse_tracking() { + printf '\e[?1000l\e[?1002l\e[?1003l\e[?1006l' + } + autoload -Uz add-zsh-hook + add-zsh-hook precmd _reset_mouse_tracking +fi