Skip to content

Commit

Permalink
Merge pull request #361 from zacchiro/master
Browse files Browse the repository at this point in the history
Add service=... support to PostgreSQL completion
  • Loading branch information
nicoulaj committed Feb 4, 2016
2 parents 4a23910 + a812877 commit 7a3d28e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/_pgsql_utils
Expand Up @@ -121,11 +121,21 @@ _pgsql_databases () {
local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
_pgsql_get_identity

local _pgsql_services _pgsql_service_files
_pgsql_service_files=(
~/.pg_service.conf
$(pg_config --sysconfdir)/pg_service.conf
)
_pgsql_services=$( grep -h '^\[.*\]' $_pgsql_service_files 2>/dev/null \
| sed -e 's/^\[/service=/' -e 's/\].*$//' )

local _pgsql_db_sql
_pgsql_db_sql="select d.datname from pg_catalog.pg_database d \
where d.datname <> 'template0'"

compadd "$@" - $( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null )
compadd "$@" - \
${(f)_pgsql_services} \
$( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null )
}

_pgsql_encodings () {
Expand Down

0 comments on commit 7a3d28e

Please sign in to comment.