Re: psql profiles? - Mailing list pgsql-general

From Matt Zagrabelny
Subject Re: psql profiles?
Date
Msg-id CAOLfK3UL8kjNW24gOB12gq-cJe4admWr1FO0pO03Nt8n7J6MxQ@mail.gmail.com
Whole thread Raw
In response to Re: psql profiles?  (Arthur Zakirov <a.zakirov@postgrespro.ru>)
Responses Re: psql profiles?  (Ron <ronljohnsonjr@gmail.com>)
List pgsql-general

On Fri, Dec 7, 2018 at 7:42 AM Arthur Zakirov <a.zakirov@postgrespro.ru> wrote:
On 07.12.2018 01:34, Matt Zagrabelny wrote:
>
>
> On Thu, Dec 6, 2018 at 4:24 PM Alvaro Herrera <alvherre@2ndquadrant.com
> <mailto:alvherre@2ndquadrant.com>> wrote:
>
>     Sure, just define a pg_service.conf file.
>     https://www.postgresql.org/docs/11/libpq-pgservice.html
>
>
> Thanks Alvaro!
>
> Is there any shorter version than:
>
> psql "service=foo"
>
> ?
>
> If not, I can make a shell alias that puts the "service=$@" into the
> command.



Thanks for the hints and discussion about this.

Here's my final implementation for the curious and to close the loop:

# a zsh function to avoid having to type "service="

$ which pssql
pssql () {
        psql "service=$@"
}

# and a zsh completion function:

$ cat ~/.fpath/_pssql
#compdef pssql

PG_SERVICES_CONF=~/.pg_service.conf

if [[ -r ${PG_SERVICES_CONF} ]]; then
    compadd $(sed -nE 's/^ *\[(.*)\] *$/\1/p' ${PG_SERVICES_CONF})
fi

 It works like a charm!

Thanks for all the help!

-m

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Importing tab delimited text file using phpPgAdmin 5.1 GUI
Next
From:
Date:
Subject: Re: Importing tab delimited text file using phpPgAdmin 5.1 GUI