How to get `ls` on NixOS to work same as Debian

Hi folks,

I noticed a funny thing that ls on NixOS when executed / aliased to ls --color=auto doesn’t show broken symlinks with red color.

I know it’s stupid but I’m really used to have Debian ls that shows blue symlinks when they work and red when the destination doesn’t exist. Please let me know if there is a fix for that :wink: Thank you.

Yes, there is.

First, try this:

eval $(dircolors -b)

This sets the LS_COLORS environment variable to something more complex than the default value. Debian probably does this in one of the .profile or .bashrc files.

After this, your ls output should already make broken symlinks appear red.

I thought to make this permanent on NixOS system-wide, you could set the enableLsColors option in your configuration, but it seems the default is true already, so not sure if that will work.

2 Likes

Ouh no, I broke it by myself. I set it to false (and shellAliases to {}) thinking how clever I am since I will set it to the proper values only for some specific users via home-manager.

Solved! Thank you so much.