Date: Thu, 13 Aug 1998 18:34:25 +1000 From: Sue Blake <sue@welearn.com.au> To: Peihan Wang <peihanw@mx.cei.gov.cn> Cc: freebsd-questions@FreeBSD.ORG, jgrosch@mooseriver.com, mhenry@white.ug.cs.usyd.edu.au Subject: Re: Re: PS1 (command line prompt) in .profile Message-ID: <19980813183425.65187@welearn.com.au> In-Reply-To: <Pine.BSF.3.96.980813152436.462A-100000@wph.bbs.edu.cn>; from Peihan Wang on Thu, Aug 13, 1998 at 03:44:46PM %2B0800 References: <Pine.BSF.3.96.980813152436.462A-100000@wph.bbs.edu.cn>
next in thread | previous in thread | raw e-mail | index | archive | help
[moved to freebsd-questions where it should have started]
On Thu, Aug 13, 1998 at 03:44:46PM +0800, Peihan Wang wrote:
> >>
> >> Hello , gurus !
> >>
> >> I am using bash (version: 2.01) on my 2.2.6 box.
> >> I put the following line in my .profile:
> >>
> >> PS1='`pwd`$ '
> >>
> >> It works well in console mode, But after I start X
> >> it does not take any effect in xterm. By the way,
> >> I am using lesstif as my window manager. I do not
> >> know what to do :-(
> >>
> --------------------------- Josef's Answer --------------------
> >
> >Read your man page. Bash uses 2 init file, .bashrc and .bash_profile.
> >.bash_profile gets run when you first login. .bashrc get run for each
> >term that your account/process create. So in your .bash_profile you
> >would have the line
> >
> > export PS1='`pwd`$ '
> >
> >That should do it
> >
> -------------------------- Henry's Answer --------------------
> >
> >You need to give the -ls argument to xterm:
> >
> >xterm -ls
> >
> >This indicates that the shell in the xterm is a login shell,
> >and thus it will read your .profile.
> >
> ################################################################
>
> Thank you very much !
>
> I write the following trinket as a gift to all FreeBSD users.
> It is very primitive and everyone can modify it for his/her
> own purpose.
>
>
> // file name : my-path-prompt.cc
> // last update : Aug/13/1998
> // author : Peihan Wang <peihanw@usa.net> , <peihanw@mx.cei.gov.cn>
>
> // This program is derived from pwd.
> // Sometimes when you set PS1='`pwd`$ ' in your .profile or .bashrc,
> // it is very annoying that while you were doing something
> // in a relatively deep directory the PATH prompt is so long
> // that cause your eyes dizzy.
>
> // So, compile this program and put it in ~/bin/ and modify your
> // profile. (PS1='`my-path-prompt`$ ')
>
> // You can modify the two consts as you wish
> // or you can add command line args to make it flexible.
>
> #include <iostream.h>
> #include <unistd.h>
> #include <string.h>
>
> const int PROMPT_MAX_LENTH = 25;
> const char * ADD_ON_STRING = "..|";
>
> main ()
> {
> char * current_path = NULL;
> char * p = NULL;
>
> if ((p = getcwd(NULL, 0)) == NULL) {
> cerr << "getcwd() error\n";
> exit(-1);
> }
>
> int path_lenth = strlen(p);
> int add_on_lenth = strlen(ADD_ON_STRING);
> char * trimed_path = NULL;
>
> current_path = new char [path_lenth + 1];
> strcpy(current_path, p);
> if (path_lenth <= PROMPT_MAX_LENTH) {
> cout << current_path;
> }
> else {
> trimed_path = new char [PROMPT_MAX_LENTH + 1];
> strcpy(trimed_path, ADD_ON_STRING);
> char * pp = current_path;
> for (int i = 0;
> i < (path_lenth - PROMPT_MAX_LENTH + add_on_lenth);
> i++) {
> pp ++;
> }
> strcat(trimed_path, pp);
> cout << trimed_path;
> delete trimed_path;
> }
> delete current_path;
> return 0;
> }
>
I don't speak C, and I don't understand why I would want a program to
do what .bashrc does. Is this better?
--
Regards,
-*Sue*-
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-newbies" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980813183425.65187>
