Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling in iterm2 does not work #2367

Open
iamtodor opened this issue Oct 12, 2022 · 15 comments
Open

Scrolling in iterm2 does not work #2367

iamtodor opened this issue Oct 12, 2022 · 15 comments
Labels
bug Something isn't working pager-related

Comments

@iamtodor
Copy link

What steps will reproduce the bug?

  1. 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.
  2. 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 #188

@iamtodor iamtodor added the bug Something isn't working label Oct 12, 2022
@iamtodor
Copy link
Author

Also, found more or less related issues #508 #509 #526 #556

@sharkdp
Copy link
Owner

sharkdp commented Nov 4, 2022

So.. did you find a solution in one of the other issues?

@iamtodor
Copy link
Author

iamtodor commented Nov 5, 2022

@sharkdp nope, I did not. Did you find it?

@iamtodor
Copy link
Author

@sharkdp could you please help me with where to look? I tried this solution #508 (comment) but it does not work for me.

Am I missing something?

@iamtodor
Copy link
Author

iamtodor commented Dec 5, 2022

@sharkdp could you please take a look?

@iamtodor
Copy link
Author

@sharkdp could you please take a look here?

@unphased
Copy link

unphased commented Feb 22, 2023

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".

@sharkdp
Copy link
Owner

sharkdp commented Feb 28, 2023

Look, guys. I don't have a Mac. Someone else will have to work on this / figure this out.

@keith-hall
Copy link
Collaborator

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".

Bat 0.12.1 was released in 2019... Did you consider that it may already work better in a recent version @unphased ?

@unphased
Copy link

unphased commented Mar 1, 2023

@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.

@JosefLitos
Copy link

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.

@lesha-co
Copy link

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

@iamtodor
Copy link
Author

for me running bat --pager="less -R" gives nothing :(

@eth-p
Copy link
Collaborator

eth-p commented Feb 10, 2024

@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.

@iamtodor
Copy link
Author

@eth-p surprisingly this one bat --pager="less -R --mouse" works for me!

Nope, I do not use any multiplexer, just vanilla iterm2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pager-related
Projects
None yet
Development

No branches or pull requests

7 participants