autocomplete icon indicating copy to clipboard operation
autocomplete copied to clipboard

[ls] ANSI color escape codes showing up in file names

Open excursus opened this issue 3 years ago • 5 comments

Sanity checks

  • [X] My issue relates to a specific CLI completion spec (e.g. git checkout is missing options in git completion spec). If your issue is more general, please create your issue here: withfig/fig
  • [X] I have searched github.com/withfig/autocomplete/issues and there are no duplicates of my issue
  • [ ] I would like to work on this.

What CLI tool does this relate to?

ls

Which statement makes the most sense?

There is a bug with this completion spec

Issue Details

I'm seeing ascii escape codes in file names like this: image Is this intended behavior?

excursus avatar Oct 20 '22 00:10 excursus

That is wild!! Have never seen this happen before 😄 @fedeci

This looks like it might be a bug in the autocomplete engine itself because ls uses the builtin generators. Will have a go at fixing myself

clo4 avatar Oct 21 '22 05:10 clo4

@excursus Looks like you're running fish, what fish version is it? (fish --version) and do you have a file named ls.fish in your ~/.config/fish/functions folder?

clo4 avatar Oct 21 '22 05:10 clo4

Sorry for the spam - one more thing to check, do the file names actually have escape codes in them? Given that fish is also suggesting the escape codes, it looks like they might... for some reason. Try running this command and send us the output 🙂

for file in *; echo $file; math (echo $file | wc -c) - 1; end

clo4 avatar Oct 21 '22 05:10 clo4

Thanks for looking into this! Here are the answers to your questions:

  • fish version 3.3.1
  • I don't have an ls.fish in ~/.config/fish/functions.
  • Running the above command produces:
test1
5
test2
5

excursus avatar Oct 21 '22 15:10 excursus

The problem seems to be cause by the following line in my config.fish: set -Ux CLICOLOR_FORCE 1 If I uncomment this line the problem goes away.

excursus avatar Oct 22 '22 17:10 excursus