Re: psql color hostname prompt

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: psql color hostname prompt
Дата
Msg-id CA+bJJbzg4qwGEUbFosCE05VA3wcVt9fCifZXip5BpabTg=Spiw@mail.gmail.com
обсуждение исходный текст
Ответ на psql color hostname prompt  (Cal Heldenbrand <cal@fbsdata.com>)
Список pgsql-general
Hi Cal:

On Mon, Apr 25, 2016 at 3:55 PM, Cal Heldenbrand <cal@fbsdata.com> 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: Bráulio Bhavamitra
Дата:
Сообщение: Re: Columnar store as default for PostgreSQL 10?
Следующее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: psql color hostname prompt