Linux Fu: Custom Bash Command Completion

532

If you aren’t a Linux user and you watch someone who knows what they are doing use Bash — the popular command line interpreter — you might get the impression they type much faster than they actually do. That’s because experienced Linux users know that pressing the tab key will tend to complete what they are typing, so you can type just a few characters and get a much longer line of text. The feature is very smart so you may not have realized it, but it knows a good bit about what you could type. For example, if you try to unzip a file, it knows the expected file name probably has a .zip extension.

Turns out completion depends on a particular GNU library known as readline. It reads text for lots of different programs, including Bash and you can configure it using the .inputrc file in your home directory. For example, here’s my .inputrc:

Read more at Hackaday