> On 07/03/2023 18:58 CET Ron <ronljohnsonjr@gmail.com> wrote:
>
> v13.10
>
> Instead of a sentence like this:
> You are connected to database "postgres" as user "postgres" via socket in
> "/var/run/postgresql" at port "5433".
>
> I'd rather have something tabular like:
> keyword | value
> ------------+-----------------------
> database | postgres
> user | postgres
> host | /var/run/postgresql
> port | 5433
Define variable conninfo with the query in ~/.psqlrc:
\set conninfo 'select * from (values (''database'', current_database()), (''user'', session_user), (''host'',
coalesce(inet_server_addr()::text,current_setting(''unix_socket_directories''))), (''port'',
coalesce(inet_server_port()::text,current_setting(''port'')))) t(keyword, value);'
And run it like that:
postgres=# :conninfo
keyword | value
----------+-----------------
database | postgres
user | ewie
host | /run/postgresql
port | 5432
(4 rows)
--
Erik