_runpg() { local cur prev; COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ]; then pushd ${PGROOT-/pgsql/}/source > /dev/null 2>&1 _filedir popd > /dev/null 2>&1 return 0; fi if [ $COMP_CWORD -eq 2 ]; then COMPREPLY=( $(compgen -W '$(runpg _commands)' -- $cur )); return 0; fi _filedir } _cdpg() { local cur; COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} pushd ${PGROOT-/pgsql/}/source > /dev/null 2>&1 _filedir -d popd > /dev/null 2>&1 } _postgres() { local cur; COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ "$prev" == "-c" ]; then COMPREPLY=($(compgen -S= -onospace -W '`LC_ALL=C command postgres --describe-config | cut -d" " -f1`' -- $cur)); return 0 fi COMPREPLY=($(compgen -W '-A -B -c -d -D -e -E -F -N -o -P -s -S -f -i -O -t -W --describe-config --help --version' -- $cur)) return 0 } complete -F _runpg runpg complete -S/ -onospace -F _cdpg cdpg complete -F _postgres postgres postmaster