-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow-ls-colors.sh
More file actions
executable file
·50 lines (43 loc) · 1.19 KB
/
show-ls-colors.sh
File metadata and controls
executable file
·50 lines (43 loc) · 1.19 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# For each entry in LS_COLORS, print the type, and description if available,
# in the relevant color.
# If two adjacent colors are the same, keep them on one line.
# Source:
# https://askubuntu.com/a/884513
declare -A descriptions=(
[bd]="block device"
[ca]="file with capability"
[cd]="character device"
[di]="directory"
[do]="door"
[ex]="executable file"
[fi]="regular file"
[ln]="symbolic link"
[mh]="multi-hardlink"
[mi]="missing file"
[no]="normal non-filename text"
[or]="orphan symlink"
[ow]="other-writable directory"
[pi]="named pipe, AKA FIFO"
[rs]="reset to no color"
[sg]="set-group-ID"
[so]="socket"
[st]="sticky directory"
[su]="set-user-ID"
[tw]="sticky and other-writable directory"
)
IFS=:
for ls_color in $LS_COLORS; do
color="${ls_color#*=}"
type="${ls_color%=*}"
# Add description for named types.
desc="${descriptions[$type]}"
# Separate each color with a newline.
if [[ $color_prev ]] && [[ $color != "$color_prev" ]]; then
echo
fi
printf "\e[%sm%s%s\e[m " "$color" "$type" "${desc:+ ($desc)}"
# For next loop
color_prev="$color"
done
echo