/bin/less
is the default pager on an Ubuntu 14.04.3 LTS desktop OS (the $PAGER
variable is unset) and gnome-terminal 3.6.2-ubuntu1 is used.
If I try for instance:
$ man man
The displayed output conforms to the width of the current Gnome terminal window. No problem there. However when I do:
$ man man | egrep regex
The output does not automatically recognize the terminal window's width. With a setting of 83 columns in terminal's menu Edit > Profile Preferences > Default size, some lines do not conform to the terminal width and are not correctly adjusted to width. As a result I get several instances of:
<standard input>:981: warning [p 8, 0.5i, div `3tbd1,0', 0.0i]: cannot adjust line
(some characters in the warning above vary from warning to warning, presumably because they point to problematic output lines located at different place in the output.)
The pager does not seem to be at fault since this doesn't happen with the command man man
.
Could it be the pipe or the rhs of the pipe disrupting things from the point of view of conforming to the Gnome terminal window width ? Is there a way to remedy that ?
EDIT 1: Is there a way to remedy that at session level, i.e. automatically, i.e. without having to check for Gnome terminal's current window width everytime I type a cmd-line that will print to stdout ?
man ...
is just an example. Definitely ! I am definitely asking about the bash implementation of either the pager or what the pager does when the output is processed through a pipe or something else that garbles the correct output width adjustment in Gnome terminal. I am stumped because I don't know where to start to find the beginning of an answer. Pliz see my comment below Steve's answer. Cheers.man man | egrep regex
to be formatted to 83 columns if the terminal is 83 columns wide? Note that bash has nothing to do with the pager — the pager is less unless you've configured a different one, but the program that formats the content to a certain number of columns is man. If you thought that egrep or bash was doing the formatting, well, it's man, and its output is a pipe, not the terminal.less
is the pager on that particular box. In my exampleman
output to pipe is just to exhibit what I find to be the bizarre behavior I get as far as the paging goes. Even so I thought that piping the output could correspond to a particular implementation of pipe by bash. If I'm mistaken, so be it; it is not important per se. *** How do I make any output conform to any terminal window width I may have arbitrarily set. I.e. either before opening the particular terminal window, or after opening the window but before executing any cmd-line printing to stdout.