colorls icon indicating copy to clipboard operation
colorls copied to clipboard

Icons for file with only one extension

Open theloadstar opened this issue 2 years ago • 7 comments

  • Relevant Issues : (none)
  • Relevant PRs : (none)
  • Type of issue :
    • [ ] Installation
    • [x] Font-related
    • [ ] Feature request
    • [ ] Bug in existing feature
    • [ ] Developer mode : Code quality / Tests / Documentation

Hello, the colorls in my machine can't recognize file with only one extension such as .ignore, .DS_Store,.type_example, here is an example: image

The file .DS_Store and .gitignore are recognized as file type instead of apple / git type. I changed nothing in yaml dir.(I also tried adding ds_store:"\ue711", and it didn't work.)

If I add any latters before dot, it can recognize rightly. For example, I renamed .gitignore to test.gitignore,it showed as follow: image

Other files with name before dot can be recognized correctly. My system is macOS 10.15.7, and I have installed nerd-font.

Thank you for reading.

theloadstar avatar Aug 10 '21 06:08 theloadstar

Thanks for the bug report!

The problem is that the files you mentioned do not have an extension.

For example, .gitignore is a hidden file, which is denoted by the leading dot, but by there is no file extension.

We would need to change the implementation that we no longer recognise files by extension, but rather using a suffix match, such that if one wanted to specify a icon for a file with an extension you would have to include the dot in the pattern.

avdv avatar Aug 12 '21 08:08 avdv

Thank you for replying.

I tried adding .DS_Store: apple in the file file_aliases.yaml before and didn't work, wondering how to realize if one wanted to specify an icon for a file with an extension you would have to include the dot in the pattern.

I noticed in README.md, the colorls can recognize the files that do not have an extension like .gitignore and .DS_Store, I just wondering how does it work, do I need to change something in file_aliases.yaml or file.yaml? image

My English is not so good, thank you for reading :)

theloadstar avatar Aug 12 '21 09:08 theloadstar

You are right, it used to work in older versions, but I broke it in commit https://github.com/athityakumar/colorls/commit/17b2142c48ac6cd760532116c0e483085caaea2c while fixing #441.

(In my defence, there were no unit tests assuring this works the way it did)

avdv avatar Aug 12 '21 17:08 avdv

Got it, thank you for replying :)

theloadstar avatar Aug 13 '21 00:08 theloadstar

Why did you close this? This is a valid issue that is supposed to work!

avdv avatar Aug 13 '21 09:08 avdv

Sorry, I thought after the commit 17b2142c48ac6cd760532116c0e483085caaea2c colorls won't bring this feature back again, my mistake , ಠ_ಠ

theloadstar avatar Aug 13 '21 09:08 theloadstar

Hi, would a code snippet like this here :

extension = File.extname(content.name).delete_prefix(".")
basename = File.basename(content.name, ".*").delete_prefix(".")
key = extension.empty? ? basename : extension
key = key.downcase.to_sym

solve this issue ? This might also solve #459 I have never done any ruby before so this might not be optimised / up to standard etc, but it seems to work on online compiler environments

olirwin avatar Jan 26 '23 10:01 olirwin