We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Tab Completion

Typing out long file paths is slow and boring. That's where the Tab key becomes your friend! If you start typing the name of a file or directory and then hit Tab, your shell will try to autocomplete the name for you.

File Paths

To demonstrate, you can start typing ls w, then press Tab:

ls w
# ls worldbanc/

Since worldbanc is (presumably) the only match, the rest gets filled in for you.

Multiple Matches

Continue typing, adding p, then press Tab again:

ls worldbanc/p
# private public

Since both worldbanc/private/ and worldbanc/public/ match worldbanc/p, the shell lists them. You can type either r or u to narrow the match. In some shells, you may need to press Tab again to see a list of options.

ls worldbanc/pr
# ls worldbanc/private/

pr is just specific enough to match worldbanc/private/!

I rarely type out full file names. I type the first few characters and press Tab.

Commands

Tab completion also works for commands. For example, if clear is the only command your shell is aware of that matches cl, typing cl and then hitting Tab will complete it to clear.

Tools

Many CLI tools support tab completion for their own subcommands and options. A popular example is git. Getting completions for a tool often requires enabling a script in your shell configuration file. We'll explain shell configuration down the road.

Assignment

Use tab completion to view one of WorldBanc's loan products without typing the full path:

cat worldbanc/public/products/loans/sbloc.txt

Submit the shell checks.