TIP: Click on subject to list as thread! ANSI
echo: unix
to: Finnigann
from: Angus McLeod
date: 2008-05-21 20:05:04
subject: bash mods

Re: bash mods
  By: Finnigann to All on Fri Feb 24 2006 01:53:00

 >         I recall modifying a private file (.bashrc perhaps) so that the
 > ls command was colorized in someway and the command dir worked the same
 > way as ls did.
 > 
 > Do I recall correctly? How did I do it?

The Bourne Again shell (bash) examines a number of files during 
initialization of an interactive login shell, reading and executing 
commands found therein.  First /etc/profile, and then whichever is the 
first it finds out of ~/.bash_profile, ~/.bash_login, and ~/.profile in 
that order.  (I personally stick with ~/.profile for compatability with 
other shells.)

When an interactive shell that is *not* a login shell starts, it usually 
executes commands from ~/.bashrc instead.

Non-interactive invocations execute whatever commands it finds in the file 
whose name it finds in the $BASH_ENV environment variable.

Loads of interesting details in the bash man-page under INVOCATION.  (Did 
you know that there was a ~/.bash_logout script?)

Colourizing the output from 'ls' is done by setting up the LS_COLORS 
environment variable, which can be done in any of those files as you 
choose.  Globally, /etc/profile is the best choice, and I recmment 
~/.profile for individual users.

You can set 'dir' to be the equivilent to 'ls' by means of an alias in the 
same initialization file as you et the colours for ls.  Just put 

	alias dir='/usr/bin/ls $LS_OPTIONS --format=vertical';

(season to taste) in /etc/profile or ~/.profile as suits you.


Since the LS_COLORS variable can be complicated to set up, and the 'dir' 
alias is common, Slackware uses a utility /usr/bin/dircolors to set up the 
variable.  That program is executed from within /etc/profile and can be 
used to set LS_COLORS, LS_OPTIONS, the 'dir' alias, and a number of other 
aliases that relate to 'ls'.  I don't know if /usr/bin/dircolors is 
available on RH systems or not.

---
Playing: "Lay me low" by "Nick Cave & The Bad Seeds"
         from the "Let love in" album
 þ Synchronet þ Linus is a regular at The ANJO BBS.  No, Linus Brathwaite!
--- SBBSecho 2.12-Win32
* Origin: Joe's Computer & BBS -= joesbbs.synchro.net =- (1:275/412)
SEEN-BY: 10/1 3 14/250 34/999 90/1 120/228 123/500 140/1 222/2 226/0 236/150
SEEN-BY: 249/303 250/306 261/20 38 100 1404 1406 1418 266/1413 280/1027
SEEN-BY: 320/119 393/68 396/45 633/104 260 267 690/682 734 712/848 800/432
SEEN-BY: 801/161 189 2222/700 2320/100 105 200 2905/0
@PATH: 275/412 400 100 140/1 261/38 633/260 267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.