On Thursday 23 July 2009, Sérgio Almeida wrote:
> You changedir, you call uprofile, and
> voila, new profile. You login again, default profile.
Most shells have the ability to execute a command when a new prompt is
generated. Users do not need to call uprofile themselves, they could
set up their ~/.*shrc to do this.
For zsh (and tcsh), you can define a function:
chpwd Executed whenever the current working directory is
changed.
precmd Executed before each prompt. Note that precommand
functions are not re-executed simply because the
command line is redrawn, as happens, for example, when
a notification about an exiting job is displayed.
For bash, you can set a variable:
PROMPT_COMMAND If set, the value is executed as a
command prior to issuing each primary prompt.
You could utilize this to call uprofile, have it output environment
variables and set them in the shell environment. A portable (bug ugly,
code wise) way would be to do this as part of the PS1 variable.
Robert
|