Personally, I've always thought that the VTxx escape sequence family is
 missing one: enable/disable scroll-lock. Then, your 'pager' just consists
 of printing the scroll-lock sequences at the beginning and end of output
 and using your multiplexer's scrolling feature, and can be accomplished
 like Eric mentioned above via aliases easily, too.

 -Leander

On Fri, Feb 10, 2017 at 1:53 AM, hiro <23h...@gmail.com> wrote:
> the problem is when i *know* stuff fill be very long, but I still want
> to start reading from the beginning. in tmux i don't know how to start
> scrolling from top of my last command. I don't want to scroll there
> manually. also in page i can use pgup/down in tmux i have to do crazy
> emacs-combinations first.
>
> On 2/10/17, Eric Pruitt <eric.pru...@gmail.com> wrote:
>> On Fri, Feb 10, 2017 at 08:26:11AM +0100, robin wrote:
>>> I usually pipe into less whenever something overflows the terminal
>>> height, but having to type 2>&1 to see stderr is a bit cumbersome. In
>>> dvtm Shift-PageUp is much easier.
>>
>> I use a generic wrapper function in Bash:
>>
>>     #   $1  Name or path of the command to execute.
>>     #   $2  White-space separated list of options to pass to the command
>>     #       when stdout is a TTY. If there are no TTY-dependent options
>>     #       this should be "--".
>>     #   $@  Arguments to pass to command.
>>     #
>>     function -paginate()
>>     {
>>         local errfd=1
>>
>>         local command="$1"
>>         local tty_specific_args="$2"
>>         shift 2
>>
>>         if [[ -t 1 ]]; then
>>             test "$tty_specific_args" != "--" || tty_specific_args=""
>>             test -t 2 || errfd=2
>>             "$command" $tty_specific_args "$@" 2>&"$errfd" | less -X -F -R
>>             return "${PIPESTATUS[0]/141/0}"  # Ignore SIGPIPE failures.
>>         fi
>>
>>         "$command" "$@"
>>     }
>>
>> Then I have around 30 aliases for various commands I use like this:
>>
>>     alias cat='-paginate cat --'
>>     alias grep='-paginate grep --color=always'
>>     alias ps='-paginate ps --cols=$COLUMNS --sort=uid,pid -N --ppid 2 -p 2'
>>
>> Output is only paginated when stdout is a TTY so I can still use pipes,
>> and the less flags ensure that less will exit if the output fits on one
>> screen. I also use tmux, but I find less to be less painful to use than
>> copy mode in tmux when I don't need to actually copy text.
>>
>> Eric
>>
>>
>

Reply via email to