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 1ssioI-00APg2-R4 for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2024 13:09:03 +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 1ssioI-008pDn-84 for pgsql-general@arkaria.postgresql.org; Mon, 23 Sep 2024 13:09:02 +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 1ssioH-008pDe-TK for pgsql-general@lists.postgresql.org; Mon, 23 Sep 2024 13:09:01 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ssioF-000eHs-Fq for pgsql-general@postgresql.org; Mon, 23 Sep 2024 13:09:00 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-5e1b55346c0so1624292eaf.3 for ; Mon, 23 Sep 2024 06:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727096939; x=1727701739; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IQE/I5sLtzBQCKJ4fXQCZ4KFxSa++tWKnvbrznHnV+g=; b=Kfahvn5hh9BKP5YDk0+ttZE6TqU4ry23SwUh3YmsP8PzGbxrFmBlGvBXAfHFz8N1mI WpgVZ8kFyFVRtlzbEv/4FBuYmhRv9KLMJvKQ3VINjM+TvT7ywKDWx0A/MD2OQGU1IHIz 6SF2rCi+DanaWoLjN3h85b54cGpQE56yD9X8u6kunAQVFmiwHRDuBVGRkMNCYlQj18SU OFzRg/HS0xyH4op6cjrZkIuTfgrZOwQbrcB8RsGtHQi3QNDDmMXYmcd/otAW6xzyVIhk IKZGKVGdgX3SsjHehUtYSGAvLFqZ7juC104LgPkNstSZ7PuKrwTsHZvwI0t3VLd6L1p7 sUyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727096939; x=1727701739; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IQE/I5sLtzBQCKJ4fXQCZ4KFxSa++tWKnvbrznHnV+g=; b=t25c5Wvcg6K3n+PuqMUF36EJcRKFao6amQ7szg32NtDS0ZTYkStUTm2W7Na1lj/HsO lvECzB0MCW028XseENuVil9zV+uziXuVR9MHohNnASPl4zyWNvISB265+5/2XB61hKYa swTF9vEwXzTekGqTu23boToWgCF7g1ZSR9WUQfbAI8ucZs5BiGynyJ6XZWi0zS80aUQa rNftVb15DxWuwoijmXBu5UsrMLyar14ooN9tTISy/TnGlFCfks7XhGY7ghE7Ks+yasyu Zs4oYkRRMze30h5X7XIlo9WgTKb5qlsAEhM/SQTbClbZ+K2Pe9F1bZo6RXbIE+hlyKR5 FTtg== X-Forwarded-Encrypted: i=1; AJvYcCWblfKeVmAaNGouG97a/okR3Wd/eaOrZXjxn7kNDtU/i+6GfcrwwbqOrzdmSs7GZIKb6FiyGlWRwUrvf7Lp@postgresql.org X-Gm-Message-State: AOJu0Yw7R2nc4tPSlpjxLEux2HCh9BY+jI6WakMXZuIhvgtxiCgRnJfm PeIzsu0KdUKsPk/xgGCa9FoMgQGFg+HCHg/nC04MAVKED8/VmqIyYi7KD+nhmBBP4+jnPc/keqW jdXWvQcyMJRJKN0iZHcOI8tMuCHmiNA== X-Google-Smtp-Source: AGHT+IGW8hZMs7dz8rYwIFLym5UqbaDvP3Xxo/8Spf2LPUn6y4HXbb7bZ4LOm+FScsEj1F5v35HEp98iNjAil8JgiV0= X-Received: by 2002:a05:6820:2613:b0:5e1:efda:3991 with SMTP id 006d021491bc7-5e58b81cf7cmr4690010eaf.0.1727096938895; Mon, 23 Sep 2024 06:08:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dominique Devienne Date: Mon, 23 Sep 2024 15:08:47 +0200 Message-ID: Subject: Re: Customize psql prompt to show current_role To: Laurenz Albe Cc: Erik Wienhold , Asad Ali , pgsql-general@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 23, 2024 at 3:05=E2=80=AFPM Laurenz Albe wrote: > On Mon, 2024-09-23 at 14:59 +0200, Dominique Devienne wrote: > > On Mon, Sep 23, 2024 at 2:51=E2=80=AFPM Erik Wienhold = wrote: > > > You could instead use this: > > > > > > SELECT current_role \gset > > > \set PROMPT1 '%n@%/ (%:current_role:)=3D%# ' > > > > > > But that won't work with subsequent SET ROLE commands. > > > > Bummer... That was kinda the point, that it updates automatically. > > > > Then I'd like to respectfully request a small enhancement to psql > > to support a new \r (or some other letter) for current_role in the prom= pt. > > To get the current role, psql would have to query the database whenever > it displays the prompt. That would be rather expensive... Hi Laurenz. Sure, although expensive might be a bit strong a word. But that would be opt-in anyway, so just a small warning in the doc about that new option would suffice, no? --DD