From owner-freebsd-questions Thu Aug 13 01:36:21 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA26832 for freebsd-questions-outgoing; Thu, 13 Aug 1998 01:36:21 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from phoenix.welearn.com.au (suebla.lnk.telstra.net [139.130.44.81]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA26811; Thu, 13 Aug 1998 01:36:06 -0700 (PDT) (envelope-from sue@phoenix.welearn.com.au) Received: (from sue@localhost) by phoenix.welearn.com.au (8.8.5/8.8.5) id SAA24328; Thu, 13 Aug 1998 18:34:29 +1000 (EST) Message-ID: <19980813183425.65187@welearn.com.au> Date: Thu, 13 Aug 1998 18:34:25 +1000 From: Sue Blake To: Peihan Wang Cc: freebsd-questions@FreeBSD.ORG, jgrosch@mooseriver.com, mhenry@white.ug.cs.usyd.edu.au Subject: Re: Re: PS1 (command line prompt) in .profile References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.88e In-Reply-To: ; from Peihan Wang on Thu, Aug 13, 1998 at 03:44:46PM +0800 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG [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 , > > // 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 > #include > #include > > 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-questions" in the body of the message