How to make mouse wheel scroll the less pager using bash and gnome-terminal

bashgnome-terminallessscrolling

I have two computers with the latest Fedora. On the first, I'm using zsh and the mouse wheel can be used with the less pager within gnome-terminal to scroll the pager.

On the second, I use bash and the mouse whell scroll the terminal history, not the pager.

The shell shouldn't make any difference, why can't I use the mouse wheel to scroll in the second case?

To illustrate what it does, imagine I have a document like this:

AAAA
BBBB
CCCC
DDDD
EEEE

And I have a two line terminal. If I use less, I get on the screen

AAAA
BBBB

The mouse wheeel cannot scroll further down. If I scroll upwards, I get the bash prompt history. Now I use the page down key to get to the bottom of the document, I get on screen:

DDDD
EEEE

Scrolling upwards gets me

BBBB
DDDD

–>

Best Answer

The computer where less scrolled had LESS=-r, the other had LESS=-asXFMMRqix8.

From the less man page:

-q or --quiet or --silent

      Causes moderately "quiet" operation: the terminal bell is not rung if an attempt is made to scroll past the end of the file or before the beginning of the file.  If the terminal has a "visual bell", it is used instead.  The bell will be rung on certain other errors, such as typing an invalid character.  The default is to ring the terminal bell in all such cases.

-X or --no-init

      Disables sending the termcap initialization and deinitialization strings to the terminal.  This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.

The -X option prevented scrolling all together and the -q option caused the pager to enter a non-scrollable state when scrolling past the beginning or end of file.

My options are now LESS=-asrRix8.