On Thu, 2009-07-23 at 17:28 +0200, Robert Buchholz wrote:
> 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.
>
This seems interesting... The problem would be to get a unified way of
doing this with each and every shell. Can still be done but it's ugly.
I'm shure we wouldn't want it to run on every PROMPT but surely on every
chdir. We can wrap this into a PROMTP precmd...
if cmd = 'chdir':
uprofile
This gets me into coding...
What do you guys think?
Cheers,
Sérgio
--
Sérgio Almeida - mephx.x@...
mephx @ freenode
|