
Colorize Files in Your Pager #15
Chapter 2, Console
|
51
HACK
Solution 3
Neither of the previous solutions is the “Linux way”; that is, a way to cus-
tomize and automate everything. So, here’s a way to solve the problem like a
true Linux hacker would. Define aliases to give you the choices you want
while using shorthand commands. Here’s one example, but it is by no
means the only way to approach this. Edit the file where aliases are defined
so that it contains these aliases:
alias ls='ls --color=auto'
alias lsp='ls --color | less -R'
alias dir='ls -al'
alias dirp='ls -al --color | less -R'
This way, you can issue a command such as ls -al > directory.txt, and
the file won’t be littered with color codes. Yet anytime you want to page
through a full list of your files in living color, all you have to type is the com-
mand
lsp or dirp.
Bash Auto-Configuration Files
Fedora Core sets default aliases in the /etc/profile.d/colorsls.sh file to:
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
Debian sets default aliases in the /etc/skel/.bashrc file to:
alias ls='ls --color=auto'
SUSE uses a complex /etc/bash.bashrc script that ends up setting the ls alias
indirectly to:
alias ls='ls --color=tty'
Mandrake uses a complex set of files, and sets the default alias in /etc/
profiles.d/alias.sh to:
alias ls='--color=auto'
Gentoo sets default aliases in /etc/skel/.bashrc to:
alias ls="ls --color=auto" ...