Matt Faus
Matt Faus

Reputation: 6671

How to make bash tab-completion work like windows' cmd.exe?

Say I have a folder with files in it with names like this:

And I want to perform some operation, let's say move, on log_2.gz.

In Windows cmd.exe, I am used to performing these steps:

  1. Type move (and nothing else)
  2. tabtabtab to traverse the tab-complete options until I get to log_2.gz
  3. Type destination

But in bash shell (within iTerm2 on Mac OS X 10.8.3), I have to do something like this:

  1. Type mv l
  2. tab which takes me to log_ and makes an annoying beep sound
  3. Type 2
  4. tab which takes me to log_2. and makes an annoying beep sound
  5. Type g
  6. tab which takes me to log_2.gz and is satisfyingly silent
  7. Type destination

As you can see, bash requires many more steps even when you know the destination filename, but imagine a scenario where you are not really certain what exactly is in the filename (maybe the ls was too long). I often find myself in this scenario after a few tab + typing and am forced to abandon the command, run ls again, copy the filename, maybe even run a pwd to concatenate with the folder, and then resume where I left off. This is very annoying.

Upvotes: 11

Views: 3543

Answers (1)

jaypal singh
jaypal singh

Reputation: 77105

You can add the following in your .inputrc (if you don't have one, then create it) file. Once added, either source the file or logout and log back in.

set show-all-if-ambiguous on
set completion-ignore-case on
TAB: menu-complete

Upvotes: 13

Related Questions