bat: `git log` broken when using bat as pager

I like using bat as my pager of choice with syntax highlighting! 😃. Somewhere across the internet I found the command export PAGER='bat --paging=always' to do exactly that.

Now I realized that my git log did not work anymore (did not show anything) and I found out that it was because of that setting. Setting export PAGER=less and my git log is back.

Is there a way how to make bat-pager and the git log compatible?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (7 by maintainers)

Most upvoted comments

Or you could try reinstalling bat without -s to see if you get the correct .2 revision bottle?

That already fixed it. Thank you! 😃

Thanks for the awesome support guys. You were really persistent about solving this problem. 👍

There we have it. Ouch 😄

Based on the otool result, your build from source was after they removed the workaround. Since the command failed, I can’t tell what version your command line tools are though. I also don’t know which version of clang is considered fixed either, unfortunately.

There’s this stackoverflow thread that might help you figure out how to update your xcode command line tools. Once you figure that out, rebuilding bat again should work.

Or you could try reinstalling bat without -s to see if you get the correct .2 revision bottle?

Do you have more information about your environment and the version of bat you are using? What you did works fine for me… My system is:

$ uname -srm
Linux 5.5.4-arch1-1 x86_64

I’m using version:

$ yay -Q bat
bat 0.12.1-1
sh-3.2$ git log | bat --no-config
Segmentation fault: 11

Trying this on my system (macOS Mojave) with git -c core.pager='bat --paging=always --pager="less"' log (I can’t use PAGER because I have a global core.pager setting), it works for me.

$ uname -srm
Darwin 18.7.0 x86_64
$ brew info bat
bat: stable 0.12.1 (bottled)

Can you run the following script and paste the output?

#!/usr/bin/env bash
_bat_config="$(bat --config-file)"
_bat_binary="$(which bat 2>&1)"

printf "\n--- System ---\n"
uname -srm
command -v sw_vers &>/dev/null && sw_vers
command -v lsb_release &>/dev/null && lsb_release -a

printf "\n--- Software ---\n"
printf "less: %s\n" "$(less --version | head -n1)"

printf "\n--- Bat ---\n"
bat --version
printf "\n"

printf "Environment:\n"
env | grep '^BAT\|^PAGER=' && printf "\n"

printf "Config:\n"
[[ -f "$_bat_config" ]] && cat "$(bat --config-file)" && printf "\n"

printf "Wrapper:\n"
file "$_bat_binary" | grep "text executable" &>/dev/null && bat "$_bat_binary" && printf "\n"

Also, how big is your git log? Maybe you’re being affected by the less --quit-if-one-screen bug?