Another nice feature of the bash shell is command line completion.
You can use the tab key for command line completion and this works on different items.
It works for commands, for variables, and for file names as well.
If you install the bash completion package, you even have some additional completion features.
You should know that this bash completion package in many cases is already
installed. Let me show you how awesome this command line completion is.
Let me start by using sudo user and then I'm pressing tab. What is happening? Nothing.
There's a good reason that nothing is happening, because when you press tab, then the bash shell is trying to complete.
But if there's multiple options, it doesn't show you anything. You need to press the tab key twice and aha. There
I can see there's a handful of commands that are starting with user When I use sudo user helper.
I have no idea what it is by the way, but I'm just pressing the h and then I'm pressing tab again and it completes.
Let's use help and aha. It doesn't have the valid option. That doesn't
matter. This is not about user helper, this is about bash completion.
Now another one is on variables. I'm going to use Echo $his
and pressing tab and that's showing historical tab tab and that is
showing his size. Well, that's convenient. What do we have in there?
We have a value of 1,000.
That's the total size of my bash history. But the thing here is
we have these variables and you can use completion on variables as well.
It also works on file names.
If ever you create a crazy long file name, don't worry, you don't have to type
the entire file name. If you want to remove it, just use RM followed by enough
to uniquely identify the file name and press the tab key. Then it will be removed.
But probably the most powerful feature is within commands.
Let's use sudo IP tab Tab IP is the command that allows
you to do stuff with your IP addresses. I'm making that IP
addr tab tab that should be IP address tab tab.
That's showing all the commands that are available. Well, let's just
use IP address show to show the current IP addresses.
Now the nice thing about these complex commands is that from the bash completion package, you install
additional information on how to complete these complex commands. That means that you don't need to use
help or man pages or whatsoever. You just display everything on screen using tab completion.