Fzf: First line of preview replaced with ansi garbage

Created on 28 Oct 2018  路  8Comments  路  Source: junegunn/fzf

  • Category

    • [x] fzf binary

    • [ ] fzf-tmux script

    • [ ] Key bindings

    • [ ] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [ ] Linux

    • [x] Mac OS X

    • [ ] Windows

    • [ ] Windows Subsystem for Linux

    • [ ] Etc.

  • Shell

    • [x] bash

    • [x] zsh

    • [x] fish

The first line of the preview window is always replaced with some ansi noise. I'm not entirely sure where that's coming from.

For example, if I say:

fzf --preview="echo 'one
two
three'" 

I get the following:

screenshot

Lines other than the first appear fine and shown as expected, in glorious ANSI colour if applicable.

Any clues on how to debug this?

fzf version 0.17.5 (brew)

Most helpful comment

Mystery solved, then. Thank you! I had a command that sets the colour palette in my config.fish. Hiding that behind a check for an interactive shell solves the issue:

if status --is-interactive
  theme_gruvbox dark
end

All 8 comments

Hi @runarorama,

It's been a while since you submitted this issue and I can't reproduce it, in the meantime have you figured out the issue, or has it been fixed in a new version of fzf?

I haven't figured it out, and it's still present as of 0.18.0 (ff95134)

Could you try with the newest version: 0.20.0 please?

Same issue with 0.20.0 (brew)

fzf uses $SHELL to launch preview command, so it's likely that your $SHELL is injecting those stuff for color configuration.

So try this and see if the problem persists

SHELL=/bin/sh fzf --preview="\echo 'one
two
three'"

That fixes the issue. My $SHELL is set to /usr/local/bin/fish

Looks like it's an Xterm control sequence for changing color palette.

(https://superuser.com/questions/647033/xterm-control-sequence-to-get-rgb-value-for-ansi-color)

The current ANSI processor of fzf doesn't understand the pattern, so they are just printed on the screen. I can probably fix this, but your shell, whatever it is, shouldn't be configured to print it out when it runs a command, because you don't want those characters to be included in the output when you run a one-off command.

fish -c ls > /tmp/output

Mystery solved, then. Thank you! I had a command that sets the colour palette in my config.fish. Hiding that behind a check for an interactive shell solves the issue:

if status --is-interactive
  theme_gruvbox dark
end
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jberglinds picture jberglinds  路  3Comments

natemara picture natemara  路  3Comments

alistaircolling picture alistaircolling  路  3Comments

asilvadesigns picture asilvadesigns  路  3Comments

fenuks picture fenuks  路  3Comments