Turn on Bash Smart Completion January 28, 2006
Posted by Carthik in administration, commands, snippets, ubuntu.trackback
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 Documents
If 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 D you 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.bashrc file. Uncomment the following lines, by removing the # in the beginning of the lines:
#if [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
#fi
Now 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 /etc/bash_completion, the “complete” utility and /etc/bash_completion.d . Explaining the nitty-gritty is beyond me. I refer you to the Debian Administration gurus for more information regarding smarter bash completion.







good to know!
[...] Another sweet little tip from the Ubuntu Blog: 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 Documents If 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 [...]
I love little things like this which make Ubuntu a much better place
I need to try this. I’ve been wondering if it was possible to auto-complete command arguments.
You can also edit `~/.bashrc` to enable it only for yourself if you don’t want to disturb anybody else or you don’t have the privileges to edit `/etc/bash.bashrc`.
Oh!…
I was really tired of losing tab completion when running anything under sudo…
I come from Debian and doing sudo just everytime is horrible… This stupid trick makes things much easyer.
Thanks!
ozroc, just switch to root using “sudo su”
This is now turned on by default in Kubuntu at least (as of 6.06) and is a pain in the backside as the behaviour isn’t correct in many situations.
So, here is how to turn it off http://www.revis.co.uk/site/?q=node/110 (and reasons why you should, and some workarounds).
Anyone know where to submit a bug report?
ozroc, just switch to root using “sudo su”
“sudo -l” is safer i thought
[...] keep the version number. Otherwise alien adds a “1″ to the version number. – Tip: Use Smart Tab Completion to avoid mistyping the file [...]
thanx!thats what i searched
THANK YOU!!! It was working, reinstalled, and it stopped.
Great! Thanks! Indeed a supplement to my learning at http://www.mlmtraining.com
[...] check this out (better than fixed) http://ubuntu.wordpress.com/2006/01/28/turn-on-bash-smart-completion/ [...]
How about this line to .bashrc
bind ‘set completion-ignore-case on’
Now cd doc[TAB]
yields cd Documents
Somebody likes somebody does not like.
[...] http://ubuntu.wordpress.com/2006/01/28/turn-on-bash-smart-completion/ [...]
[...] and it’s too late in the day for extra caffeine, so that’ll have to be it. But, look here for tips on making your tab completion more powerful. It’ll even complete command line [...]
It might help =) http://gentoo-wiki.com/TIP_Use_TAB-completion_when_emerging_packages
[...] http://ubuntu.wordpress.com/2006/01/28/turn-on-bash-smart-completion/ [...]
Hmm. Have to say I just searched for this page … so I could turn “smart” (AKA brain damaged) completion OFF. Can’t bear the way it thinks it’s being clever, and either hides files from me (“I’m sure that file is in that directory, you know”) or invents gibberish (on /media devices, in particular). This is on Ubuntu 8.04.
[...] will keep the version number. Otherwise alien adds a “1″ to the version number. – Tip: Use Smart Tab Completion to avoid mistyping the file [...]
@Araneidae
Agreed. I turned the damned thing off because it’s a right pain in the arse and kept getting in my way. For example try tab-completing to unzip a file that doesn’t end in extension .zip. It won’t let you. You either have to rename the file first, or work around it somehow (like type ‘ls’, then tab-complete the filename, then backup to replace ‘ls’ with ‘unzip’).
I can’t stand software that thinks it knows what I’m doing better than I do.
Hi!
I am not used to hit the tab twice when a file name is not unique. For example when you have two files like result.dat and residuals.dat and you type res[TAB] nothing happens. You have to hit the TAB twice to see the list of all files starting with res . Is there a way to turn this to me unexpected behaviour off? I mean to see the list of all files starting with res hitting TAB once instead of twice?
[...] Turn on bash auto-complete. (Source) sudo gedit /etc/bash.bashrc # Uncomment these 3 lines. #if [ -f /etc/bash_completion ]; then # . [...]
Thank you for the opportunity you gave
@23:
Put “set show-all-if-ambiguous on” in your /etc/inputrc or ~/.inputrc to make single tab show all
Quite some time ago I put together ClearCase UNIX tools completion for Bash. Have a look at it if you’re using ccase with bash or if you’re looking to write your own completion script: http://jan.tomka.name/project/clearcase-completion-bash
sağlık iksiri
Biber hapı ile zayıflarken stres gibi faktörlerini de en aşağıya indirebilirsiniz. Stresli olduğumuz durumlarda daha fazla yemek yeriz ve daha fazla kilo alırız. Bu stresi en azına indirebiliriz ve biber hapı ile destekleyerek daha iyi kilo verebiliriz.
Thanq,this is what I need
[...] Turn on bash auto-complete. (Source) sudo gedit /etc/bash.bashrc # Uncomment these 3 lines. #if [ -f /etc/bash_completion ]; then # . [...]
I am new to UBUNTU and finding it awesome ………
Thanks for helpful information bayan escort siteleri you catch up us with your sagol instructional çok explanation.
This was greatly helpful for me when I went from an USB Stick Live Ubuntu 10.04 (Lucid Lynx LTS) installation to my LTS-upto-LTS replaced HDD installation, and while it was working perfect with USB Live, it seemed to me that I did it somewhere wrong.
You saved some time for me, fellow.
thanks so much all admin turkiyenin 1 numarali eskort ilan sitesi.
thankss good bloq.
I need to try this. I’ve been wondering if it was possible to auto-complete command arguments.
[...] above was tested on Ubuntu 10.04. See http://embraceubuntu.com/2006/01/28/turn-on-bash-smart-completion/ for some more information for bash completion for the root user. Bash, Bash Completion, Linux, [...]
This is now turned on by default in Kubuntu at least (as of 6.06) and is a pain in the backside as the behaviour isn’t correct in many situations.
Health has been good to your site on your hands
Health has been good to your site on your hands
Health has been good to your site on your hands
I like the valuable information you provide to your articles. I will bookmark your blog and test once more right here frequently. I am reasonably sure I will be told many new stuff proper right here! Best of luck for the next!
Many thanks sharing fantastic informations. Ones websiteis consequently cool. We are impressed from the main factors that you’ve with this blog. The item reveals precisely how nicely people perceive this specific subject. Thank your share with me! http://www.fakeray-bansunglasses.com.
antalya ev ilaçlama
[...] http://embraceubuntu.com/2006/01/28/turn-on-bash-smart-completion/ LD_AddCustomAttr("AdOpt", "1"); LD_AddCustomAttr("Origin", "other"); [...]
It still works in 2012. (Meanwhile it is included in Ubuntu, I am not sure if it was in 6.04 too)
But it also very useful for other distros (I use BackTrack)
Thanks, I used your instructions to disable it under ~/.bashrc
Found it very annoying when it was stopping tab completion for things like:
$ sudo cryptsetup luksClose /dev/mapper/ [TAB] – doesn’t work!
But try:
$ cryptsetup luksOpen /dev/mapper/ [TAB] – that does work!