Is there any way to make less
program repeat first line (or first 2 lines) on every displayed page?
Is there any other pager program which can do this?
This would be a killer-app for database table browsing, think mysql
or psql
or gqlplus
…
See the screenshot in the bottom of this page. I want to repeat header line + horizontal ascii bar.
Best Answer
There is a solution using Vim.
First, you need a Vim macro, which will do most of the work. Save it in
~/.vim/plugin/less.vim
:Second, to emulate a pager, you need to invoke vim so that it will:
I put this together as helper script in
~/bin/vimpager
:Make the script executable with
chmod +x ~/bin/vimpager
.Third, you need to override pager program for psql. Do not set variable
PAGER
globally, as it can affect other programs, not only psql. Instead, add this to your~/.psqlrc
file:Voila! After reloading your profile, you can enjoy the result, which should behave as expected (arrow keys browse both vertically and horizontally) and look like this: . Plus, all the power of Vim is right there if you need it.