1 |
On Thu, 2009-07-23 at 17:28 +0200, Robert Buchholz wrote: |
2 |
> On Thursday 23 July 2009, Sérgio Almeida wrote: |
3 |
> > You changedir, you call uprofile, and |
4 |
> > voila, new profile. You login again, default profile. |
5 |
> |
6 |
> Most shells have the ability to execute a command when a new prompt is |
7 |
> generated. Users do not need to call uprofile themselves, they could |
8 |
> set up their ~/.*shrc to do this. |
9 |
> |
10 |
> For zsh (and tcsh), you can define a function: |
11 |
> chpwd Executed whenever the current working directory is |
12 |
> changed. |
13 |
> precmd Executed before each prompt. Note that precommand |
14 |
> functions are not re-executed simply because the |
15 |
> command line is redrawn, as happens, for example, when |
16 |
> a notification about an exiting job is displayed. |
17 |
> |
18 |
> For bash, you can set a variable: |
19 |
> PROMPT_COMMAND If set, the value is executed as a |
20 |
> command prior to issuing each primary prompt. |
21 |
> |
22 |
> |
23 |
> You could utilize this to call uprofile, have it output environment |
24 |
> variables and set them in the shell environment. A portable (bug ugly, |
25 |
> code wise) way would be to do this as part of the PS1 variable. |
26 |
> |
27 |
|
28 |
This seems interesting... The problem would be to get a unified way of |
29 |
doing this with each and every shell. Can still be done but it's ugly. |
30 |
|
31 |
I'm shure we wouldn't want it to run on every PROMPT but surely on every |
32 |
chdir. We can wrap this into a PROMTP precmd... |
33 |
|
34 |
if cmd = 'chdir': |
35 |
uprofile |
36 |
|
37 |
This gets me into coding... |
38 |
|
39 |
What do you guys think? |
40 |
|
41 |
Cheers, |
42 |
Sérgio |
43 |
-- |
44 |
Sérgio Almeida - mephx.x@×××××.com |
45 |
mephx @ freenode |