For example, if I type in "apt-"and press tab,I can find "apt-get" below.But if I type in "get", "apt-get" cannot appear. How can I do to match not only from the beginning?


As far as I know, it is not possible to search sub strings of all possible commands at a time.

You do though have the option of searching for sub strings of previously typed commands by using Ctrl+R and then typing your sub string. You can press Ctrl+R again to cycle through the previously typed commands containing this sub string


zsh might be able to get you halfway there:

enter image description here enter image description here

For me, zsh seems to prefer prefix completions (file<tab> will get me file filefrag file-roller, -file<tab> will get me apt-file desktop-file-install ecryptfs-rewrite-file grub-file ...). I don't understand the completion system well enough to make zsh do substring matching even if prefix matching works. My completion options:

# The following lines were added by compinstall

zstyle ':completion:*' completer _expand _complete _ignored
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' matcher-list '' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle ':completion:*' squeeze-slashes true

autoload -Uz compinit
# End of lines added by compinstall
  • fish also seems to support this. – Léo Lam Jul 28 '15 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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