blob: 7eb61fdef3ce267b60d1c2faa86e3072d284b29b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# Test that we have metadata about what options this system's ls(1) supports,
# and try to create it if not
(
# Create a directory to hold metadata about ls(1)
lcd=$HOME/.cache/ls
if ! [ -d "$lcd" ] ; then
mkdir -p -- "$lcd" || exit
fi
# Write ls(1)'s --help output to a file, even if it's empty
if ! [ -f "$lcd"/help ] ; then
ls --help >"$lcd"/help 2>/dev/null || exit
# Iterate through some useful options and create files to show they're
# available
if grep -q -- --color "$lcd"/help ; then
touch -- "$lcd"/color || exit
fi
fi
) || return
# Run dircolors(1) to export LS_COLORS if available and appropriate
if [ -e "$HOME"/.cache/ls/color ] ; then
if command -v dircolors >/dev/null ; then
if [ -r "$HOME"/.dircolors ] ; then
eval "$(dircolors --sh -- "$HOME"/.dircolors)"
else
eval "$(dircolors --sh)"
fi
fi
fi
|