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

Icons of symbolic links to directories #566

Closed
Naheel-Azawy opened this issue Jan 26, 2021 · 3 comments · Fixed by #1644
Closed

Icons of symbolic links to directories #566

Naheel-Azawy opened this issue Jan 26, 2021 · 3 comments · Fixed by #1644

Comments

@Naheel-Azawy
Copy link

I have just noticed that the icons of links to directories look like files (ln=🗎). I guess the source shows the reason in icons.go:

case f.linkState == working:
	key = "ln"

Maybe it's possible to add something like ln-di? But some might complain about other icons too. Maybe better ignore checking if it's a link or not and just use the icon of the linked file? Not sure, what do you think?

@gokcehan
Copy link
Owner

@Naheel-Azawy I'm still trying to keep our color and icon configuration symmetric. And as you know color configuration is still somewhat compatible with ls colors. I think dircolors have an option for this in the form LINK target. Maybe we can implement something similar though I don't know if it is feasible in our code or not.

@Dimfred
Copy link

Dimfred commented Aug 13, 2021

Maybe better ignore checking if it's a link or not and just use the icon of the linked file?
Ranger does it also like this the link has the same icon as the underlying file.

That would be really great to have an ignore, like when ln is not present in LF_ICONS to then take the underlying filetype.

@lorentzforces
Copy link
Contributor

lorentzforces commented Feb 25, 2024

Old issue, but I was looking for discussion of link target colors and here I am.

I'd be willing to take a stab at getting something together for this.

It looks like right now the biggest hurdle is in how to represent that preference in the icon/color mapping; the code that determines how to style the entries in a directory looks pretty straightforward. I could see two options off the bat: we could either use some kind of special value (like a hardcoded string we stuff into the icon map or a field on a tcell.Style). The other option might be to redefine the styleMap and iconMap types to be structs with an additional boolean field called useLinkTarget or something similar, and check that when determining styling when rendering the UI. That has the disadvantage of requiring an update to any access to those types, but there aren't too many of them and the change would be pretty light. They're already defined as types, so we've got that going for us, at least. This seems relatively cleaner as an approach.

Any preference one way or the other? Happy to take any guidance.

lorentzforces added a commit to lorentzforces/lf that referenced this issue Mar 17, 2024
Support LS_COLORS/dircolors use of "target" for symlinks to style 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.
lorentzforces added a commit to lorentzforces/lf that referenced this issue Mar 17, 2024
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.
lorentzforces added a commit to lorentzforces/lf that referenced this issue Mar 17, 2024
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.
lorentzforces added a commit to lorentzforces/lf that referenced this issue Mar 17, 2024
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.
gokcehan added a commit that referenced this issue Apr 7, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants