forked from sayan01/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-ls-colorcode
executable file
·43 lines (38 loc) · 1.21 KB
/
show-ls-colorcode
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
#!/bin/bash
# For LS_COLORS, print type and description in the relevant color.
IFS=:
for ls_color in $LS_COLORS; do
color="${ls_color#*=}"
type="${ls_color%=*}"
# Add descriptions for named types.
case "$type" in
bd) type+=" (block device)" ;;
ca) type+=" (file with capability)" ;;
cd) type+=" (character device)" ;;
di) type+=" (directory)" ;;
do) type+=" (door)" ;;
ex) type+=" (executable file)" ;;
fi) type+=" (regular file)" ;;
ln) type+=" (symbolic link)" ;;
mh) type+=" (multi-hardlink)" ;;
mi) type+=" (missing file)" ;;
no) type+=" (normal non-filename text)" ;;
or) type+=" (orphan symlink)" ;;
ow) type+=" (other-writable directory)" ;;
pi) type+=" (named pipe, AKA FIFO)" ;;
rs) type+=" (reset to no color)" ;;
sg) type+=" (set-group-ID)" ;;
so) type+=" (socket)" ;;
st) type+=" (sticky directory)" ;;
su) type+=" (set-user-ID)" ;;
tw) type+=" (sticky and other-writable directory)" ;;
esac
# Separate each color with a newline.
if [[ "$color_prev" ]] && [[ "$color" != "$color_prev" ]]; then
echo
fi
printf "\e[%sm%s\e[m " "$color" "$type"
# For next loop
color_prev="$color"
done
echo