Quote:> When I posted the following message, everyone who has responded to me,
> seems to be a bit confused. What the following script (embedded in
> .cshrc) will do in csh is that whenever you change directory using cd
> command, it will display the login user name and the changed directory.
> For example, if you are a root and in /bin, you will get a prompt of
> "root/bin# '. If you change directory to /usr/src by 'cd /usr/src'
> command, your next prompt will become "root/usr/src# '. It's useful
> because you always know who you are and where you are.
Most responses I've seen offered working solutions to exactly that.
Perhaps you should've read them more carefully. E.g.,
PS1='$LOGNAME$PWD# '
will achieve exactly the effect you describe in ksh: PWD is automatically
updated and the variables are re-evaluated every time the prompt is
displayed. (Make sure you use single quotes or it won't work.)
Did you try it? Why isn't it adequate for your needs?
Quote:> I only have O's csh manual and am waiting for the O's ksh manual. I need
> to reprogram pdksh so that I can add some diagnostics command (It's
> critical that this new command will not cause any filesystem access.). I
> suppose that the same capability with ksh might be a bit more difficult
> because ksh doesn't seem to have an embedded 'chdir' command.
What do you mean by "embedded 'chdir'"? Ksh certainly has built-in 'cd' --
indeed, it's hard to imagine a shell without it.
But if your point was that you want cd to do other things besides
changing the prompt, that's been answered, too: define a function
and alias it to cd:
mycd()
{
cd $*
whatever_strange_things_I_want
Quote:}
alias cd=mycd
If you want something to be done whenever the prompt is redisplayed,
whether or not cd was used, use trap DEBUG, possibly again with a function
(as has also been suggested):
trap my_prompter_function DEBUG
If your problem is avoiding file system access, these shouldn't
cause any unless your functions do, besides possibly updating the
history file: that can be avoided by unsetting the HISTFILE variable.
If still can't make it work the way you want, please explain exactly
what you tried, what happened and what you would've wanted to happen.
--
Tapani Tarvainen