> This has been an interesting topic!
I thought I should share the final version as well:
_mm() {
local cur files
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
files=$(find /home/mathias/Videos/movies/ -iname "*.avi" -type f -
printf "%P\n" | grep "${cur}" | sed "s/\\([][\\(\\) ,\']\\)/\\\\\\1/
g")
local IFS=$'\n'
COMPREPLY=(${files})
}
complete -F _mm mm
And the `mm' script needs to append the root folder, of course, like
so:
#!/bin/bash
mplayer "/home/mathias/Videos/movies/$1"
Works quite well. Maybe it will be useful to someone else too.
/Mathias