1
00:00:06,580 --> 00:00:09,740
Another nice feature of the
bash shell is command line completion.

2
00:00:10,480 --> 00:00:15,089
You can use the tab key for command
line completion and this works on different items.

3
00:00:15,710 --> 00:00:19,390
It works for commands, for variables,
and for file names as well.

4
00:00:20,550 --> 00:00:25,929
If you install the bash completion package,
you even have some additional completion features.

5
00:00:26,550 --> 00:00:30,185
You should know that this bash
completion package in many cases is already

6
00:00:30,185 --> 00:00:33,820
installed. Let me show you how
awesome this command line completion is.

7
00:00:34,700 --> 00:00:39,700
Let me start by using sudo user and
then I'm pressing tab. What is happening? Nothing.

8
00:00:40,340 --> 00:00:46,580
There's a good reason that nothing is happening, because when
you press tab, then the bash shell is trying to complete.

9
00:00:46,580 --> 00:00:52,820
But if there's multiple options, it doesn't show you anything.
You need to press the tab key twice and aha. There

10
00:00:52,820 --> 00:00:59,060
I can see there's a handful of commands that
are starting with user When I use sudo user helper.

11
00:00:59,359 --> 00:01:05,239
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.

12
00:01:06,040 --> 00:01:10,409
Let's use help and aha. It
doesn't have the valid option. That doesn't

13
00:01:10,409 --> 00:01:14,780
matter. This is not about user
helper, this is about bash completion.

14
00:01:15,340 --> 00:01:20,376
Now another one is on variables.
I'm going to use Echo $his

15
00:01:20,376 --> 00:01:25,413
and pressing tab and that's showing
historical tab tab and that is

16
00:01:25,413 --> 00:01:30,450
showing his size. Well, that's convenient.
What do we have in there?

17
00:01:31,109 --> 00:01:32,170
We have a
value of 1,000.

18
00:01:34,290 --> 00:01:38,090
That's the total size of my
bash history. But the thing here is

19
00:01:38,090 --> 00:01:41,890
we have these variables and you
can use completion on variables as well.

20
00:01:43,209 --> 00:01:44,709
It also works
on file names.

21
00:01:45,670 --> 00:01:50,863
If ever you create a crazy long file
name, don't worry, you don't have to type

22
00:01:50,863 --> 00:01:56,056
the entire file name. If you want to
remove it, just use RM followed by enough

23
00:01:56,056 --> 00:02:01,250
to uniquely identify the file name and press
the tab key. Then it will be removed.

24
00:02:01,969 --> 00:02:06,370
But probably the most
powerful feature is within commands.

25
00:02:07,609 --> 00:02:12,616
Let's use sudo IP tab Tab
IP is the command that allows

26
00:02:12,616 --> 00:02:17,623
you to do stuff with your
IP addresses. I'm making that IP

27
00:02:17,623 --> 00:02:22,629
addr tab tab that should
be IP address tab tab.

28
00:02:23,210 --> 00:02:26,800
That's showing all the commands
that are available. Well, let's just

29
00:02:26,800 --> 00:02:30,389
use IP address show to
show the current IP addresses.

30
00:02:30,969 --> 00:02:37,460
Now the nice thing about these complex commands
is that from the bash completion package, you install

31
00:02:37,460 --> 00:02:43,950
additional information on how to complete these complex
commands. That means that you don't need to use

32
00:02:43,949 --> 00:02:50,439
help or man pages or whatsoever. You
just display everything on screen using tab completion.
