A Nicer Tab Autocomplete

If you, like me, rely on tab completion at the command line in Linux or MacOS to help find things for you, it can be annoying when it doesn’t. If you’ve entered a lowercase where the filename has an uppercase, or if there are multiple possible files (in which case double-tab prompts for “show all possible”), autocomplete doesn’t always behave the way one might hope. This is all configurable.

Here’s what I use (these lines are in ~/.inputrc)

set show-all-if-ambiguous on
set show-all-if-unmodified on
set completion-ignore-case on

From the Bash reference manual, here’s what those commands do:

show-all-if-ambiguous

This alters the default behavior of the completion functions. If set to ‘on’, words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. The default value is ‘off’.

show-all-if-unmodified

This alters the default behavior of the completion functions in a fashion similar to show-all-if-ambiguous. If set to ‘on’, words which have more than one possible completion without any possible partial completion (the possible completions don’t share a common prefix) cause the matches to be listed immediately instead of ringing the bell. The default value is ‘off’. completion-map-case If set to ‘on’, and completion-ignore-case is enabled, Readline treats hyphens (‘-’) and underscores (‘_’) as equivalent when performing case-insensitive filename matching and completion.

completion-map-case

If set to ‘on’, and completion-ignore-case is enabled, Readline treats hyphens (‘-’) and underscores (‘_’) as equivalent when performing case-insensitive filename matching and completion.

Advertisements