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