[comp.unix.wizards] pwd in your PS1

AGRISCS@umcvmb.missouri.edu (Don Ingli) (12/29/89)

I have developed a method to put your pwd into your ps1.

The way I do it is to create a shell function in my .profile and then have
it run a program called chd .

place this in your .profile

chd() {
  . chd
}
PS1="$LOGNAME:`pwd`> "
export PS1


this creates a function chd that will run a script called chd and affect
the current environment....

now create this shell script: and name it chd

cd $*
PS1="$LOGNAME:`pwd`> "
export PS1


remember to place it in a subdirectory that is in your $PATH var.
Also, make sure you have executable permissions  chmod 700 chd  :-)

HINT: If you have a nosey co-worker/friend use chd to display a path
and then use cd to go where you want... cd wont change your prompt.
ex:
chd project
don:/usr8/don/project> cd /usr/games

your prompt will show you that you are in subdir project but actually
be in the games directory!!

Also...  chd with no args will take you to your HOME directory since it
calls cd...


Hope this helps...


 DON INGLI------------------------------------------------------------+
 UNITED STATES DEPARTMENT OF AGRICULTURE - SOIL CONSERVATION SERVICE  |
 bitnet: agriscs@umcvmb.bitnet  internet: agriscs@umcvmb.missouri.edu |
 attmail: attmail!attbl!arpa!umcvmb.missouri.edu!agriscs              |
 ALL OPINIONS IN THIS NOTE ARE OF MY OWN AND DO NOT REPRESENT THE     |
 FEDERAL GOVERNMENT OR THE UNIVERSITY OF MISSOURI-COLUMBIA -----------+

satam@ecs.umass.edu (Kirtikumar Satam) (12/29/89)

Inserting the following three aliases will help achieve the same
effect. Note that this is only for csh.
This part of code was once posted by someone in comp.unix.questions.

Also, if you want full path to be displyed, then change {cwd:t} to {cwd}.
The "\\!%" at the end is used to indicate the history command number.
cwd= predefined shell variable which gets set to the Current Working
Directory.

------------------------------------------------------------
alias cd 'chdir \!* && set prompt="${cwd:t}_\\!% "'
alias pushd 'pushd \!* && set prompt="${cwd:t}_\\!% "'
alias popd 'popd \!* && set prompt="${cwd:t}_\\!% "'
-------------------------------------------------------------

Hope this helps.
Thanks.
-satam
------------------------------------------------------------------------
Kirtikumar "Mumbaichaa" Satam
INTERNET : satam@ecs.umass.edu
BITNET : satam@umaecs.bitnet
217 Northwood Apts, Sunderland, MA 01375   Tel# 413-665-3222
------------------------------------------------------------------------