Search⌘ K
AI Features

Autocomplete

Explore how Bash autocomplete works for commands and arguments, develop custom autocomplete scripts using functions and arrays, and learn techniques like argument handling with shift and string case manipulation. This lesson helps you improve your command line workflow by making autocomplete tailored to your scripts.

How Important is this Lesson?

In this lesson you will build on what you learned previously about:

  • Bash arrays

  • Terminal escape codes

  • Built-ins

  • Bash functions

  • Bash startup scripts

to comprehend more deeply a feature you will probably use almost every time you use bash.

Autocompleting Commands

If you hit the TAB key on your keyboard twice at the default prompt, then you should see something like this:

Display all 2266 possibilities (y or n)?
Terminal 1
Terminal
Loading...

If you’re brave enough to hit y then you will see a list of all the commands available in your path.

To escape that list, hit q.

Now if you try typing z on a fresh shell command line, and then hit TAB twice, you will likely immediately see the commands available that begin with z.

That’s autocomplete in bash - by default, you get the commands available that match the letters you’ve typed in so far. This is handy if you can only remember part of a command, or you just want to see what commands start with a (try it!).

Autocompleting Arguments

...