Subject: bug#54270: 29.0.50; tramp doesn't work for zsh with trailing zle_bracketed_paste "2004h"

From: Michael Albinus <[email-masked]>
Date: Sun, 06 Mar 2022 14:00:45 +0100

William Xu <[email-masked]> writes:

Hi William,

> After some debugging, it turns out that zsh is adding some special
> zle_bracketed_paste at the end of the prompt: "~ % [?2004h", which
> makes the regexp matching fail. I have to make below change to fix it.

Indeed. The Tramp manual discusses the issue, and recommends to set on
the remote ~/.zshrc:

--8<---------------cut here---------------start------------->8---
[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return
--8<---------------cut here---------------end--------------->8---

> However, considering zsh has become the default shell in some OSes, like
> macOS, would it be possible to resolve this at tramp? Using changes like
> below? Or make regexp "\\'" be part of user configurable option, like
> tramp-shell-prompt-pattern?

I don't want to change this, due to possible damages for other
configurations. However, the Tramp manual recommends to tell Tramp, that
the remote shell is zsh, see (info "(tramp) Remote shell setup")
Tramp will behave correctly then.

Best regards, Michael.