On Tue, Nov 01, 2011 at 06:22:47AM +0200, Peter Eisentraut wrote:
> I wrote:
> > I have often found myself wanting that psql automatically switch between
> > normal and \x mode depending on the width of the output. Would others
> > find this useful?
> >
> > Attached is a crude demo patch. Enable with \pset expanded auto.
>
> Here is a finalized patch for this. The first hunk of the patch is the
> documentation change, so you can see there how it's supposed to work.
> Let me know what you think.
+1. I'm anticipating liking this enough to put it in ".psqlrc".
Perhaps this message should change to just "Target width is 120.", since it now
applies to more than just the wrapped format:
[local] test=# \pset columns 120
Target width for "wrapped" format is 120.
Similarly, psql documentation for "\pset columns" and the COLUMNS environment
variable should note expanded auto in addition to the wrapped format.
For "\pset format wrapped", we only use $COLUMNS when the output is a tty. I'm
thinking it's best, although not terribly important, to apply the same rule to
this feature.
Thanks,
nm