From owner-freebsd-questions Mon Aug 3 18:50:57 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA12891 for freebsd-questions-outgoing; Mon, 3 Aug 1998 18:50:57 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from www.schell.de ([195.20.238.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA12881 for ; Mon, 3 Aug 1998 18:50:45 -0700 (PDT) (envelope-from sas@schell.de) Received: from localhost (sas@localhost [127.0.0.1]) by www.schell.de (8.9.0/8.9.0) with SMTP id DAA19012; Tue, 4 Aug 1998 03:50:27 +0200 Date: Tue, 4 Aug 1998 03:50:26 +0200 (MET DST) From: Sascha Schumann To: Studded cc: William Woods , "freebsd-questions@FreeBSD.ORG" Subject: Re: BASH prompt question In-Reply-To: <35C657D9.4B2577D4@dal.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by hub.freebsd.org id SAA12886 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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... ------------------------------------ INVOCATION A login shell is one whose first character of argument zero is a -, or one started with the --login option. An interactive shell is one whose standard input and out­ put are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state. ... When bash is invoked as an interactive login shell, it first reads and executes commands from the file /etc/pro­ file, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. ... When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc. ... ------------------------ To end this ``discussion'': ~/.bashrc _will be_ sourced automatically by bash, if you... o do a `su [username]' o start a xterm It will _not_be automatically sourced, if you... o do a `su - [username]' o login from console o use sth else to login remotely > > 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 ;) > 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 ;) > Here's some info from misc.c in xterm's source about the escape codes > for the title and icon: > > case 0: /* new icon name and title*/ > case 1: /* new icon name only */ > case 2: /* new title only */ > > 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 :-(( ;) Greetings, Sascha To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message