Skip to content

Instantly share code, notes, and snippets.

View horsepunchkid's full-sized avatar

Steven N. Severinghaus horsepunchkid

View GitHub Profile
@horsepunchkid
horsepunchkid / psql_bash_completion.sh
Created June 5, 2019 20:46
Bash completion for psql services
_complete_psql() {
services=$(egrep -o '^\[.+\]' ~/.pg_service.conf | cut -f2 -d[ | cut -f1 -d] | sort)
if [[ $services ]]
then
COMPREPLY=( $( compgen -W "$services" -- ${COMP_WORDS[COMP_CWORD]}) )
else
echo
echo "(no services)"
echo -n "> ${COMP_WORDS} "
fi