Paths

joel jijoel at lava.net
Tue Sep 4 11:59:59 PDT 2001


Rodney, 

Sorry for not getting back with you earlier; I was out the door moments after 
sending my last message. Heh... the call of the real life. ;-) 

The ~/.bashrc file is quite nifty. It's basically a script that automatically 
runs every time you open a new terminal. You can have some pretty incredible 
things in there, but I think it tends to be a good thing to start small, and 
figure out how to do more stuff as you need it. One interesting thing you can 
do with your .bashrc file is change your command prompt: 

I never really liked the default Mandrake command prompt. Everything just 
kind of ran together, so I couldn't easily tell where I issued a command. So, 
I put this line in my .bashrc file:

PS1='\n[\u@\h \w]\n$ '

So, every time that I get a command prompt, the computer will print a blank 
line, my user-name, the host-name of the computer I'm on, and the full name 
of my current working directory. Then, it puts in another line and gives me a 
simple $ prompt. The whole thing looks like this:

[joel at river ~/misc/linux/ITEC]
$

When I log in as the root user on my machine, I want to KNOW it, instantly, 
so I've set up that command prompt basically the same way, only it displays 
in RED, so I can instantly spot it. The command I use is: 

PS1="\[\033[1;31m\]\n[\u@\h \w]\n\[\033[1;31m\]\t$ \[\033[0m\]" 

There are a lot of other things you can put in to the command prompt, 
including stuff like how many files are in the current directory (or how much 
disk space the directory consumes), information on how much power your laptop 
battery has, and so on. For more information about setting your prompt, see 
http://www2.linuxjournal.com/lj-issues/issue64/3215.html and 
http://www.linuxdoc.org/HOWTO/Bash-Prompt-HOWTO/ 

There's a lot more you can do with the .bashrc file, like setting up aliases 
(short commands that replace or extend existing commands), sending an e-mail 
message to another account (for security), and so on. 

--Joel

On Monday 03 September 2001 03:28 am, Rodney Kanno wrote:
> Joel,
>
> K I got it working now..great! What other stuff can be put in the ~/.bashrc
> file?
>
> Thanks,
> Rodney
>
> On Monday 03 September 2001 03:21 pm, you wrote:
> > Heh... I should've forseen that one ;-)
> >
> > Yes. Setting any variable on the command line will only work for the
> > terminal you are currently in. It lets you test changes, figure out how
> > to configure stuff, and so on. To make a permanent change, something that
> > will automatically be done every time you log on, get a new terminal, or
> > whatever, just put the line at the end of your ~/.bashrc file.
> >
> > So, for instance, if you're running X and KDE, you'd get to a terminal
> > window and type:
> >
> > kwrite ~/.bashrc
> >
> > and at the bottom of the .bashrc file, you'd enter the change:
> >
> > PATH=$PATH:/home/rodney/bin/
> >
> > Save it, close it, you're set!
> >
> > --Joel
> >
> > On Monday 03 September 2001 03:08 am, Rodney Kanno wrote:
> > > Hi Joel
> > >
> > > Is PATH=$PATH:/home/rodney/bin/ just a temporary fix? Cause It seems to
> > > work only in the current terminal session. Once I close out of a
> > > terminal and come back in, it don't work anymore.
> > >
> > > Thanks,
> > > Rodney
> > >
> > > On Monday 03 September 2001 02:51 pm, you wrote:
> > > > If you wanted your /home/rodney/bin directory in your path, enter
> > > > this at the command line:
> > > >
> > > > PATH=$PATH:/home/rodney/bin/
> > > >
> > > > The first part of this will keep the existing path, and add
> > > > /home/rodney/bin at the end.
> > > >
> > > > --Joel
> > > >
> > > > On Monday 03 September 2001 02:42 am, Rodney Kanno wrote:
> > > > > Hi,
> > > > >
> > > > > How do I set path statements in Linux Mandrake 8.0? I have a
> > > > > program within several subdirectories and it is quite a pain to
> > > > > switch to the directory everytime I want to start the program.
> > > > >
> > > > > Thanks,
> > > > > Rodney



More information about the LUAU mailing list