Autocompletion not working

I'd focus on the command completion first.

You can try to remove the ".zcompdump" in your home directory and re-run the:

autoload -Uz compinit && compinit -I

That got command completion working for me so my whole setup is:

my .zshrc

fpath=(/Users/textere/.zsh/completion $fpath)
autoload -Uz compinit && compinit -I

and I have this in my completion directory that:

textere@seraphim completion % ls -al
total 3960
drwx------  3 textere  staff       96 Dec  7 14:00 .
drwx------  3 textere  staff       96 Dec  7 11:27 ..
-rw-------  1 textere  staff  2027280 Dec  7 11:50 _rclone

That I generated with:

rclone genautocomplete zsh _rclone

Have ~/.zsh-completion in path.

➜  ~ echo $fpath
/home/me/.zsh-completion /home/me/.oh-my-zsh/plugins/git /home/me/.oh-my-zsh/functions /home/me/.oh-my-zsh/completions /usr/share/Modules/init/zsh-functions /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.7.1/functions
➜  .zsh-completion ls -al     
total 1988
drwxr-xr-x.  2 jc jc    4096 Dec  7 22:12 .
drwx------. 35 jc jc    4096 Dec  7 22:16 ..
-rw-r--r--.  1 jc jc 2026434 Dec  7 22:12 _rclone

Also generated _rclone with rclone genautocomplete zsh _rclone.

Could you list your plugins?

Also it might have something to do with rclone having _rclone in the file instead of rclone. As you might see here.


You've reached max number of replies a new user can create. (not new user..?) Please wait 18 hours.


Yes I tried it and got errors.


So I removed oh-my-zsh and got started with the raw zsh installation wizard (understanding it is a huge headache!).
I got command completion with rclone working and I think I know why:
Wizard:
(2) Use the new completion system.
(now at compinstall menu)
2. Matching control: set behaviour for case-insensitive matching,
extended (partial-word) matching and substring matching.
3. Styles for changing the way completions are displayed and inserted.
4. Change whether old-style `compctl' completions will be used.
I set this to true.
and command completion works. Remote completion it just does nothing.


I'm not gonna use raw zsh (too large of a headache). I was on oh-my-zsh, but might move to prezto instead now.

I got command completion working with prezto (only need to add /usr/share/zsh/vendor-completions/ to fpath), but remote path gives me -- no matches found -- . It can't even autocomplete remotes listed in the local config ( something: ). Maybe encrypted config is causing it? Though I did rclone ls remote:, but still nothing.

If it is changed to rclone and not _rclone, command completion stops working for me.

@ncw - I am close to getting autocompletion to work but when I try to source in the bash completion file which it should support, I get:

textere@seraphim Downloads % rclone genautocomplete bash rclone
textere@seraphim Downloads % . ./rclone
./rclone:type:45471: bad option: -t

and I have this in my .zshrc file

# load bashcompinit for some old bash completions
autoload bashcompinit && bashcompinit

and when I try to hit tab, I get:

textere@seraphim Downloads % . ./rclone
./rclone:type:45471: bad option: -t
textere@seraphim Downloads % rclone ls GD:__start_rclone:6: command not found: _init_completion
__start_rclone:6: command not found: _init_completion

so closer!

It would probably be worth finding out what that actually refers to. It is possibly a bash feature that zsh doesn't support?

Seems to be this, but I'm not as familiar with the scripting here to understand the why yet:

if [[ $(type -t compopt) = "builtin" ]]; then
    complete -o default -F __start_rclone rclone
else
    complete -o default -o nospace -F __start_rclone rclone
fi

and seems to be something around the init_completion not working.

Argm shell magic! $(type -t compopt) = "builtin" is checking whether compopt is a builtin or not. Presumably it either will be or won't be so we could replace that test with 0 = 0 (true) or 0 = 1 (false) if you want to see if you can get it going.

Hmm. I'll play a bit more but I'm still getting:

textere@seraphim Downloads % rclone ls GD:__start_rclone:6: command not found: _init_completion
__start_rclone:6: command not found: _init_completion


I tried turning each on and sourcing and still not quite yet.

:frowning: I have to say I'm well out of my depth as far as bash scripting goes now :frowning:

You will also need to add the following line to get that function and the completion working:

autoload compinit && compinit

It's quite the long post so far.

Is already done and that fixes command completion.

The additional question was related to bash completion which will autocomplete your paths and such on your remotes with tab. We were trying to get that to work on zsh as the bash completion bit does not seem to work for me (or OP)

So mine is it's current state is:

textere@seraphim ~ % cat .zshrc
alias home='ssh home'
alias router='ssh router'

PLEXAPI_CONFIG_PATH=/Users/textere/Documents/scripts/plexapi.ini
export PLEXAPI_CONFIG_PATH

fpath=(/Users/textere/.zsh/completion $fpath)
autoload -Uz compinit && compinit -i

# load bashcompinit for some old bash completions
autoload bashcompinit
bashcompinit
source ~/Downloads/rclone

The last 3 lines should make zsh bash completion compatible and allow it work but something isn't working properly with the bash compatibility.

I did read the whole thread but had thought that you may have missed that command in your latest trials.

I too faced the same errors regarding the -t flag & the missing _init_completion command while sourcing the autocomplete script for bash in zsh.

I worked-around the -t flag by replacing it with 0=0 or 0=1 as necessary, as suggested by ncw and solved the missing _init_completion by running the autoload & compinit command: autoload -U +X compinit && compinit

I also have the zsh-completion package installed via brew in case that makes a difference.

Apologies, you can ignore the above post. Turned out it was using the cached completion for zsh instead of the bash completion.

Are you testing with the zsh from brew or the default zsh shell on Catalina? I'm using the stock zsh shell for my stuff.

 zsh --version
zsh 5.7.1 (x86_64-apple-darwin19.0)

And do you have the final bash completion you changed? I can test with that rather than trying to fix it myself.

Yep, I was trying on the default zsh shell on Catalina.

Doesn't really matter much anyway since I did get stuck at the same point.

I did find this PR to make bash completion scripts generated by cobra compatible with zsh:

Will spend some time tomorrow to see if I can get this working using this.

And the latest source for that from kubectl:

I was able to get this working with the following completion script, however, it still doesn't do remote completion, unfortunately.