Request: Make remote path completion work for fish and zsh

Would be nice without having to go to bash every time...

Would be nice somebody submits PR:)

Rclone does support fish and zsh to some extent

$ rclone genautocomplete 

Generates a shell completion script for rclone.
Run with `--help` to list the supported shells.

  rclone completion [command]

  completion, genautocomplete

Available Commands:
  bash        Output bash completion script for rclone.
  fish        Output fish completion script for rclone.
  powershell  Output powershell completion script for rclone.
  zsh         Output zsh completion script for rclone.

Give it a try!

I know, I have - that's why I said to the remote path extent!

The other completions appear to be there, but only the bash code, longer and seemingly the product of more effort, has the coolest aspect.

Sorry I missed that.

Currently rclone does bash completion only for this here

However I looked at the help

	// BashCompletionFunction is custom bash functions used by the legacy bash autocompletion generator.
	// For portability with other shells, it is recommended to instead use ValidArgsFunction
	BashCompletionFunction string

And see that way of doing things has been deprecated and we have a new way which will work with all shells

	// ValidArgsFunction is an optional function that provides valid non-flag arguments for shell completion.
	// It is a dynamic version of using ValidArgs.
	// Only one of ValidArgs and ValidArgsFunction can be used for a command.
	ValidArgsFunction func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)

So we should probably switch over to using that.

I had a quick go at this here

v1.65.0-beta.7527.5c9cfbbc8.fix-completion on branch fix-completion (uploaded in 15-30 mins)

Can you give it a try with fish or zsh?

There seems to be something I don't understand (maybe a bug) which is splitting the input on : which I put a workaround in for, but it isn't quite right yet.

Very, very quick test with fish and zsh, literally 2 minutes...

Works in both. Nice. :slightly_smiling_face:

That is encouraging. That code isn't good enough to merge yet as I need to figure out the colon weirdness, but having the completer in go rather than bash is a great step forward.

Another test suggests it is unable to complete a remote path with spaces in. Or one with brackets, it seems.

Which shell are you having a problem with? It worked OK in bash when I tried it.

I rebased the completions patch and updated it to use GenBashCompletionV2 and this seems to fix the problems I was having with it so I think this is ready to go.

Any testing much appreciated :slight_smile:

v1.66.0-beta.7705.c53cc4e24.fix-completion on branch fix-completion (uploaded in 15-30 mins)

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.66

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.