After some years of "BASHing", I've wrote several custom scripts. Most of them I don't use on a daily basis, so it's easy to forget how I've named them, as consistent as I might try to be.
So I know that if I'm intending to run my FLAC2MP3.bat
, I just write FLA
+TABTAB, and there I have a list of what Bash could find in my $PATH:
FLAC2MP3.bat FLAC2MP3.bat~ FlashPlayerApp.exe FlashPlayerCPLApp.cpl
Is it possible to do the same kind of searching but writing *MP3*
(or anything similar) to search for any files that match the pattern on my PATH? When I do write that and press TAB (once or twice), basically nothing happens.
What I've already tried:
- Although it's not identical to my question, I've tried the answers for "How do I let bash autocomplete wildcards?". They seem to only relate to completions on the current dir contents, which is not my case at all.
- This answer to an almost similar question (but not involving wildcards) seemed like a good idea: using
find
on$PATH
. Although it's not as practical as pressing TAB, it could be a solution. However, I almost got crazy and had no success with variable expansion, since my PATH (as most of Cygwin PATHs) has spaces into some directories, and expansion inserts single quotes when finding them (find \'${PATH/:/\' \'}\' -maxdepth 1 -iname mp3 -print -quit
). In reality, I've lost so much time trying to make this work that it could almost be a separate question.
~/bin/
you can runls ~/bin/*mp3*
. BTW, it's a good idea to write your scripts so that, even if you don't use getopts or getopt or similar for option processing, they all understand at least a-h
and/or--help
option (which displays basic usage info and exits).PATH
(or whatever) element. I use github.com/thrig/scripts/blob/master/filesys/findin.c to do that.