Tip: Autocomplete Arguments in the Terminal on Linux

Share

On Bash and other shells on Linux, it's possible to autocomplete an argument by pressing the Tab key. This can be customized, but it's available by default on Linux Mint without requiring additional customization.

While typing the zeroth argument, you can press the Tab key to autocomplete the the name of the terminal command.

For example, if you type ./sc, and press Tab, it may autocomplete to ./script.sh if you have such file in the current working directory.

You can also autocomplete system utilities like mkdir, but, because the autocomplete searches the entire /usr/bin, it's not very useful. If you type just m, or even mk, there will be dozens of files that start with those characters, so you'll end up having to type the whole thing.

You can also autocomplete the filenames and filepaths passed as arguments to terminal commands. For example, if you type cat fi and press Tab, assuming you have a file called file.txt in the current working directory, it will autocomplete to cat file.txt.

Similarly, you can autocomplete directory names, and files in subdirectories, e.g. if you want to cat important/tasks.txt, you might be able to do it typing cat im, pressing the Tab key to autocomplete cat important/, then typing t, and pressing the Tab key again.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments