How can I make the completion of the bash tab, for example, the termination of the vim tab and the loop through match matches?

I wanted to find a solution for this for YEARS.

For this reason, I am much more productive in vim when manipulating files than in bash.

if I have

file_12390983421 file_12391983421 file_12340983421 file_12390986421 

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

 file_12390983421 file_12391983421 file_12340983421 file_12390986421 

And it's terribly boring and painful to work with.

The same sequence in vim will iterate over 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 will switch tomorrow.

+70
bash vim shell
Aug 24 '11 at 17:22
source share
5 answers

By default, TAB bound to the complete readline command. Your desired behavior will be menu-complete . You can change the reading settings by editing ~/.inputrc . To restore the TAB , add this line:

 TAB: menu-complete 

See the READLINE section in man bash more details.

+79
Aug 24 2018-11-18T00:
source share

For bash> = 4, you might like these settings:

 # If there are multiple matches for completion, Tab should cycle through them bind 'TAB':menu-complete # Display a list of the matching files bind "set show-all-if-ambiguous on" # Perform partial completion on the first Tab press, # only start cycling full results on the second Tab press bind "set menu-complete-display-prefix on" 

This setting is similar to Vim set wildmode=longest:full:list,full

I extracted these settings from this question on the Unix & Linux site.

+17
Jan 30 '18 at 4:56
source share

At the top

 # cycle forward Control-k: menu-complete # cycle backward Control-j: menu-complete-backward 

you can also consider adding

 # display one column with matches set completion-display-width 1 

This way, you retain the current Tab functionality and make bash display capabilities in a single column. Therefore, instead of

 file_12340983421 file_12390983421 file_12390986421 file_12391983421 

You'll get

 file_12340983421 file_12390983421 file_12390986421 file_12391983421 

PS You can get the latest readline library from this GNU Readline library website .

+14
May 23 '12 at 15:52
source share

Thanks to @sth, I found the best for me:

To save the normal bash tab, then use ctl-f to cycle through if necessary using the menu

put this in your .inputrc file:

 "\Cf": menu-complete 
+6
Aug 25 '11 at 5:17
source share

In my experience, the solution provided in the answer never worked for me completely. TL; DR : Add set -o vi to your ~/.bashrc .

When using menu-complete in combination with vi keyboard shortcuts, I have to make sure my ~/.bashrc has:

 set -o vi 

My ~/.inputrc never enough to have:

 TAB: menu-complete set editing-mode vi set keymap vi 

I am assuming that somehow the set editing-mode and set keymap TAB:... keys are TAB:... settings, but I have not studied the documentation completely to find out why this is.

0
Nov 20 '15 at 0:00
source share



All Articles