Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Change cd hook in _ssh_hosts



On Thu, Mar 26, 2026 at 6:59 AM <lemen@xxxxxxxxx> wrote:
>
>         function chpwd() { pwd > "$lwd_file" }
>
> When a shell completion uses cd, the hook is also executed and and sets
> the directory accordingly.

There are likely more cases than just _ssh_hosts that assume "cd" has
no side-effects outside the current (sub)shell, including at least the
_cd function for "cd" completion itself.  The question is whether
those would misbehave if changed to "cd -q" (and why they don't use
that already).

In the meantime I suggest this:

function chpwd() { [[ -o zle ]] && pwd > "$lwd_file" }

This updates the file only for "cd" executed at a shell prompt.




Messages sorted by: Reverse Date, Date, Thread, Author