Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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"?

share|improve this question
add comment

3 Answers

up vote 9 down vote accepted

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.

share|improve this answer
    
edited to mention the use of exec bash, as that's quite an important step to make it work! ;) –  Drav Sloan Sep 17 '13 at 19:47
    
Thanks! For anyone who's wondering, this doesn't seem to change the normal functionality; it just adds the shift-tab key combo. –  Erhannis Sep 17 '13 at 20:16
    
Correct, please leave my tab key alone!! :) I'd be upset if that changed :D –  Drav Sloan Sep 17 '13 at 20:18
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.