diff --git a/zsh/ghostty.zsh b/zsh/ghostty.zsh index 4da79a2..c9269f4 100644 --- a/zsh/ghostty.zsh +++ b/zsh/ghostty.zsh @@ -7,6 +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 +fi