I use zsh with the “new” completion system (compinit
). Sometimes I want to restrict completion to a subset of what is possible, to cut down on ambiguity. This is a user choice, not a configuration setting: I want to hit a different key instead of Tab to get a different set of completions. I don't want to configure completions differently for that command. Tab should still do its normal thing.
In some cases, there are workarounds. For example, I have a key bound to _bash_complete-word
, which in most cases completes files. But sometimes I want a less common focus. For example:
- Complete only host names after
scp
, not local file names. - Complete only remote names after
git checkout
, not branch names.
How can I bind a key that will complete remote names after git checkout
, but not branch names? More generally, how can I bind a key to complete something different from what would normally be completed in the current context?