Introduce '--keep-ansi' option to keep ANSI codes on output
This improves filtering mode by allowing cases when colors needed to be passed from input to output in filtering mode.
@7ocb no plan to fix?
@blcham I initially intended to but had no time. I just did another attempt now and to be honest I'm not sure how to approach this.
The tests on CI failing:
2) Failure:
TestGoFZF#test_kill_default_command_on_accept [test/test_go.rb:1960]:
Expected: "Started"
Actual: ""
171 runs, 1425 assertions, 1 failures, 0 errors, 1 skips
but this test succeeds for me locally (here I commented other tests) :
# Running:
TestGoFZF#test_kill_default_command_on_accept = 0.16 s = .
Finished in 0.164830s, 6.0669 runs/s, 30.3343 assertions/s.
1 runs, 5 assertions, 0 failures, 0 errors, 0 skips
also the on CI in "test fzf on linux" this test passes also.
@7ocb :heart: thanks for the try, not sure how to fix this either
@blcham also I rebased this PR on top of base/master, so can be used as drop-in replacement of original fzf :smile:
Could it be merged into the original repo? @junegunn
Just rebased this on latest master.
All checks are green.
@7ocb
I did following:
git clone https://github.com/7ocb/fzf
cd fzf
git checkout keep-colors-on-ouptut-cleaned
make
ls --color=auto | ./target/fzf-linux_amd64 --keep-ansi
The last command did not show me any color :(:
Is it expected behavior?
@blcham you need to do
ls --color | fzf --keep-ansi --ansi:
@7ocb thanks a lot! it works! However my original issue was not only ls --color, but vimcat :(. I thought it is the same case, so i presented ls --color instead. The following still does not work for me:
vimcat some-file-with-syntax-highlighting | fzf --keep-ansi --ansi
Any idea about that? Is vimcat not using ansi?
@blcham likely vimcat detects if it's output goes to terminal or to pipe and it does not include coloring in case if it's output goes to pipe (in same way as ls --color=auto does).