Use symlink target for stat styling & icons (#566) (#1644)

* use symlink target for stat styling & icons (#566)

Support LS_COLORS/dircolors use of "target" for symlinks to select icons
and styles for them according to the target stat. This mainly applies to
directories - file name-based styles will still be based on the name of
the link, not its target. This mirrors `ls` behavior.

* remove unnecessary debugging and factor out parsePair in color parsing

* move conditional to switch block

* clarify ln target behavior in docs

* run gofmt on single file

---------

Co-authored-by: Gökçehan Kara <gokcehankara@gmail.com>
This commit is contained in:
lorentzforcesandGökçehan Kara authored and GitHub committed 2024-04-07 15:35:46 +02:00
1 parent 21d256d7da
commit 5b108037a3
5 files changed
+93 -65

No files matched your search

+9 -3
View File
@@ -2026,8 +2026,11 @@ escaping newlines with backslashes as follows:
ex=01;32:\
"
Having such a long variable definition in a shell configuration file
might be undesirable. You may instead use the colors file (refer to the
The ln entry supports the special value target, which will use the link
target to select a style. File name rules will still apply based on the
link's name -- this mirrors GNU's ls and dircolors behavior. Having such
a long variable definition in a shell configuration file might be
undesirable. You may instead use the colors file (refer to the
CONFIGURATION section) for configuration. A sample colors file can be
found at https://github.com/gokcehan/lf/blob/master/etc/colors.example
You may also see the wiki page for ANSI escape codes
@@ -2038,7 +2041,10 @@ ICONS
Icons are configured using LF_ICONS environment variable or an icons
file (refer to the CONFIGURATION section). The variable uses the same
syntax as LS_COLORS/LF_COLORS. Instead of colors, you should put a
single characters as values of entries. The icons file (refer to the
single characters as values of entries. The ln entry supports the
special value target, which will use the link target to select a icon.
File name rules will still apply based on the link's name -- this
mirrors GNU's ls and dircolors behavior. The icons file (refer to the
CONFIGURATION section) should consist of whitespace-separated pairs with
a # character to start comments until the end of the line. Do not forget
to add set icons true to your lfrc to see the icons. Default values are