bat icon indicating copy to clipboard operation
bat copied to clipboard

mouse wheel scrolling

Open mcandre opened this issue 2 months ago • 3 comments

Hi,

bat doesn't appear to support mouse wheel scrolling out of the box.

I don't know if bat offers some opt-in parameters to enable this, but once is does, these should arguably be enabled by default.

Latest stable bat Homebrew zsh macOS Sequoia

mcandre avatar Oct 29 '25 22:10 mcandre

I agree that this should be enabled by default, or at least be able to set it as a default. The way I've figured out how to get it to work is by enabling mouse mode in the pager, like so:

bat --pager="less -R --mouse" your_file.txt

You can also set your PAGER environment variable to include the necessary less options:

export PAGER="less -R --mouse"

After setting this variable, any command that uses the PAGER environment variable, including bat, will automatically use these settings. This could be set in your .zshrc or .bashrc profile so it's always available.

jeremyaltman avatar Oct 30 '25 20:10 jeremyaltman

With --pager="less -R --mouse", quitting back to the terminal often dumps junk characters into the next prompt.

In fact, Apple less with -R --mouse has this problem. Curious.

... and with Homebrew (GNU) less. Yikes.

GNU less with -R but no --mouse scrolls somewhat better. Though, like so many other bat configurations, when mouse wheel scrolling is enabled, then the cursor can no longer select any of the text.

mcandre avatar Nov 02 '25 03:11 mcandre

You can try with --pager=builtin

keith-hall avatar Nov 30 '25 19:11 keith-hall