Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've noticed that for many of the commands I use in bash I have actually learned how many letters of the command I must type before I can press [TAB] to have bash successfully autocomplete the command. For example when opening chromium I dont usually type the whole command but instead type

$ chrom[TAB][ENTER]

and bash successfully autocompletes the command to chromium before I hit the [ENTER] key. Is there a way to make autocomplete work without having to hit [TAB]? My general thinking is that if I type

$ chrom[ENTER]

bash could check and see that chrom isnt a valid command, but it would make sense to autocomplete it to chromium since that is the only command that starts with chrom

share|improve this question
I prefer having visual feedback which command I execute on the command line, which would be not possible with your suggested autocomplete function. If you want to shorten commonly used commands, you could consider creating an alias: alias chrom='chromium' That would even work if you happen to install a programe named chrome and correctly launch chromium. –  Marco Jun 16 '12 at 12:54
add comment

2 Answers

up vote 1 down vote accepted

This is only an idea, since I feel TAB isn't that hard to hit, muscle memory is an amazing thing.

But if we're going for maximum perverseness:

The BASH shell has a feature involving the 'command_not_found_handler' function, which often is used in many situations as a "Command Not Found" notifier, where it tells you where you might find more information on whatever you mistyped. This is often pre-installed in Ubuntu.

Of course, more information is easily found in the BASH Man Page, try searching for 'not_found'.

This could be beaten into submission and used to implement your 'tab-completion-on-fail^H^H^Henter' desire. Actual code is left as an exercise for the reader.

I fully agree with @Marco above, that I REALLY want the feedback from seeing/knowing what I typed and what I got are substantially similar.

Sounds more like a Microsoft Innovation really.

share|improve this answer
add comment

Aliases are definitely your friend here, for instance I have:

alias code='cd ~/Dropbox/97_2012/work/ror/code'
alias docs='cd ~/Dropbox/97_2012/work/setups'

so I can just type

$ code


$ docs

and I'll get placed in the appropriate directory.

You put these in a .bash_aliases file in your home directory ("~").

You include this (and this code most likely already exists) in your .bashrc file with:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases

If you add them and want to see them immediately, either start a new shell session or run your .bashrc in your current terminal session, e.g. . ~/.bashrc or even just the aliases alone, . ~/.bash_aliases

This is better than the approach you initially outlined for a bunch of reasons and is the approach used by the community to give you this functionality.

share|improve this answer
I'm not sure that's really what the OP is asking for though. There's no autocompletion involved here, and you'd still have to remember the short commands. –  slhck Jun 16 '12 at 14:07
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.