sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
48.97k stars 1.23k forks source link

mis-behaviour of `--style=plain` while itegrating with `fzf` #2988

Closed KevinNitroG closed 3 months ago

KevinNitroG commented 3 months ago

Sorry I don't know if this problem belongs to fzf or bat so I just created an issue here. Or if it is a bug or not (or a feature?)...

I want to preview the result of fzf integration without the header of information of the previewing file. So I use the arg --style=plain (I guess that arg helps me to achieve that)


What steps will reproduce the bug?

  1. Config fzf integration like below (windows powershell)
    # Ref: https://github.com/junegunn/fzf/blob/master/ADVANCED.md
    $INITIAL_QUERY = "${*:-}"
    $RG_PREFIX = "rg --column --line-number --no-heading --color=always --smart-case"
    $var = "" |
      fzf --ansi --disabled --query "$INITIAL_QUERY" `
        --bind "start:reload:$RG_PREFIX {q}" `
        --bind "change:reload:sleep 0.2 & $RG_PREFIX {q} || rem" `
        --color "hl:-1:underline,hl+:-1:underline:reverse" `
        --delimiter ":" `
        --prompt 'Ripgrep> ' `
        --preview-label "Preview" `
        --header "FIND FILE'S CONTENT" `
        --header-first `
        --preview 'bat --color=always {1} --highlight-line {2} --style=plain' `
        --preview-window 'up,60%,border-bottom,+{2}+3/3,~3'

What happens?

What did you expect to happen instead?

The video of the bug

video

How did you install bat?

Chocolatey


bat version and environment

Software version

bat 0.24.0 (fc95468)

Operating system

Windows 6.2.9200

Command-line

C:\ProgramData\chocolatey\lib\Bat\tools\bat-v0.24.0-x86_64-pc-windows-msvc\bat.exe --diagnostic

Environment variables

SHELL=<not set>
PAGER=<not set>
LESS=<not set>
LANG=<not set>
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<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=<not set>
NO_COLOR=<not set>
MANPAGER=<not set>

System Config file

Could not read contents of 'C:\ProgramData\bat\config': The system cannot find the path specified. (os error 3).

Config file

# 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="Catppuccin Mocha"

# 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="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 "*.ino:C++"
#--map-syntax ".ignore:Git Ignore"

Custom assets metadata

bat_version: 0.24.0
creation_time:
  secs_since_epoch: 1716515563
  nanos_since_epoch: 460732000

Custom assets

Compile time information

Less version

> C:\ProgramData\chocolatey\bin\less.exe --version
less 643 (Spencer V8 regular expressions)
Copyright (C) 1984-2023  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
keith-hall commented 3 months ago

it looks like the ~3 at the end of your fzf --preview-window argument tells fzf to keep three lines as a header when scrolling the preview window. A quick search shows some info about this argument from when it was first introduced: https://github.com/junegunn/fzf/releases/tag/0.26.0

KevinNitroG commented 3 months ago

it looks like the ~3 at the end of your fzf --preview-window argument tells fzf to keep three lines as a header when scrolling the preview window. A quick search shows some info about this argument from when it was first introduced: junegunn/fzf@0.26.0 (release)

Thank you. I didn't figure out. I will close this issue now.