0

i realized that my zsh does not autocomplete the folders of a SSH server when I am in a local terminal and use cd, rsync or any other command. The bash in Ubuntu does this.

e.g.:

rsync -avh --progress user@host:/folder1/subfolder/another_subf . -n

the command works so I can connect, its just very uncomfortable when you have to type and know every foldername by heart.

1 Answer 1

1

ZSH can tab complete for rsync over SSH; the feature is probably simply not enabled in your ZSH. Here's what I see for a localhost: TAB

% rsync -avz . localhost:
Applications/  Desktop/       Documents/     Downloads/     Library/
...

First, you will ideally need automated login setup, unless you like typing your password after every TAB. For SSH this can be done with public key authentication, among other methods. There are other questions on how to set this up.

Then, in ZSH the completion system will need to be enabled. A minimal test of this is:

% zsh -f
lion% rsync -avz . localhost:
# (remote tab completion is not available, I hit control+c)
lion% autoload -U compinit
lion% compinit
lion% rsync -avz . localhost:
Applications/  Desktop/       Documents/     Downloads/     Library/
...
lion% exit

Therefore you will need to enable the completion system by placing the commands

autoload -U compinit
compinit

into a ZSH "run command", usually ~/.zshrc and then load a new shell with exec zsh -l or some similar action.

5
  • This works for my SSH server. However, maybe it's better to use autoload -Uz?
    – gernophil
    Commented Aug 10, 2022 at 14:15
  • @gernophil uhhhh (... furiously reads zshall for the umpteenth time ...)
    – thrig
    Commented Aug 10, 2022 at 14:18
  • @thrig - run-help may be your friend. :-)
    – fd0
    Commented Aug 10, 2022 at 18:19
  • @fd0 not really, that just runs man which is an order of magnitude (or more) slower than my numan command.
    – thrig
    Commented Aug 10, 2022 at 18:36
  • @gernophil you would only need -z if you have set KSH_AUTOLOAD somewhere prior in your configuration; otherwise, there's not much point to delaying when the compinit code is run given that compinit is run right after the autoload line.
    – thrig
    Commented Aug 11, 2022 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .