Thanks a lot for bat!
I just noticed that if you bat a file in iTerm2 and simply keep switching back and forth to fullscreen, the output gets messed up pretty bad.
Here is an example, bat a file belonging to Homebrew:


Now if I simply get out of fullscreen, output gets messed up:


You can also see the scrollbar in the terminal growing, simply switching back and forth to fullscreen (cmd+enter):

Not even sure where to start with this, but let me know if I can help!
You can also see the scrollbar in the terminal growing
This would be because of less, the default pager for bat. less will automatically resize itself with the terminal and re-print everything to fit the new size. The content that was on the screen before the re-print is pushed back into the scrollback buffer, which creates a jumbled mess when scrolling back up.
If you disable the pager with --paging=never, this shouldn't happen anymore. A more permanent fix would be to add export BAT_PAGER=catexport BAT_PAGER='' (thanks for the tip, @sharkdp!) to your .bash_profile file, though.
As for the last image: the line wrapping fails because the terminal was resized to a smaller width than when it was printed, which makes iTerm's text wrapping take over. Unfortunately, once bat passes control to the pager, there's no way redraw/refresh the output to fit the smaller terminal.
Thank you for helping out here, @eth-p. Just a minor comment: To disable the pager permanently, you can use export BAT_PAGER="" (instead of setting it to cat). This way, bat will not spawn an additional process.
export BAT_PAGER="" working great!
Thanks for the help, closing 鉂わ笍
Most helpful comment
This would be because of
less, the default pager forbat.lesswill automatically resize itself with the terminal and re-print everything to fit the new size. The content that was on the screen before the re-print is pushed back into the scrollback buffer, which creates a jumbled mess when scrolling back up.If you disable the pager with
--paging=never, this shouldn't happen anymore. A more permanent fix would be to addexport BAT_PAGER=catexport BAT_PAGER=''(thanks for the tip, @sharkdp!) to your.bash_profilefile, though.As for the last image: the line wrapping fails because the terminal was resized to a smaller width than when it was printed, which makes iTerm's text wrapping take over. Unfortunately, once
batpasses control to the pager, there's no way redraw/refresh the output to fit the smaller terminal.