Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of my favorite features of zsh is autocomplete, especially when I'm completing a filename on a networked machine. But how to you include wildcards (like *) and have it autocomplete from 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 autocompletes 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?

share|improve this question

Think setting GLOB_COMPLETE should change this.


From man zshoptions:


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.

share|improve this answer

For whatever reason, you have to escape the glob character when used in the remote path in scp/ssh.

scp server:~/file\*<tab>

This is also true if you want to, say, scp over a bunch of files using a glob (rather than doing glob completion), e.g.

scp server:~/files/project.\* ~/localdir
share|improve this answer

You must log in to answer this question.

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