bat
bat copied to clipboard
Scrolling in iterm2 does not work
What steps will reproduce the bug?
- if I run
bat .zshrc.backup
in the macos terminal I'm able to scroll all the content of the file. Initially, on my screen, there are 30 lines and I can scroll it up to the last 102 lines. - if I run
bat .zshrc.backup
in iterm2 I'm not able to scroll all the content of the file until I press enter to load more rows and then I will be able to scroll up and down from 1 to 102 line.
What happens? The scrolling does not work
What did you expect to happen instead?
The scrolling does work
How did you install bat
?
homebrew
bat version and environment
bat .zshrc.backup --diagnostic
#### Software version
bat 0.22.1
#### Operating system
macOS 12.6 (Darwin 21.6.0)
#### Command-line
```bash
bat .zshrc.backup --diagnostic
Environment variables
SHELL=/bin/zsh
PAGER=less
LESS=-R
LANG=<not set>
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER=<not set>
System Config file
Could not read contents of '/etc/bat/config': No such file or directory (os error 2).
Config file
# Uncomment the following line if you are using less version >= 551 and want to
# enable mouse scrolling support in `bat` when running inside tmux. This might
# disable text selection, unless you press shift.
# --pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"
# Syntax mappings: map a certain filename pattern to a language.
# Example 1: use the C++ syntax for Arduino .ino files
# Example 2: Use ".gitignore"-style highlighting for ".ignore" files
--map-syntax "zshrc:Bourne Again Shell (bash)"
--map-syntax "zshenv:Bourne Again Shell (bash)"
--map-syntax "Brewfile:Bourne Again Shell (bash)"
Custom assets metadata
Could not read contents of '/Users/iamtodor/.cache/bat/metadata.yaml': No such file or directory (os error 2).
Custom assets
'/Users/iamtodor/.cache/bat' not found
Compile time information
- Profile: release
- Target triple: x86_64-apple-darwin
- Family: unix
- OS: macos
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: fxsr,sse,sse2,sse3,ssse3
- Host: x86_64-apple-darwin
Less version
> less --version
less 608 (PCRE2 regular expressions)
Copyright (C) 1984-2022 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less
might be related to https://github.com/sharkdp/bat/issues/188
Also, found more or less related issues https://github.com/sharkdp/bat/issues/508 https://github.com/sharkdp/bat/issues/509 https://github.com/sharkdp/bat/issues/526 https://github.com/sharkdp/bat/issues/556
So.. did you find a solution in one of the other issues?
@sharkdp nope, I did not. Did you find it?
@sharkdp could you please help me with where to look? I tried this solution https://github.com/sharkdp/bat/issues/508#issuecomment-464838961 but it does not work for me.
Am I missing something?
@sharkdp could you please take a look?
@sharkdp could you please take a look here?
bat --pager="less -R"
works for me but I would love to have bat
just figure out how to not override less flags for us. Running bat 0.12.1
here. For now just gonna alias bat
to bat --pager="less -R"
.
Look, guys. I don't have a Mac. Someone else will have to work on this / figure this out.
bat --pager="less -R"
works for me but I would love to havebat
just figure out how to not override less flags for us. Runningbat 0.12.1
here. For now just gonna aliasbat
tobat --pager="less -R"
.
Bat 0.12.1 was released in 2019... Did you consider that it may already work better in a recent version @unphased ?
@keith-hall That's a solid point. On this Ubuntu 20.04 system it's provided via apt and there is still no newer version available from there. On my mac it's provided from homebrew and on version 0.18, and this is not an issue there.
This has prompted me to update my env setup scripts to go back to preparing bat
via cargo
instead of apt
again. Plus, getting it from apt installs it as batcat
and I had to make another symlink for that too.
I know this may sound obvious, but have you tried uncommenting the suggested line --pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"
?
It worked for me, though I am not on a Mac.
Since the issue is still open I would like to share my experience. I had this issue on freshly installed iterm2, then I ran bat --pager="less -R"
and then happened two things: first, it worked, second, iterm asked whether I would like mouse scrolling to interact with these programs. After clicking yes bat
works as intended even without --pager
switch
so either bat remembers --pager
(?) or it's just a question of enabling some setting in iterm2
for me running bat --pager="less -R"
gives nothing :(
@iamtodor, can you try enabling mouse reporting and mouse wheel events in iTerm? You'll also need to add the --mouse
option to less
(either through bat --pager="less -R --mouse"
or by setting the LESS
environment variable to LESS="--mouse"
) to have it ask the terminal to report mouse/scroll wheel inputs.
Also, are you using tmux
, screen
, or some other multiplexer? Those have their own mouse event support that may prevent the events from being properly passed along to less
.
@eth-p surprisingly this one bat --pager="less -R --mouse"
works for me!
Nope, I do not use any multiplexer, just vanilla iterm2