zsh has a feature where command line tab-completion performs context-aware completions, so you can do things like:

# Good:

$ wget g<tab>    # becomes:
$ wget gopher://

$ wget --hea<tab>    # becomes:
$ wget --header=

I like that feature, but sometimes it prevents me from completing filenames in contexts where zsh thinks something else is more appropriate:

# Bad:

$ file vs-debug.apk
vs-debug.apk: Zip archive data, at least v2.0 to extract
$ adb push v<tab>     # becomes:
$ adb push version

I have ^I bound to expand-or-complete (the default widget). What I would like is to have a different key perform unfiltered filename expansion, eg:

# Desired behaviour:

$ adb push v<shift-tab>     # would become:
$ adb push vs-debug.apk

Nothing I saw in zshzle(1) looked appropriate, but I tried the following other widgets anyway:

  • expand-or-complete-prefix
  • menu-expand-or-complete
  • expand-cmd-path
  • expand-word

I don't want to lose the context-aware completion. Any ideas for how I can perform unfiltered filename expansion/completion using an alternate key binding?

I am using zsh 5.0.2 (x86_64-apple-darwin12.4.0) and zsh 4.3.17 (i686-pc-linux-gnu).

2 Answers 2


There's no built-in widget for that, but it's easy enough to define one. I assume you're using the “new-style” completion system (loaded by compinit).

_complete_files () {
  eval "$_comp_setup"
  _main_complete _files
compdef -k _complete_files complete-word '^X/'

The completion function follows the ones defined in the zsh distribution in Completion/Base. The compdef builtin declares the function as a completion widgets and binds it to a key.


I guess the better way is to make zsh perform correct completions. Take a look at zsh-completions. It is a collection of completions for all kinds of programms. There are also completions for adb.

You must log in to answer this question.

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