Bash autocomplete
Bash autocompletion saves time and reduces errors by completing commands, filenames, and more with the Tab key.
- Edit
~/.bashrcand 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 comand pressTab. It will likely complete togit commit. If multiple options exist (likegit compare), pressingTabtwice shows a list. - Filename Completion: Type
cd Docand pressTab. If a "Documents" directory exists, it completes tocd Documents/. - Option Completion: Type
ls --land pressTab. It can complete tols --listor other available options. - Variable Completion: Type
echo $HOME/Dand press tab. It will complete the directories in your home directory that start with D. - User Completion: Type
ssh usand 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…

