Today's tip is a simple one many experienced users will roll their eyes at, but that is because it is so common and handy to use. When watching and helping people new to Linux, I often see them fail to utilize this powerful tool. They struggle to remember file names and commands and it hurts my soul to watch knowing how much easier it could be for them. Knowing how to use this helps you help yourself. There isn't a day that goes by I don't use this probably a hundred times.
Tab completion
Tab completion is a powerful feature in the Linux terminal that allows you to quickly complete filenames, directory paths, and commands by pressing the 'Tab' key. It can significantly speed up your workflow and reduce the chances of typos.
Benefits of using tab completion:
- Efficiency: Saves time by reducing typing and minimizing errors.
- Discoverability: Helps you discover available commands and file/directory names.
- Accuracy: Reduces typos and potential mistakes.
Using Tab Completion
Completing Commands: Type the start of a command, maybe one you can't quite remember the name of, and press 'Tab' twice to see a list of available commands that match the entered text. If you've typed enough that there will only be one option, it'll complete that one for you.
Completing Filenames and Directories: When typing a file or directory name, press 'Tab' to automatically complete the name. If multiple options match, pressing 'Tab' twice will display the options.
Navigating Directories:
Use tab completion to navigate through directories quickly. For example, type cd /usr/l
and press 'Tab' to complete to /usr/local/
.
Conclusion
It should be noted that tab completion may work slightly different depending on the terminal and other settings you may have. Pressing 'Tab' twice may bring up a full menu to select from for available files or directories, for instance. However, this overview provides the gist of how it works for most any system I regularly come across.
If you feel it lacking remeber that your shell (bash, zsh) is just loading from available functions and completions scripts. Source: https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html