#! /bin/bash # # this file: # https://dataswamp.org/~incal/cols/dircolors-script # # This script assigns colors to files based on their # extensions, it is sourced and put into effect by ls(1). # See dircolors(1). # # useful commands: # $ dircolors --print-database # $ man dircolors # dircolors(1) # $ info dircolors # $ dircolors --print-database | grep -i -A1 'attribute codes' # # with Emacs: # (man "dircolors") # (info "(coreutils) dircolors invocation") # # attributes: # 00 none 00-01 are supported in the Linux VT/tty/console # 01 bright # 02 n/a # 03 n/a # 04 underscore 04-05 & 07-08 are not supported (?) # 05 blink # 06 n/a # 07 reverse # 08 concealed # colors (30-37) local N='00;30' # black local R='00;31' # red local G='00;32' # green local Y='00;33' # yellow local B='00;34' # blue local M='00;35' # magenta local C='00;36' # cyan local W='00;37' # white # bright (01) local BN='01;30' # black (can be set as gray, for example) local BR='01;31' # red local BG='01;32' # green local BY='01;33' # yellow local BB='01;34' # blue local BM='01;35' # magenta local BC='01;36' # cyan local BW='01;37' # white # background (40-47) local BGN='40' # black local BGR='41' # red local BGG='42' # green local BGY='43' # yellow local BGB='44' # blue local BGM='45' # magenta local BGC='46' # cyan local BGW='47' # white # file types # NORMAL 00 # FILE 00 local RS="rs=0" # reset to NORMAL local DI="di=$BB" # directory local LN="ln=$C" # symlink local MH="mh=00" # multihardlink local PI="pi=$BY;$BGB" # pipe/FIFO local SO="so=$BM" # socket local DO="do=$M" # door - n/a local BD="bd=$BY;$BGB" # block device driver local CD="cd=$Y;$BGB" # char device driver local OR="or=$R" # broken symlink (orphan) or non-stat(1)able file # MISSING 00 local SU="su=$N;$BGY" # user sticky bit, setuid u+s local SG="sg=$BN;$BGR" # group sticky bit, setgid g+s local CA="ca=$N;$BGR" # capability (?) local TW="tw=$N;$BGG" # sticky and other-writable directory, i.e. +t o+w local OW="ow=$BN;$BGG" # -t o+w local ST="st=$BW;$BGB" # +t o-w local EX="ex=$BG" # executable, +x # archive local AR="$BN" local ARCHIVE="*.7z=$AR:*.Z=$AR:*.ace=$AR:*.arj=$AR:*.bz2=$AR:*.bz=$AR:*.cpio=$AR:*.deb=$AR:*.dz=$AR:*.ear=$AR:*.gz=$AR:*.jar=$AR:*.lz=$AR:*.lzh=$AR:*.lzma=$AR:*.rar=$AR:*.rpm=$AR:*.rz=$AR:*.sar=$AR:*.tar=$AR:*.taz=$AR:*.tbz2=$AR:*.tbz=$AR:*.tgz=$AR:*.tlz=$AR:*.txz=$AR:*.tz=$AR:*.war=$AR:*.xz=$AR:*.z=$AR:*.zip=$AR:*.zoo=$AR" # audio local AUD="$BM" local AUDIO="*.aac=$AUD:*.au=$AUD:*.axa=$AUD:*.flac=$AUD:*.m4a=$AUD:*.mid=$AUD:*.midi=$AUD:*.mka=$AUD:*.mp3=$AUD:*.mpc=$AUD:*.oga=$AUD:*.ogg=$AUD:*.opus=$AUD:*.ra=$AUD:*.spx=$AUD:*.wav=$AUD:*.xspf=$AUD" # header local HH="$M" local HEADER="*.h=$HH:*.hh=$HH" # HTML local HTMLP="$W;$BGB" local HTML="*.htm=$HTMLP:*.html=$HTMLP" # image local IMG="$N;$BGG" local IMAGE="*.bmp=$IMG:*.gif=$IMG:*.jpeg=$IMG:*.jpg=$IMG:*.mng=$IMG:*.pbm=$IMG:*.pcx=$IMG:*.pgm=$IMG:*.png=$IMG:*.pnm=$IMG:*.ppm=$IMG:*.svg=$IMG:*.svgz=$IMG:*.tga=$IMG:*.tif=$IMG:*.tiff=$IMG:*.webp=$IMG:*.xbm=$IMG:*.xpm=$IMG" # object/compiled local DIMP="$G" local DIM="*.o=$DIMP:*.elc=$DIMP" # PDF, PS, man.1 local PDFP="$N;$BGW" local PDF="*.1=$PDFP:*.7=$PDFP:*.pdf=$PDFP:*.ps=$PDFP" # source local SRC="$G" local SOURCE="*.bib=$SRC:*.c=$SRC:*.cc=$SRC:*.cpp=$SRC:*.el=$SRC:*.fps=$SRC:*.tex=$SRC" # video local VID="$BY" local VIDEO="*.3GP=$VID:*.M2TS=$VID:*.anx=$VID:*.asf=$VID:*.avi=$VID:*.axv=$VID:*.cgm=$VID:*.dl=$VID:*.emf=$VID:*.flc=$VID:*.fli=$VID:*.flv=$VID:*.gl=$VID:*.m2ts=$VID:*.m2v=$VID:*.m4v=$VID:*.mkv=$VID:*.vid=$VID:*.mp4=$VID:*.mp4v=$VID:*.mpeg=$VID:*.mpg=$VID:*.nuv=$VID:*.ogm=$VID:*.ogv=$VID:*.ogx=$VID:*.qt=$VID:*.rm=$VID:*.rmvb=$VID:*.ts=$VID:*.vob=$VID:*.webm=$VID:*.wmv=$VID:*.xcf=$VID:*.xwd=$VID:*.yuv=$VID" # text local TXT="$BW" local TEXT="*.txt=$TXT" # web local CSS="*.css=$B;$BGW" local PHP="*.php=$BW;$BGB" local TORRENT="*.torrent=$BW;$BGM" # misc local ISO="*.iso=$N;$BGC" local MAKEFILE="*Makefile=$BW;$BGB" # done local TYPES="$ARCHIVE:$AUDIO:$CSS:$DIM:$HEADER:$HTML:$IMAGE:$ISO:$VIDEO:$PDF:$PHP:$SOURCE:$TEXT:$TORRENT" LS_COLORS="$RS:$BD:$CA:$CD:$DI:$DO:$EX:$MH:$OR:$OW:$PI:$SG:$SO:$ST:$SU:$TW:"$MAKEFILE":"$TYPES export LS_COLORS