Easy Bash Completion

I’m a lazy/impatient typist and therefore a big fan of shell completion.There’s a lot of good completion support for common programs, but whatif I want to have shell completion for a custom program or shellfunction? A quick and easy way is to bind one of the pre-definedcompletion functions, as I learned today.

Eg. I have a shell function “sshr” to log me into a remote host as root:

sshr() { /usr/bin/ssh "root@$@" ;}

To have the shell use the same expansion rules as regular ssh, bind itlike this:

complete -F _ssh sshr

To get a list of predefined completion rules, run “complete -p”

This and more from