home · contact · privacy
Fix ls color loss on switching to root.
authorPlom Heller <plom@plomlompom.com>
Sat, 19 Sep 2026 10:45:10 +0000 (12:45 +0200)
committerPlom Heller <plom@plomlompom.com>
Sat, 19 Sep 2026 10:45:10 +0000 (12:45 +0200)
home/any/.profile.d/aliases

index f0ff635ab2bac0ea513e6c577154050d9b3952a8..77d81583ac40e6f05fca06de1bc49e54e3d6d997 100644 (file)
@@ -1,2 +1,7 @@
+# dircolors only knows a terminal via its $TERM or a non-empty $COLORTERM,
+# and its database has no entry for foot's TERM=foot. So a shell that has
+# lost foot's COLORTERM=truecolor (e.g. root's, via "su -l", which keeps only
+# TERM) gets no LS_COLORS and hence no ls colors. Fill it in with a forced
+# COLORTERM in that case; an existing LS_COLORS is left alone.
+[ -n "${LS_COLORS}" ] || eval "$(COLORTERM=${COLORTERM:-truecolor} dircolors -b)"
 alias ls="ls --color=auto"
-