Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make bash tab completion behave like vim tab completion and cycle through matching matches?

Tags:

bash

shell

vim

I've been meaning to find a solution for this for YEARS.

I am sooo much more productive in vim when manipulating files than bash for this reason.

If I have

file_12390983421 file_12391983421 file_12340983421 file_12390986421 

In bash and type file_1->tab , it obviously lists:

file_12390983421 file_12391983421 file_12340983421 file_12390986421 

And this is a horrible bore and painful to work with.

The same sequence in vim will loop through the files one at a time.

Please someone tell me how to do this in bash, or if there is another shell that can do this, I'll switch tomorrow.

like image 560
pixelearth Avatar asked Aug 24 '11 17:08

pixelearth


People also ask

Does Bash have tab completion?

Bash completion is a functionality through which Bash helps users type their commands more quickly and easily. It does this by presenting possible options when users press the Tab key while typing a command.

How do you completion a tab in Linux?

Command-line completion allows the user to type the first few characters of a command, program, or filename, and press a completion key (normally Tab ↹ ) to fill in the rest of the item. The user then presses Return or ↵ Enter to run the command or open the file.

How can I tell if I have Bash completion?

You can use the complete command with the -p option to get a list of all or specific completions.


1 Answers

By default TAB is bound to the complete readline command. Your desired behavior would be menu-complete instead. You can change your readlines settings by editing ~/.inputrc. To rebind TAB, add this line:

TAB: menu-complete 

For more details see the READLINE section in man bash.

like image 132
sth Avatar answered Sep 24 '22 22:09

sth