How to use wildcards to auto-complete on remote server in zsh?
One of my favorite features of zsh is auto-complete, especially when I'm completing a filename on a networked machine. But how do you include wildcards (like *) and have it auto-complete on the remote machine?
For instance, say I have file1, file2开发者_开发技巧, and file3 residing on a server; I want to copy all those files to my local machine, so I enter
scp server:~/fi<tab>
zsh then correctly auto-completes to
scp server:~/file
but then when I try to wildcard
scp server:~/file*<tab>
all it does it beep at me (it works correctly if the file paths are local). Is there a set of zsh options that makes this work? I found GLOB_COMPLETE and EXTENDED_GLOB, but the best I could do with any combination of those was to auto-complete a single match, or cycle through all matches, but not expand the auto-complete to all matches (as it does on the local command line). Is that actually possible?
Thanks!
randyAs I've mentioned at superuser: Think setting GLOB_COMPLETE should change this.
setopt GLOB_COMPLETE
From man zshoptions
:
GLOB_COMPLETE
When the current word has a glob pattern, do not insert all the words resulting from the expansion but generate matches as for completion and cycle through them like MENU_COMPLETE. The matches are generated as if a ‘*’ was added to the end of the word, or inserted at the cursor when COMPLETE_IN_WORD is set. This actually uses pattern matching, not globbing, so it works not only for files but for any completion, such as options, user names, etc.
Note that when the pattern matcher is used, matching control (for example, case-insensitive or anchored matching) cannot be used. This limitation only applies when the current word contains a pattern; simply turning on the GLOB_COMPLETE option does not have this effect.
Your example works perfectly fine for me. I don't know what makes it work on my system, but here's what I have set:( alwaystoend cbases extendedglob interactive interactivecomments monitor shinstdin). And my .zshrc has:
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle ':completion:*' max-errors 1 numeric
zstyle ':completion:*' menu select=2
autoload -Uz compinit zsh-mime-setup
compinit
I've the same problem ! I suceed with the follwing command: scp "user@server:/dir/*" localdir
double quote escapes the completion.
精彩评论