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

Introduce '--keep-ansi' option to keep ANSI codes on output #2693

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

7ocb
Copy link
Contributor

@7ocb 7ocb commented Dec 24, 2021

This improves filtering mode by allowing cases when colors needed to be passed from input to output in filtering mode.

@7ocb 7ocb mentioned this pull request Dec 24, 2021
15 tasks
@blcham
Copy link

blcham commented May 21, 2022

@7ocb no plan to fix?

@7ocb 7ocb force-pushed the keep-colors-on-ouptut-cleaned branch from 6c7457f to 8b99a8f Compare May 22, 2022 09:17
@7ocb
Copy link
Contributor Author

7ocb commented May 22, 2022

@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.

@blcham
Copy link

blcham commented May 22, 2022

@7ocb ❤️ thanks for the try, not sure how to fix this either

@7ocb
Copy link
Contributor Author

7ocb commented May 22, 2022

@blcham also I rebased this PR on top of base/master, so can be used as drop-in replacement of original fzf 😄

@7ocb 7ocb force-pushed the keep-colors-on-ouptut-cleaned branch from 8b99a8f to 30d156d Compare February 25, 2023 14:34
@WantToLearnJapanese
Copy link

Could it be merged into the original repo? @junegunn

This improves filtering mode by allowing cases when colors needed to be passed from input to output in filtering mode.
@7ocb 7ocb force-pushed the keep-colors-on-ouptut-cleaned branch from 30d156d to f707182 Compare August 25, 2023 11:05
@7ocb
Copy link
Contributor Author

7ocb commented Aug 25, 2023

Just rebased this on latest master.

@7ocb
Copy link
Contributor Author

7ocb commented Aug 25, 2023

All checks are green.

@blcham
Copy link

blcham commented Sep 28, 2023

@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 :(:
image

Is it expected behavior?

@7ocb
Copy link
Contributor Author

7ocb commented Oct 1, 2023

@blcham you need to do

ls --color | fzf --keep-ansi --ansi:

2023-10-01--11-32-41

@blcham
Copy link

blcham commented Oct 1, 2023

@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?

@7ocb
Copy link
Contributor Author

7ocb commented Oct 2, 2023

@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).

@dir
Copy link

dir commented Jul 1, 2024

I take it this hasn't gotten implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants