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

Do not use 'most' PAGER, as it is not compatible with bats output #1063

Closed
dangoncalves opened this issue Jun 18, 2020 · 9 comments · Fixed by #1452
Closed

Do not use 'most' PAGER, as it is not compatible with bats output #1063

dangoncalves opened this issue Jun 18, 2020 · 9 comments · Fixed by #1452
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@dangoncalves
Copy link

Describe the bug you encountered:
when I use bat on a single file, colors are not displayed, control sequences are diplayed instead. The bug occurs with fedora's package or when I build bat from sources. Using fish or bash does not change anything and using konsole or alacritty has the same results.
You can find a screenshot here
...

Describe what you expected to happen?
bat should display colors
...

How did you install bat?
dnf install bat
or
cargo build (from sources)


system

$ uname -srm
Linux 5.6.18-300.fc32.x86_64 x86_64

bat

$ bat --version
bat 0.15.0

$ env
PAGER=most

bat_config

$ cat /home/daniel/.config/bat/config

# This is `bat`s configuration file. Each line either contains a comment or
# a command-line option that you want to pass to `bat` by default. You can
# run `bat --help` to get a list of all possible configuration options.

# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes`
# for a list of all available themes
#--theme="TwoDark"
--theme="Solarized (dark)"

# Enable this to use italic text on the terminal. This is not supported on all
# terminal emulators (like tmux, by default):
#--italic-text=always

# Uncomment the following line to disable automatic paging:
#--paging=never

# 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="--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 .ino files
#   Example 2: Use ".gitignore"-style highlighting for ".ignore" files
#--map-syntax "*.ino:C++"
#--map-syntax ".ignore:Git Ignore"

bat_wrapper

No wrapper script for 'bat'.

bat_wrapper_function

No wrapper function for 'bat'.

No wrapper function for 'cat'.

tool

$ less --version
less 551 (POSIX regular expressions)

@dangoncalves dangoncalves added the bug Something isn't working label Jun 18, 2020
@sharkdp
Copy link
Owner

sharkdp commented Jun 18, 2020

I'm pretty sure this is the problem:

 PAGER=most

bat is not compatible with most. Could you try to add --pager="less" to your config file?

In case this works, we should probably make sure that others do not run into this problem and ignore if PAGER=most has been set.

@eth-p
Copy link
Collaborator

eth-p commented Jun 18, 2020

In case this works, we should probably make sure that others do not run into this problem and ignore if PAGER=most has been set.

I think a first-time warning message would also be a good idea if we do this, otherwise people might open issues about bat not respecting the PAGER variable.

Also, should that apply to the BAT_PAGER variable as well?

@dangoncalves
Copy link
Author

Yes, you've got it. Using --pager=less solve the issue.

@sharkdp sharkdp reopened this Jun 29, 2020
@sharkdp sharkdp changed the title Bat display control sequences instead of colors Do not use 'more' PAGER, as it is not compatible with bats output Jun 29, 2020
@sharkdp sharkdp added the good first issue Good for newcomers label Jun 29, 2020
@KristobalJunta
Copy link

@sharkdp I assume this is open to contributions?
I am willing to take on this (with consideration of the discussion in #1123)

@sharkdp
Copy link
Owner

sharkdp commented Oct 8, 2020

I am willing to take on this (with consideration of the discussion in #1123)

👍

Enselic added a commit to Enselic/bat that referenced this issue Nov 27, 2020
In preparation of fixing issue sharkdp#1063.
This is a pure refactoring with no intended functional side effects.
Enselic added a commit to Enselic/bat that referenced this issue Dec 27, 2020
This macro is intended to be package-internal and is not to be
considered part of the public lib API.

Use it in three places to reduce code duplication. However, main reason
for this refactoring is to allow us to fix sharkdp#1063 without duplicating the
code yet another time.

The macro can also be used for the "Binary content from {} will not be
printed to the terminal" message if that message starts to use eprintln!
instead (if ever).

To trigger/verify the changed code, the following commands can be used:

    cargo run -- --theme=ansi-light tests/examples/single-line.txt
    cargo run -- --theme=does-not-exist tests/examples/single-line.txt
    cargo run -- --style=grid,rule tests/examples/single-line.txt
sharkdp pushed a commit that referenced this issue Dec 28, 2020
This macro is intended to be package-internal and is not to be
considered part of the public lib API.

Use it in three places to reduce code duplication. However, main reason
for this refactoring is to allow us to fix #1063 without duplicating the
code yet another time.

The macro can also be used for the "Binary content from {} will not be
printed to the terminal" message if that message starts to use eprintln!
instead (if ever).

To trigger/verify the changed code, the following commands can be used:

    cargo run -- --theme=ansi-light tests/examples/single-line.txt
    cargo run -- --theme=does-not-exist tests/examples/single-line.txt
    cargo run -- --style=grid,rule tests/examples/single-line.txt
@Enselic
Copy link
Collaborator

Enselic commented Dec 28, 2020

@sharkdp Seems like this issue was accidentally closed? I referenced it in my bat_warning! commit, but only for reference, not for fixing :)

@sharkdp sharkdp reopened this Dec 29, 2020
@sharkdp sharkdp changed the title Do not use 'more' PAGER, as it is not compatible with bats output Do not use 'most' PAGER, as it is not compatible with bats output Dec 29, 2020
@sharkdp sharkdp added this to the v0.18.0 milestone Jan 9, 2021
sharkdp added a commit that referenced this issue Jan 10, 2021
Fix #1063: Do not use 'more' or 'most' PAGER, as they are not compatible with bats output
@sharkdp
Copy link
Owner

sharkdp commented Feb 28, 2021

Bugfix released in bat v0.18.

@pgimalac
Copy link

Bugfix released in bat v0.18.

If PAGER (but not BAT_PAGER or --pager) is more or most, silently use less instead to ensure support for colors, see #1063 (@Enselic)

I spent too much time not understanding why less was used instead of most, I understand why there is no warning (as per #1402) but I believe it should at least be written explicitly in the README

@sharkdp
Copy link
Owner

sharkdp commented May 27, 2021

I agree, this should be documented. It would be great if you could open a new ticket such that it will not be forgotten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants