PAGER=less
export PAGER
-# Set colors for ls (and zsh completions). This colors files normal (fi),
+# Set colors for GNU ls (and zsh completions). This colors files normal (fi),
# directories blue bold (di), symbolic links cyan (ln), named pipes normal
# (pi), sockets normal (so), block devices normal (bd), character devices
# normal (cd) and executables bold red (ex).
# See `dircolors --print-database` for possible colors.
LS_COLORS='no=00:fi=00:di=34;01:ln=36:pi=00:so=00:bd=00:cd=00:ex=31;01'
export LS_COLORS
+# Set the same colors for non GNU ls.
+LSCOLORS='ExgxxxxxBxxxxxBxBxExEx'
+# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+# | | | | | | | | | | |
+# | | | | | | | | | | *- directory writable to others, without sticky bit
+# | | | | | | | | | *--- directory writable to others, with sticky bit
+# | | | | | | | | *----- executable with setgid bit set
+# | | | | | | | *------- executable with setuid bit set
+# | | | | | | *--------- character special
+# | | | | | *----------- block special
+# | | | | *------------- executable
+# | | | *--------------- pipe
+# | | *----------------- socket
+# | *------------------- symbolic link
+# *--------------------- directory
+export LSCOLORS
# Sources a configuration file if it exists; loads a fallback .local file if
# Improved ls which displays the files in columns (-C), visualises directories,
# links and other special files (-F) and pages everything through less (L).
+#
+# If available use GNU ls with colorized output. If it isn't available use
+# normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
+# pager.
+ls --color &> /dev/null
+if [[ $? -eq 0 ]]; then
+ alias ls='ls --color'
+else
+ alias ls='CLICOLOR_FORCE=1 ls -G'
+fi
+# Main ls function.
function ls() {
command ls -C -F $* L
}