Обсуждение: \set to create shortcut

Поиск
Список
Период
Сортировка

\set to create shortcut

От
Fabrice Chapuis
Дата:
Hi,
I want to persist a shortcut between session.
 
postgres [157394]=# \set cs 'select current_schema';
postgres [157394]=# :cs
┌────────────────┐
│ current_schema │
├────────────────┤
│ public         │
└────────────────┘
(1 row)

I put it in .pgsql_profile but it does not work

any idea?

Re: \set to create shortcut

От
Laurenz Albe
Дата:
On Thu, 2024-02-22 at 09:32 +0100, Fabrice Chapuis wrote:
> I want to persist a shortcut between session.
>  
> > postgres [157394]=# \set cs 'select current_schema';
> > postgres [157394]=# :cs
> > ┌────────────────┐
> > │ current_schema │
> > ├────────────────┤
> > │ public         │
> > └────────────────┘
> > (1 row)
>
> I put it in .pgsql_profile but it does not work
>
> any idea?

It works for me if I put the semicolon inside the single quotes.

Yours,
Laurenz Albe

Re: \set to create shortcut

От
Erik Wienhold
Дата:
On 2024-02-22 09:32 +0100, Fabrice Chapuis wrote:
> I want to persist a shortcut between session.
> 
> 
> > postgres [157394]=# \set cs 'select current_schema';
> > postgres [157394]=# :cs
> > ┌────────────────┐
> > │ current_schema │
> > ├────────────────┤
> > │ public         │
> > └────────────────┘
> > (1 row)
> 
> 
> I put it in .pgsql_profile but it does not work
> 
> any idea?

What output do you get?

You should put that \set or \ir .pgsql_profile in .psqlrc which is the
standard file read by psql.

-- 
Erik



Re: \set to create shortcut

От
Fabrice Chapuis
Дата:
Ok I put it  .psqlrc file. It works. Thanks to you
Fabrice

On Thu, Feb 22, 2024 at 10:32 AM Erik Wienhold <ewie@ewie.name> wrote:
On 2024-02-22 09:32 +0100, Fabrice Chapuis wrote:
> I want to persist a shortcut between session.
>
>
> > postgres [157394]=# \set cs 'select current_schema';
> > postgres [157394]=# :cs
> > ┌────────────────┐
> > │ current_schema │
> > ├────────────────┤
> > │ public         │
> > └────────────────┘
> > (1 row)
>
>
> I put it in .pgsql_profile but it does not work
>
> any idea?

What output do you get?

You should put that \set or \ir .pgsql_profile in .psqlrc which is the
standard file read by psql.

--
Erik