Re: psql profiles?

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: psql profiles?
Date: 2018-12-07 17:14:37
Message-ID: fb4c121c-0ea9-2d6c-a2ac-18d245a659db@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/07/2018 10:45 AM, Matt Zagrabelny wrote:
>
> On Fri, Dec 7, 2018 at 7:42 AM Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru
> <mailto:a(dot)zakirov(at)postgrespro(dot)ru>> wrote:
>
> On 07.12.2018 01:34, Matt Zagrabelny wrote:
> >
> >
> > On Thu, Dec 6, 2018 at 4:24 PM Alvaro Herrera
> <alvherre(at)2ndquadrant(dot)com <mailto:alvherre(at)2ndquadrant(dot)com>
> > <mailto:alvherre(at)2ndquadrant(dot)com <mailto:alvherre(at)2ndquadrant(dot)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!

I made bash functions to do something similar, with just hardcoded server
names.  It has auto-complete and allows me to use descriptive names instead
of server names and custom postgres versions.

--
Angular momentum makes the world go 'round.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ken Tanzer 2018-12-07 18:40:09 Re: != ANY(array) does not behave as expected
Previous Message s400t 2018-12-07 17:04:38 Re: Importing tab delimited text file using phpPgAdmin 5.1 GUI