Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  • log_1.log
  • log_2.log
  • log_2.gz

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.

like image 902
Matt Faus Avatar asked May 29 '13 05:05

Matt Faus


1 Answers

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
like image 182
jaypal singh Avatar answered Nov 17 '22 11:11

jaypal singh