Turn on Bash Smart Completion The Bash shell has this sweet feature where you can use the TAB key to auto-complete certain things. For example, when I am in my home directory, the following command:
cd Do[TAB-key]will automatically yield:
cd DocumentsIf you are an absolute novice, like I was, not so long ago, discovering tab completion in the terminal can make you go “Wow!”. Wait till you hear the rest now Though you can use the TAB key to complete the names of files and directories, by default the completion is pretty “dumb”. If you have already typed
cd Dyou would expect that the tab key would cause only the directory names to be completed, but if I try it on my machine, the tab completion tool uses filenames too. Now, don’t despair! There is now a smart bash tab completion trick you can use. Smart completion even complete the arguments to commands!! To enable smart completion, edit your
/etc/bash.bashrcfile. Uncomment the following lines, by removing the # in the beginning of the lines:
#if [ -f /etc/bash_completion ]; then # . /etc/bash_completion #fiNow you can use tab completion to power your way through commands. You can even extend bash smart completion to your own favourite commands
by using , the “complete” utility and
Explaining the nitty-gritty is beyond me. I refer you to the Debian Administration gurus for more information regarding smarter bash completion.
0 comments:
Post a Comment