Open pagerc opened 4 years ago
The original ls.c
expects color strings to not have printable characters. For multi-column mode ls.c
calculates the lenght of each printed name to add whitespace padding in an attempt to avoid adding linebreaks in the middle of file names. But since it doesn't expect printable characters in the color sequence it will calculate these lengths "wrong" for our purpose.
Unpatched:
Patched: (please ignore the alignment issue for test.plist, I probably have a problem in my file type definition, I'm not using the code of even-better-ls, but just the concept)
The patch basically boils down to a
if (print_with_color) {
// add 1 character for the icon, and 1 character for the space between icon and filename
len += 2;
}
in static size_t length_of_file_name_and_frills()
The patch process could however be improved massively. Right now the supplied ls.c is years old.
The original LS has dir_colors for generating the LS_COLORS attributes, which already supports console escape sequences which permits mapping unicode character sets to file types:
This for example, when the below is added to ~/.dir_colors, it will make all rc resource files light green in appearance and set the alpine linux icon when using NerdFonts: *rc 36m \e[36
I recommend updating the project/readme with the above details to assist in disseminating this information so that as a community we can focus on improving our file type mappings with contributions to https://github.com/trapd00r/LS_COLORS additional icon/color mappings.