Hi Cal: On Mon, Apr 25, 2016 at 3:55 PM, Cal Heldenbrand <cal@xxxxxxxxxxx> wrote: > I whipped up a psqlrc and companion shell script to provide a colored prompt > with the hostname of the machine you're connected to. It works for both > local sockets and remote connections too. Color may be nice, but as previously pointed it can distort things. > /usr/local/pgsql/etc/psqlrc > ============================================== > -- PROMPT1 is the primary prompt > \set PROMPT1 > '%[%033[1;31m%]%`/usr/local/pgsql/etc/psql_hostname.sh`%[%033[0m%] > %n@%/%R%#%x ' And you are exec'ing in every round ( not too big, but I come from a time of slow forks). I think psql ( at least in 9.3 didn't bother looking behind ) gives you enough: cdrs=> \set PROMPT1 %M:%>-%x-%:AUTOCOMMIT:-:PROMPT1 db1:5432--on:-cdrs=> begin; BEGIN db1:5432-*-on:-cdrs=> commit; COMMIT db1:5432--on:-cdrs=> \c apc - psql (9.4.7, server 9.3.10) You are now connected to database "apc" as user "folarte". db1:5432--on:-apc=> And you can color it: db1:5432--on:-apc=> \set PROMPT1 '%[%033[1;31m%]%M%[%033[0m%]%n@%/%R%#%x ' <RED>db1</RED>folarte@apc=> -- not a fan of html mail. lsof may give you longer or more acurate names, but I think std escapes are enough. Francisco Olarte. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general