Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVJi9-0003SB-4U for pgsql-general@arkaria.postgresql.org; Fri, 07 Dec 2018 17:14:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gVJi7-0003Qb-UM for pgsql-general@arkaria.postgresql.org; Fri, 07 Dec 2018 17:14:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVJi7-0003QR-H0 for pgsql-general@lists.postgresql.org; Fri, 07 Dec 2018 17:14:43 +0000 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVJi4-0005eY-Ll for pgsql-general@lists.postgresql.org; Fri, 07 Dec 2018 17:14:42 +0000 Received: by mail-oi1-x241.google.com with SMTP id h25so3969084oig.1 for ; Fri, 07 Dec 2018 09:14:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=RIC8OaAXNEcdTsGAGOJDbSf3CIRrX0twgufZPGl7pnc=; b=e3EJi/ZaTeUF7GjcURW6KXOCQNu7OEdcow4bBoHIF+pbPtEklMG5MzXJiPNSk0Z1Hi Ki/nYMDNkx4namvRKQW1+QmiPs9rghVYCdNLrWrsZQvqMFUYXq0qZqPAkZVtrAiqwnDw FbyIbWWAXuaxU1nHE952y1SYQVcIOV4SYEymaXA5QF510FIonoO4a1GHRvgMChx9qpAR pqwnRDSJjx+O99bo5D0nxPJaamSpdp73f9jT2s3m6KOm819TFRiDOf1h18GwTrpm6/75 fshp1cK33y0CvQHXiswGM7iDNe8Qa02UNyjVZ9Rq23c8/X411B/cvvog2TOON/HEVZ/N CbfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=RIC8OaAXNEcdTsGAGOJDbSf3CIRrX0twgufZPGl7pnc=; b=EU6dFIz2KcQlHWWmcYReT0W98ovTadfZBcNDCQ5+RemJ/If36y8p/HSUb3EB4bzBAa siiiAzinO1FbU6ggO/zFh/nEohV0ikRH7pzF7l2UsqO1GYdWgFsn7F+8oT+MYx98lsrL IeeA+pKq+WtpTy9XzCgaKRhCxEPK4nSgyMx8FpABdGr8YMOWhpcrj5muyaBXW9qs1QlJ b1KeJwx8Yk0KeA4qj71bZdtPFR9kmSaGteEe/QQ1B2d9kxlLqls0ZIHQJzaLhVIWB+3o ccRqK6tdx0mOcyN7zuP0lLePWHwYcUcEjdNx0bFmkcvlaBYxRq693DPTSKWOWUiFr+Yb dkcw== X-Gm-Message-State: AA+aEWaOIYO6FenWMm//JevXMYVtD8Dgyq/c1FykQbjDwsyq1A2uXPFR 4uIGFTTrxDPFbqEE2DBSAxuakiwh X-Google-Smtp-Source: AFSGD/VwNRuZ4BN0tfOdmgDdvAsGPDJRENC7trn3JUnR9Ka3KKgPEnalLFwtNiAkZGPat/HN6E8Bww== X-Received: by 2002:aca:3904:: with SMTP id g4mr1814305oia.24.1544202879267; Fri, 07 Dec 2018 09:14:39 -0800 (PST) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id 52sm6765693oti.30.2018.12.07.09.14.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 09:14:38 -0800 (PST) Subject: Re: psql profiles? To: pgsql-general@lists.postgresql.org References: <20181206222318.6jolbk3oscgbvb4c@alvherre.pgsql> <3a918aca-6d16-5799-94cb-daf790128c5d@postgrespro.ru> From: Ron Message-ID: Date: Fri, 7 Dec 2018 11:14:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------3F255E85AD3B0AEE15631030" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------3F255E85AD3B0AEE15631030 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 12/07/2018 10:45 AM, Matt Zagrabelny wrote: > > On Fri, Dec 7, 2018 at 7:42 AM Arthur Zakirov > wrote: > > On 07.12.2018 01:34, Matt Zagrabelny wrote: > > > > > > On Thu, Dec 6, 2018 at 4:24 PM Alvaro Herrera > > > >> > 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. --------------3F255E85AD3B0AEE15631030 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 12/07/2018 10:45 AM, Matt Zagrabelny wrote:

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!

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.
--------------3F255E85AD3B0AEE15631030--