Zsh completion does break with aliases

What is the problem you are having with rclone?

zsh completion is not always doing what it should.

Run the command 'rclone version' and share the full output of the command.

rclone v1.69.1

  • os/version: debian 12.10 (64 bit)
  • os/kernel: 6.1.0-27-amd64 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.24.0
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

This got nothing to do with the actual cloud storage.

The command you were trying to run (eg rclone copy /tmp remote:tmp)

It's not a problem with a specific command. Rather, I am using zsh completion A LOT for everything, including rclone, and the rclone implementation works well enough... so long as the actual commmand word at the beginning of the line is indeed "rclone".
Now I have defined a good few aliases for various rclone things ("rcn" and "rcP" will be two more obvious ones: rclone -n or -P). The problem is that zsh completion for these aliases doesn't work at all. The reason is that the rclone completion (in my case that's /usr/share/zsh/vendor-completions/_rclone) uses rclone itself to generate the completions. Or rather it doesn't use a hardcoded "rclone", it uses the actual command word at the start of the line, ie it tries to run "rcn" or "rcP"... and these, being aliases, of course don't exist as executables. So the exec fails and the completion fails as well. If I create "rcn" and "rcP" (etc) as symlinks for rclone in a directory on the path, all works. But this is ugly.
Suggestion: the code in _rclone that creates the required command to generate the completion details (the few lines after
# Prepare the command to obtain completions
) should check whether the actual first command line word is indeed an executable file and if not should probably fall back to using "rclone". For the time being I have just replaced this:
requestComp="${words[1]} __complete ${words[2,-1]}"
with this hardcoded version:
requestComp="rclone __complete ${words[2,-1]}"
as I haven't looked into all the gory details of how the _rclone completion actually does its job. This seems to work but it's not optimal either.