Created
June 5, 2019 20:46
-
-
Save horsepunchkid/8b4e8c37136caea39710371efb5542c6 to your computer and use it in GitHub Desktop.
Bash completion for psql services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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 | |
return 0 | |
} | |
complete -F _complete_psql psql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment