function _connect() { COMPREPLY=() local currentWord=${COMP_WORDS[COMP_CWORD]} local completeHosts=$(cat /etc/passwd|grep "/var/www"|cut -d ':' -f 1) COMPREPLY=($(compgen -W "$completeHosts" -- "$currentWord")) return 0 } complete -F _connect groot