Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bourne shell .profile $PWD 1

Status
Not open for further replies.

s2budd

Technical User
May 15, 2001
30
GB
Within the .profile file
I know that the $PWD does not work within the bourne shell -only the korn shell.

The below command with korn shell works for including
the current directory within the prompt - but is there any way of acheiving this within the bourne shell ?

export PS1=`print $USER | cut -f3 -d/`':$PWD > '


Many thanks for any help
Stuart
 
Stuart,

I'm not 100% sure if this works.
Just try.

CD1(){
x=$1
cd $x
PS1=$(basename $(dirname $PWD))/$(basename $PWD)
if [ -d /$PS1 ] ;then
PS1=$PWD
else
PS1=.../$PS1
fi
PS1="[$(hostname):$PS1]# "
}
alias cd='CD1'

Regards Gregor Gregor.Weertman@mailcity.com
 
Gregor

That's fantastic.
It works a treat - many thanks
Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top