Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZcey-0006Tz-Lo for pgsql-general@arkaria.postgresql.org; Tue, 07 Mar 2023 19:07:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZcex-00016C-E2 for pgsql-general@arkaria.postgresql.org; Tue, 07 Mar 2023 19:07:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZcex-000163-3K for pgsql-general@lists.postgresql.org; Tue, 07 Mar 2023 19:07:39 +0000 Received: from mout-u-204.mailbox.org ([2001:67c:2050:101:465::204]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZceu-0007rG-5J for pgsql-general@postgresql.org; Tue, 07 Mar 2023 19:07:37 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4PWQ1V3pZcz9sQT; Tue, 7 Mar 2023 20:07:26 +0100 (CET) Date: Tue, 7 Mar 2023 20:07:25 +0100 (CET) From: Erik Wienhold To: Ron , pgsql-general@postgresql.org Message-ID: <1899112657.14571.1678216045978@office.mailbox.org> In-Reply-To: <4eed5377-3603-85b9-965e-f2bcd507c045@gmail.com> References: <4eed5377-3603-85b9-965e-f2bcd507c045@gmail.com> Subject: Re: psql \conninfo in tabular form? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Rspamd-Queue-Id: 4PWQ1V3pZcz9sQT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 07/03/2023 18:58 CET Ron 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: > =C2=A0=C2=A0 keyword=C2=A0 | =C2=A0 value > ------------+----------------------- > =C2=A0 database=C2=A0 | postgres > =C2=A0 user =C2=A0=C2=A0 =C2=A0 | postgres > =C2=A0 host =C2=A0=C2=A0 =C2=A0 | /var/run/postgresql > =C2=A0 port =C2=A0 =C2=A0=C2=A0 |=C2=A0 5433 Define variable conninfo with the query in ~/.psqlrc: =09\set conninfo 'select * from (values (''database'', current_database()),= (''user'', session_user), (''host'', coalesce(inet_server_addr()::text, cu= rrent_setting(''unix_socket_directories''))), (''port'', coalesce(inet_serv= er_port()::text, current_setting(''port'')))) t(keyword, value);' And run it like that: =09postgres=3D# :conninfo =09 keyword | value =09----------+----------------- =09 database | postgres =09 user | ewie =09 host | /run/postgresql =09 port | 5432 =09(4 rows) -- Erik