Ok; suppose I'm in Bash and I have several files in a folder. Several of them are named file☠☡☢☣.txt
, where ☠☡☢☣
starts with crazy untypable unicode characters. How would I refer to one of them? Pushing tab only auto-completes to file
, and then it wants you to type a crazy character. Is there some way to tell bash "select the 3rd one in that list you just gave me"?

- 829,060

- 229
3 Answers
I would suggest you work around it and use another type of key binding with readline, such as Shift+TAB.
Add the following to your ~/.inputrc
:
"\e[Z": menu-complete
Then issue an exec bash
(this should then read the settings in your ~/.inputrc
). As a one-off, instead of restarting bash, you can set up the same binding by running bind '"\e[Z": menu-complete'
.
You should now be able to use repeated ShiftTAB sequences to cycle through the filenames that match (rather than having to input the next matching character). This will work for any command issued (as it's a standard read-line command that is being bound to the ShiftTAB sequence). As noted by the OP, this does not effect the standard behavior of the TAB key, it just adds the functionality of the ShiftTAB combo.

- 14,345
- 4
- 45
- 43
Another way that works sometimes is to use ?
or *
globbing wildcards and then typing some of the remainder of "stuff" until you get a unique match with tab completion.

- 3,373
Go to the directory containing file☠☡☢☣.txt
and enter ls -i
. You will see the line:
xxxxx file☠☡☢☣.txt
where xxxxx
is the index number of file☠☡☢☣.txt
. Enter:
find . -maxdepth 1 -inum xxxxx -exec /bin/mv -i {} bettername.txt \;
where xxxxx
on the preceding line is the aforementioned index number obtained from ls -i
. This renames file☠☡☢☣.txt
as bettername.txt
.

- 1,811
exec bash
, as that's quite an important step to make it work! ;) – Drav Sloan Sep 17 '13 at 19:47