Hello,
Using iTerm2 "AlternateMouseScroll", I can scroll in less instead of using arrow keys.
Do you think that would work with bat ?
Thanks :)
Thank you for your feedback.
This is a duplicate of #188 (and #193).
You should be able to use the fix suggested in #188. If that works, we should probably add it to the "Troubleshooting" section of the README.
@sharkdp: I tweaked the bash function provided by @achalddave to use RS instead of RF, and was able to get this to work on a Mac using the default Terminal app. Hopefully this helps
Instead of wrapping bat in a script, you can also wrap the pager, as suggested in the README: https://github.com/sharkdp/bat#using-a-different-pager
Hi folks,
Could someone give us the exact best process to resolve this issue?
I've looked at all the old issues and didn't found any definitive good answer.
Then we can document it in the readme.
Thanks!
@mike-mosher The only thing with your script is that you always wrap the content into less, where bat has some nice detections about how to render (for example try bat file | pbcopy and you won't have line numbers, etc.)
Here is a working micro-tutorial (for macOS at least):
~/bat.pager.sh#!/bin/bash
less --tabs 4 -RF "$@"
chmod +x ~/bat.pager.shalias cat="PAGER=~/bat.pager.sh bat --theme='mytheme'"
source ~/.[zsh|bash]rcAnd this is working nicely
Edit: @sharkdp maybe adding a well-written version of my guide to the README would be a good call, as many of us don't know what PAGER means, especially how it's related to having your terminal support the mouse in it. You may close the issue if you want
@gjuchault solution works for me, but its not perfect because it shows the end of file.
Is there any way to make it scrollable like less is by default?
@gjuchault Thanks!
I would propose the following modification:
Write the following to ~/.bat_pager.sh:
#!/bin/bash
less --tabs 4 -RF "$@"
Make the file executable:
chmod +x ~/.bat_pager.sh`
bash
export BAT_PAGER="$HOME/.bat_pager.sh"
@mladenp It shows the beginning of the file for me. And scrolling also doesn't work for you?
@gjuchault @sharkdp Thanks for the updated process. However, your suggestions don't work. I'm using Mac OS and Terminal.app with Bash. To get it to work, you need to substitute RF with RS in the .bat_pager.sh script.
@mike-mosher RF works fine with me
What does creating a shell script give you over just setting export LESS="--tabs 4 -RF"?
The problem with using the LESS environment variable is that bat will pass command-line options to less. The options on the command-line take precedence over the values in the environment variable.
I hope that things are now well explained in this README section: https://github.com/sharkdp/bat#using-a-different-pager
Most helpful comment
Hi folks,
Could someone give us the exact best process to resolve this issue?
I've looked at all the old issues and didn't found any definitive good answer.
Then we can document it in the readme.
Thanks!