Bash completion is a wonderful feature that allows you quickly compose complex shell commands. Add muscle memory to the mix, and one-liners will appear on the screen as if you were typing with 20 fingers. Add Bash aliases on top of that, and… you’re back to square one.
Sometimes aliases break the completion functionality, and that can be very annoying. Thankfully, there’s a solution in the form of a Bash script ingeniously called complete_alias.
Setup
Assuming that you already have the bash-completion
package installed (naming may vary on certain Linux distributions), the installation of complete_alias is very simple. Clone complete_alias Git repository:
git clone https://github.com/cykerway/complete-alias.git ~/.complete_alias
Source the complete_alias
script in ~/.bashrc
(or .bash_completion
, if you have one):
|
|
Add definitions for each alias that has broken Bash completion (again in ~/.bashrc
). For example:
|
|
Alternatively, you can complete all your aliases with the following one-liner (after you’ve declared all your aliases):
|
|
Start a new shell session or source ~/.bashrc
in your current session and that’s it.