Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Linux autocompletion with numbered menu?

I've been trying to find this for a couple of days now and while I am aware that I can write a bash function to get it the way I want, I am sure that this option comes out of the box.

I have recently upgraded to RHEL 7.11 and in previous RHEL versions when using double tab it would display a numbered menu when I had ambiguous options.

Consider this, I have a directory with the following files:

abc  abcd  abcde  abcdef  abcdefg  abcdefgh  abcdefghi

So when I type:

cat abc [tab][tab]

And there were multiple matches, I would get:

1) abc
2) abcd
3) abcde
4) abcdef
5) abcdefg
6) abcdefgh
7) abcdefghi

Subsequently I could type '7' and [tab] and it would concatenate the file at the option 7).

This is super useful when there are a lot of similar options with many files starting with the same characters (as is the case on my server where file names are preceded with system names for clarity).

Any ideas?

like image 922
kjbergman Avatar asked Jul 11 '18 06:07

kjbergman


People also ask

How do you autocomplete in Linux?

When at the MS-DOS, Windows command line or a Linux or Unix shell, typing in long file names or directories can become a burden. Use the Tab to autocomplete the names of directories and files while in the command line.

How do I autocomplete in Vim?

file. to enter the *edit* mode and type any JavaScript keyword in the text editor and press *Ctrl + x* followed by *Ctrl + o*. Vim editor will show the possible auto-complete suggestions.


1 Answers

I recommend https://github.com/junegunn/fzf, I started to replace all my in-shell menu choices with this GREAT tool.

It has bash support, batteries included.

like image 200
torbatamas Avatar answered Oct 16 '22 02:10

torbatamas