junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
64.33k stars 2.38k forks source link

Preserve color output of `kubecolor get pods -A | fzf --ansi`? #3782

Closed tmpm697 closed 5 months ago

tmpm697 commented 5 months ago

Checklist

Output of fzf --version

0.51.0

OS

Shell

Problem / Steps to reproduce

I have this:

kubecolor get pods -A | fzf --ansi

expect color output of kubecolor preserved but in fact, the color is lost.

LangLangBart commented 5 months ago

Usually, there is an extra option to retain the escape sequences when piped into another command.

See: kubecolor/kubecolor - Dynamic tty support

KUBECOLOR_FORCE_COLORS=true kubecolor ... | fzf ...
# or
kubecolor --force-colors ... | fzf ...
# Enables colors automatically when outputting to the terminal; otherwise, it disables them.
command grep --color=auto '^foo' /usr/share/dict/words
command grep --color=auto '^foo' /usr/share/dict/words | fzf

# vs

# Always enables colorized output.
command grep --color=always '^foo' /usr/share/dict/words | fzf