Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssl7Y-00AglN-Ef for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2024 15:37:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ssl7X-00BE7i-Ev for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2024 15:37:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssl7X-00BE7Z-3T for pgsql-general@lists.postgresql.org; Mon, 23 Sep 2024 15:37:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssl7Q-000fSc-Qa for pgsql-general@postgresql.org; Mon, 23 Sep 2024 15:37:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 48NFalSx3085361; Mon, 23 Sep 2024 11:36:47 -0400 From: Tom Lane To: Adrian Klaver cc: Dominique Devienne , Laurenz Albe , Erik Wienhold , Asad Ali , pgsql-general@postgresql.org Subject: Re: Customize psql prompt to show current_role In-reply-to: References: <3079980.1727103295@sss.pgh.pa.us> Comments: In-reply-to Adrian Klaver message dated "Mon, 23 Sep 2024 08:16:53 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3085359.1727105807.1@sss.pgh.pa.us> Date: Mon, 23 Sep 2024 11:36:47 -0400 Message-ID: <3085360.1727105807@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Adrian Klaver writes: > On 9/23/24 08:07, Dominique Devienne wrote: >> I often resort to \conninfo, but it's less automatic and >> harder to visually parse (IMHO) compared to a custom ad-hoc prompt. > For me that shows the user that connected(session_user) not the > current_user. Worse than that: what it reports is libpq's PQuser(), that is the name that was used to log in with. But if what you want is the session_user, psql prompts already have %n for that. regards, tom lane