Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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
Good point. I feel that although they aren't initially looking for this... this might be a good route to take. The OP may implement an answer that does auto-complete and presses [RETURN] and may then find that unintended commands get executed which can be hazardous. Think of delete link with no confirm, a well known problem. That experience may then lead the OP to 'want' to press return and may then like a short alias that will reduce their typing. Maybe! So I am giving information to try and help them going down that path. – Michael Durrant Aug 10 '14 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .