In a bash completion script, suppose COMPREPLY=(aa/ba/ aa/bb/)
. When the script is invoked, the completion options looks like this to the user:
This piece of code taken from debian sid /etc/bash_completion should help:
# Remove colon-word prefix from COMPREPLY items
local colon_word=${1%${1##*:}}
local i=${#COMPREPLY[*]}
while [ $((--i)) -ge 0 ]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
done
I was having the same problem and I fixed it by adjusting how I bound the completion function to the command. I know this works when you are dealing with actual files in the filesystem, I think it will work with any sort of file path like options, but I'm not sure.
Before:
complete -F _fubar fubar
After:
complete -o filenames -F _fubar fubar
For more details: Programmable Completion Builtins