Select a particular result from completion suggestions

Solution 1:

Assuming you are using bash, either add the following to your ~/.bashrc:

bind '"\e[6~": menu-complete'
bind '"\e[5~": menu-complete-backward'

Or to change the defaults for all programs that use the readline completion library, not just bash, create the file ~/.inputrc containing:

$include /etc/inputrc
"\e[6~": menu-complete
"\e[5~": menu-complete-backward

Now when you open a new terminal, you can press:

  • TAB as normal to see available completions.
  • Pg Dn to select the first completion or change to the next one.
  • Pg Up to select the last completion or change to the previous one.
  • Alt+n Pg Dn to select the nth completion or move forward n completions.

So for your example type Pg DnPg Dn or Alt+2Pg Dn to get the second file aww.txt.