Re: How to list current user and database in PSQL

From: bricklen <bricklen(at)gmail(dot)com>
To: peterlen <peteralen(at)earthlink(dot)net>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to list current user and database in PSQL
Date: 2013-12-31 19:18:22
Message-ID: CAGrpgQ-ZoPVAo+dJx1_Y7L4L9edOd-j=+JTnYjQ6gzPjoPHESA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 31, 2013 at 10:55 AM, peterlen <peteralen(at)earthlink(dot)net> wrote:

> After logging into the PSQL Shell Script as a particular user and
> database, I
> want to display who my current user is and what database I am in as I may
> have forgotten who I am logged in as in order to make sure any commands are
> going to the right place. In Oracle's SQLPlus you can do something like
> "show user" and get feedback on the user you are logged in as. Is there an
> equivalent thing for PSQL to list the user and database?
>
> Thanks - Peter
>

As Adrian Klaver mentioned, you can set your psql prompt. Here are few
entries from my $HOME/.psqlrc

\set PROMPT1 '%n(at)%`hostname`:%> [%/] %x%# '
\timing on
\pset pager off
\x auto
\set HISTCONTROL = ignoreboth

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Kregloh 2013-12-31 20:25:23 Re: pg_upgrade & tablespaces
Previous Message peterlen 2013-12-31 19:12:10 Re: How to list current user and database in PSQL