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

Re: Preserve trailing slash after completing remote path



On Sat, Oct 30, 2021 at 7:32 PM Alan <8fvebtoeq87@xxxxxxxxx> wrote:
>
> Does anyone know how I get the behavior of "unsetopt autoremoveslash" with remote paths?

Unfortunately the _remote_files function explicitly passes the
autoremove option to compadd, so the only way to get this to work is
to edit or replace that file.

diff --git a/Completion/Unix/Type/_remote_files
b/Completion/Unix/Type/_remote_files
index b537406a0..93e1b7f43 100644
--- a/Completion/Unix/Type/_remote_files
+++ b/Completion/Unix/Type/_remote_files
@@ -85,12 +85,15 @@ if zstyle -T ":completion:${curcontext}:files"
remote-access; then
     remdispf=( ${(M)remdispf:#${~glob[2]}} )
   fi

+  local -a autoremove
+  [[ -o autoremoveslash ]] && autoremove=(-r "/ \t\n\-")
+
   _tags remote-files
   while _tags; do
     while _next_label remote-files expl ${suf:-remote directory}; do
       [[ -n $suf ]] &&
           compadd "$args[@]" "$expl[@]" -d remdispf --
${(q)remdispf%[*=|]} && ret=0
-      compadd ${suf:+-S/} -r "/ \t\n\-" "$args[@]" "$expl[@]" -d remdispd \
+      compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd \
        -- ${(q)remdispd%/} && ret=0
     done
     (( ret )) || return 0




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