Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Loading functions

On Thu, 19 Apr 2012, Mark wrote:

> Then I realised that ideally my shell would "do something" (e.g.
> automatically load functions, set env vars) when I go into a directory
> or any subdirectory and "undo" it (unload these functions, unset the
> variables) upon leaving the directory. Which ultimately leads to my next
> question: can zsh be instructed to have a particular environment that is
> local to certain directories?

You will have to insert code into the 'hook-function 'chpwd' for
example by creating a directory of 'environments' like '~/.vim/direnv.d/*'
and put 'setters' and 'unsetters' into files with some naming scheme,
and let 'chpwd' source those files according to some schema (tests
regexps on name, etc.).  This might be realy useful I think...



Christoph von Stuckrad      * * |nickname |Mail <stucki@xxxxxxxxxxxxxxx> \
Freie Universitaet Berlin   |/_*|'stucki' |Tel(Mo.,Mi.):+49 30 838-75 459|
Mathematik & Informatik EDV |\ *|if online|  (Di,Do,Fr):+49 30 77 39 6600|
Takustr. 9 / 14195 Berlin   * * |on IRCnet|Fax(home):   +49 30 77 39 6601/

Messages sorted by: Reverse Date, Date, Thread, Author