Colourful file listings in the terminal
If you are bored of the plain black and white colour file listings when you type “ls” in your Terminal, you can actually make the ls command colour the files based on their type (not mime type, but directory, symlink, etc) and extension.
If you add the switch -C or –color to the ls command (i.e.)
ls -F -color
then you should get somewhat more interesting output!
If you want to have some control over the colours that are displayed for each file type, create a file called
.dircolours (or similar) in your home directory containing an entry for each terminal type (i.e. beterm or xterm) and the list of file extensions along with their colours. The example below demonstrates how this works.
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 00;32 # directory
LINK 01;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
*~ 05;31 # stuff we hate to find laying around (flashing red)
.c 00;35 # source code
.tar 00;31 # archives or compressed (bright red)
Once you have saved this file somewhere you need to add the following commands to your
.bashrc is probably better), replacing the
.dircolours filename with whatever you used…
eval `dircolors ~/.dircolours` alias ls='ls --color=always'
Posted in Terminal
(comments are closed).