Based on jm666
's suggestion and the link provided by Kevin
I now got the following code to work:
_cmd() {
local cur files
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
files=$(ls ~/pdf/)
COMPREPLY=( $(compgen -W "${files}" -- ${cur}) )
}
Note that ls ~/pdf/*.pdf
does not work since it expands to pathname and not filename of each file..