Skip to Main Content
Linux Desktop Hacks
book

Linux Desktop Hacks

by Nicholas Petreley, Jono Bacon
March 2005
Beginner to intermediate content levelBeginner to intermediate
342 pages
15h 55m
English
O'Reilly Media, Inc.
Content preview from Linux Desktop Hacks
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" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Server Hacks, Volume Two

Linux Server Hacks, Volume Two

William von Hagen, Brian K. Jones
Introducing Linux Distros

Introducing Linux Distros

Jose Dieguez Castro

Publisher Resources

ISBN: 0596009119Supplemental ContentCatalog PageErrata