Bash autocomplete

Bash autocompletion saves time and reduces errors by completing commands, filenames, and more with the Tab
key.
- Edit
~/.bashrc
and add:
bind '"\t":menu-complete'
bind "set show-all-if-ambiguous on"
bind "set completion-ignore-case on"
bind "set menu-complete-display-prefix on"
- Apply changes:
source ~/.bashrc
Now, Tab
cycles completions, shows all options, ignores case, and displays common prefixes. Faster, easier command-line!
Examples:
- Command Completion: Type
git com
and pressTab
. It will likely complete togit commit
. If multiple options exist (likegit compare
), pressingTab
twice shows a list. - Filename Completion: Type
cd Doc
and pressTab
. If a "Documents" directory exists, it completes tocd Documents/
. - Option Completion: Type
ls --l
and pressTab
. It can complete tols --list
or other available options. - Variable Completion: Type
echo $HOME/D
and press tab. It will complete the directories in your home directory that start with D. - User Completion: Type
ssh us
and press tab. It will complete to the users on the system that start with us.
Bash autocomplete: first list files then cycle through them
Is it possible to configure bash in such a way that on the first tab autocomplete it lists all possible files and on subsequent ones cycles through the choices? Both options are easy to do separa…
