Last active
January 5, 2018 16:07
-
-
Save alexeygorelov/51e017f1b14ed09d0b80f219989785f0 to your computer and use it in GitHub Desktop.
Для LS_COLORS выводит тип и описание соответствующего цвета.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
# Additional information 'dircolors -p' and 'man dir_colors' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment