Setting a part of a PWD as a prompt and keeping a variable updated

Viewed 1881

I'm using tcsh, and I'm trying to set a part of the PWD to appear always in the prompt (so I will always know in which "parent" directory I am).

I managed to extract the needed part of the prompt in the following way, and it works fine (I call it MyTreePath):

set MyTreePath=`echo $PWD | awk '{... print whichTree}'`

I've added the code above to my .tcshrc and I've added %$MyTreePath to my set prompt line in .tcshrc.

The problem is that once the shell is opened, the MyTreePath doesn't change, even if I'm going to a totally different path.

How to keep a variable that appears in the prompt updated?

1 Answers
Related