Suppose I have a bash function specialcat that cats a file in the ~/Special directoryspecialcat () {    cat ~/Special/$1}Suppose the ~/Special directory was set up like so:mkdir ~/Specialecho This is the first special file > ~/Special/firstfileecho This is the second special file > ~/Special/secondfileThe specialcat function is used like:> specialcat firstfileThis is the first special fileI want to enable argument completion so that> specialcat firstf[TAB]produces> specialcat firstfileregardless of what the current working directory is and what files happen to be there.This is my attempt so far_options_specialcat () {    COMPREPLY=( $(compgen -W $(ls ~/Special)) )}complete -F _options_specialcat specialcatwhich leads to> specialcat firstf[TAB]firstfile   secondfile  > specialcat firstfThat is, pressing tab on a partial file name will display the list of files, but will not complete the command.How do I alter my _options_specialcat function to produce the desired behavior?
How to use bash command completion so that only files within a particular directory are completed?
bash;autocomplete;compgen
You need to filter the list by the current argument, so:COMPREPLY=( $(compgen -W $(ls ~/Special) -- $2) )