I have a script (let's call it myscript) and I want to enable autocomplete arguments for files with a specific extension (e.g. .txt). I can do this simply with:
complete -f -X '!*.txt' myscript Then, given the files a, b, a.txt, b.txt, and ab.txt typing "myscript" and hitting tab twice gives me:
$ myscript a.txt ab.txt b.txt What I want to do is allow wildcards to filter this further, e.g. if I type "myscript *b*" and hit tab twice I want to see:
$ myscript *b* ab.txt b.txt Unfortunately this doesn't give me any autocompletion. If I remove the custom autocomplete (or pass -o bashdefault to complete) it gives me:
$ myscript *b* ab.txt b b.txt I don't want to see b in the results or have it passed to the script if I hit enter. Is there any way to get around this?
cdseveral times, unanswered so far). It works in zsh.