Date: Thu, 13 Aug 1998 15:44:46 +0800 (CST) From: Peihan Wang <peihanw@mx.cei.gov.cn> To: freebsd-newbies@FreeBSD.ORG Cc: jgrosch@mooseriver.com, mhenry@white.ug.cs.usyd.edu.au Subject: RE: Re: PS1 (command line prompt) in .profile Message-ID: <Pine.BSF.3.96.980813152436.462A-100000@wph.bbs.edu.cn>
next in thread | raw e-mail | index | archive | help
>>
>> 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;
}
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?Pine.BSF.3.96.980813152436.462A-100000>
