Command completion in Bash lets the shell offer command-aware matches when Tab is pressed, including subcommands, options, and arguments provided by installed completion scripts. Basic filename completion can work without extra packages, but command-specific completion needs Bash's programmable completion layer and a completion loader.
On Ubuntu and Debian systems, the bash-completion package installs a shared completion loader and the /etc/bash_completion compatibility entry point. Current default Ubuntu startup files already source one of those paths for interactive shells, but older or custom ~/.bashrc files may need the loader added manually.
The package is enabled when an interactive Bash shell can find _comp_complete_load, the on-demand loader function. If that check already prints the function name after reloading ~/.bashrc, the completion loader is active and no startup-file edit is needed.
Related: How to configure Bash login scripts
Related: How to enable bash completion in macOS
Related: How to generate shell completions for Codex
$ shopt progcomp progcomp on
If this returns off, run shopt -s progcomp in the interactive shell or remove the startup-file line that disables progcomp.
$ sudo apt install bash-completion
The package manager prints the normal install summary and finishes by setting up the bash-completion package.
$ ls /etc/bash_completion /etc/bash_completion
Use the existing distro snippet if ~/.bashrc already has one. The short manual snippet below is for custom startup files that do not load bash-completion yet.
$ cp ~/.bashrc ~/.bashrc~
If ~/.bashrc does not exist yet, create it with touch ~/.bashrc before checking or adding the completion loader.
$ source ~/.bashrc $ f=_comp_complete_load $ declare -F "$f" _comp_complete_load
If this command prints _comp_complete_load, skip the ~/.bashrc edit and open a new terminal before using command-specific completion.
. /etc/bash_completion
$ source ~/.bashrc
$ f=_comp_complete_load $ declare -F "$f" _comp_complete_load
The _comp_complete_load function is the bash-completion on-demand loader. It loads command-specific completion files when completion is requested for a command.