Re: [GENERAL] psql color hostname prompt

2016-05-05 Thread Steve Crawford
BTW, I just noticed that as of 9.5 there is an optional GUC called cluster_name. Unfortunately I don't see a way to reference it in the prompt string. I'll suggest that as a feature. My earlier hack will work but in 9.5 use cluster_name instead of making up a fake extension variable. Cheers, Steve

Re: [GENERAL] psql color hostname prompt

2016-04-28 Thread Francisco Olarte
Hi Steve: On Wed, Apr 27, 2016 at 7:09 PM, Steve Crawford wrote: > The various hacks appear to not deal with the fact that there may be > multiple instances of postgresql running on different TCP ports or Unix > connections nor with the fact that the local connection may, in fact, be a > pooler a

[GENERAL] psql color hostname prompt

2016-04-27 Thread Cal Heldenbrand
Hi everyone, The default psql prompt can be a little frustrating when managing many hosts. Typing the wrong command on the wrong host can ruin your day. ;-) 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 wor

Re: [GENERAL] psql color hostname prompt

2016-04-27 Thread dabicho
On Wed, Apr 27, 2016 at 12:09 PM, Steve Crawford wrote: > On Wed, Apr 27, 2016 at 1:29 AM, Francisco Olarte > wrote: >> >> Hi Cal: >> >> On Tue, Apr 26, 2016 at 5:20 PM, Cal Heldenbrand wrote: >> ... >> > 2) %M vs shell call >> > %M on when connected to the local machine displays the string "[l

Re: [GENERAL] psql color hostname prompt

2016-04-27 Thread dabicho
On Wed, Apr 27, 2016 at 12:09 PM, Steve Crawford wrote: > On Wed, Apr 27, 2016 at 1:29 AM, Francisco Olarte > wrote: >> >> Hi Cal: >> >> On Tue, Apr 26, 2016 at 5:20 PM, Cal Heldenbrand wrote: >> ... >> > 2) %M vs shell call >> > %M on when connected to the local machine displays the string "[l

Re: [GENERAL] psql color hostname prompt

2016-04-27 Thread Steve Crawford
On Wed, Apr 27, 2016 at 1:29 AM, Francisco Olarte wrote: > Hi Cal: > > On Tue, Apr 26, 2016 at 5:20 PM, Cal Heldenbrand wrote: > ... > > 2) %M vs shell call > > %M on when connected to the local machine displays the string "[local]" > > which I didn't like. I wanted a real hostname to show no

Re: [GENERAL] psql color hostname prompt

2016-04-27 Thread Francisco Olarte
Hi Cal: On Tue, Apr 26, 2016 at 5:20 PM, Cal Heldenbrand wrote: ... > 2) %M vs shell call > %M on when connected to the local machine displays the string "[local]" > which I didn't like. I wanted a real hostname to show no matter which > client/server pair I was using. Zero chance for mistaken

Re: [GENERAL] psql color hostname prompt

2016-04-26 Thread Cal Heldenbrand
Would it be reasonable to just take the simple approach with same algorithm I used in the shell script? Basically: If the psql client uses a local UNIX domain socket, or localhost TCP connection, use the string output by "hostname" system command. From the C perspective, this is just calling the

Re: [GENERAL] psql color hostname prompt

2016-04-26 Thread Steve Crawford
> > 2) %M vs shell call > > %M on when connected to the local machine displays the string "[local]" > which I didn't like. I wanted a real hostname to show no matter which > client/server pair I was using. Zero chance for mistaken commands on the > wrong host. Many times we ssh to a remote serv

Re: [GENERAL] psql color hostname prompt

2016-04-26 Thread Cal Heldenbrand
Thanks for the input everyone. I'll try to comment on each discussion point: 1) garbled output in large queries I messed around with a few things, and have not been able to recreate any issues. Can you provide a test case for this? Also, any other interesting things about your terminal, like y

Re: [GENERAL] psql color hostname prompt

2016-04-25 Thread Francisco Olarte
Hi: On Mon, Apr 25, 2016 at 4:04 PM, Achilleas Mantzios wrote: > Hello, have done that, looked really nice, but unfortunately this resulted > in a lot of garbled output, in case of editing functions, huge queries, up > arrows, etc... Did you use %[ %] to delimit non-printing sequences as Cal di

Re: [GENERAL] psql color hostname prompt

2016-04-25 Thread hubert depesz lubaczewski
On Mon, Apr 25, 2016 at 08:55:21AM -0500, Cal Heldenbrand wrote: > The only outside tool it requires is lsof to determine the hostname of the > remote socket. Otherwise it uses plain stuff like awk / sec and bash tools. Why would you need lsof to get hostname for remote connection, when you can u

Re: [GENERAL] psql color hostname prompt

2016-04-25 Thread Francisco Olarte
Hi Cal: On Mon, Apr 25, 2016 at 3:55 PM, Cal Heldenbrand 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 previous

Re: [GENERAL] psql color hostname prompt

2016-04-25 Thread Achilleas Mantzios
On 25/04/2016 16:55, Cal Heldenbrand wrote: Hi everyone, The default psql prompt can be a little frustrating when managing many hosts. Typing the wrong command on the wrong host can ruin your day. ;-) I whipped up a psqlrc and companion shell script to provide a colored prompt with the host

[GENERAL] psql color hostname prompt

2016-04-25 Thread Cal Heldenbrand
Hi everyone, The default psql prompt can be a little frustrating when managing many hosts. Typing the wrong command on the wrong host can ruin your day. ;-) 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 wor