Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.