Zsh Mailing List Archive
Messages sorted by:
Fwd: Re: Loading functions
- X-seq: zsh-users 17021
- From: Paul Hoffman <nkuitse@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Fwd: Re: Loading functions
- Date: Thu, 19 Apr 2012 19:33:03 -0400
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
[Sorry for the duplicate, Mark; I accidentally replied to you privately
and not to the list.]
On Thu, Apr 19, 2012 at 11:03:11PM +0000, Mark wrote:
> Hello again fellow zshians,
> For a particular git repository I created some helper functions.
> Usually I cd to the gitroot and then I load these functions (and env
> variables) by sourcing './zsh.env.'
> Often I forget to source the file and I also just dislike to source it
> manually. I probably got irritated by this irritating pattern of first
> forgetting to source the file, then forgetting to preface it with it's
> path by typing ". zsh.env" and only then getting it right by typing
> ". ./zsh.env".
> After being properly annoyed in today's fourth or fifth terminal screen
> i started to search for alternative ways. At first I thought I could
> execute some script instead of sourcing it. But I couldn't find ways in
> which my shell would remember specified functions after the script had
> been executed. Is this even possible?
> 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?
I just started doing this sort of thing recently. Here's a snippet from
if [[ -x .autodir/exit ]]; then
print -- '(-autodir)' >&2
builtin cd $@ || return $?
if [[ -x .autodir/enter ]]; then
print -- '(+autodir)' >&2
Paul Hoffman <nkuitse@xxxxxxxxxxx>
Messages sorted by: