Date: Mon, 03 Aug 1998 20:35:10 -0700 From: Studded <Studded@dal.net> To: Sascha Schumann <sas@schell.de> Cc: William Woods <wwoods@cybcon.com>, "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG> Subject: Re: BASH prompt question Message-ID: <35C6816E.58367535@dal.net> References: <Pine.LNX.3.96.980804031907.17819A-100000@www.schell.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Sascha Schumann wrote:
>
> On Mon, 3 Aug 1998, Studded wrote:
>
> > Sascha Schumann wrote:
> > >
> > > On Sun, 2 Aug 1998, William Woods wrote:
> > >
> > > > I would like to make my bash prompt show a little more info, like what dir the
> > > > user is in. How would I do this?
> > >
> > > Edit /etc/profile and insert at the end:
> > >
> > > test "$SHELL" = "/bin/bash" && test -e ~/.bashrc && source ~/.bashrc
> >
> > Why are you inserting a test to accomplish something that bash does by
> > default?
>
> Because it's not default nor done automatically.
>
> I don't like to quote documents everybody has. But if people are too lazy
> to look at it, I have to do it...
There's no reason to be rude. In point of fact I have read the system
docs on bash, and quite a bit of supplementary literature. :)
> ~/.bashrc _will be_ sourced automatically by bash, if you...
>
> o do a `su [username]'
> o start a xterm
Agreed.
> It will _not_be automatically sourced, if you...
>
> o do a `su - [username]'
In which case you may or may not want that behaviour, but see below.
> o login from console
I actually have my prompt and most other stuff in .bash_profile, but
you can get what you want by putting the test in your local
.bash_profile instead of the system /etc/profile, which is the point
that someone else tried to make in this thread earlier.
> o use sth else to login remotely
I'm not familiar with sth. Another option for the su case that I've
been using very successfully is the --rcfile option. I have an alias
like this:
alias rootme='/usr/bin/su -m root --rcfile $HOME/.bash_profile'
which allows me both to have the option of carrying my native
environment around or just using su if I want the root environment.
There are other ways of accomplishing this using combinations of
.bash_profile and .bashrc files, but I've found that this system works
well for me.
> > > PS1='\u@\h:`pwd -P` $ '
> > > export PS1
> >
> > Again, working too hard. :) Why call a shell function every time you
> > hit return? The following accomplishes what you have there, and adds
> > your correction for the \$:
>
> My profile files etc are set up in the way
>
> A=asdasd
> B=sthelse
> C=hohoh
>
> export A B C
>
> So, I don't have to type 1000s of exports...
>
> We probably don't need to discuss the overhead of either method ;)
*nod* The only reason I don't have mine set up that way is that I don't
like having to edit features in more than one location. I don't have so
many things to add and subtract that it's a huge burden, however I like
to keep things tidy.
> > export PS1='\u@\h: \w \$'
> >
> > This syntax is available in bash 2 and above, but you should be using
> > bash 2 anyway. :)
>
> Because I've used older versions which didn't have it. The last thing I do
> is to look for more features for my prompt ;)
Yeah, it's not a major point, but on a lot of the systems I work on
every cpu cycle is precious.
> > This may be more details than the original poster wanted, but the goal
> > is to show what's possible. Some people have implemented colored prompts
> > using ansi escape codes, but I haven't gotten that obsessed yet. :)
>
> A red prompt would be nice, if you are root. That makes you even think a
> little bit more before doing sth like "/tmp # rm -R wfiles /" instead of
> "/tmp # cp -R wfiles /" like I did some days ago :-(( ;)
Yeah, that's one of the most popular uses. A friend of mine has a lot
of this kind of stuff lying around... If I get it working I'll post it.
Doug
--
*** Chief Operations Officer, DALnet IRC network ***
When you don't know where you're going, every road will take you there.
- Yiddish Proverb
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35C6816E.58367535>
