Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: separating functions, fpath, and autoload
- X-seq: zsh-users 23571
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Re: separating functions, fpath, and autoload
- Date: Mon, 13 Aug 2018 09:55:06 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=nJ33e03F144qg2LwxB7erMahfJ8r0iyzx+mcXn5BO1A=; b=jLuSGSYH+D0Jl6FEABoq6NfAygKJuXGVAKX4HYI/aOf6dx3olvUBWKOjxORUD2Z4bG V0WsXqZm11nwC5xfcDaruxyHvKZt8vdHmcZU2eDbNyYq7Z1gqFjNY8pHB5U8iUlgosqV 7IiUb08l+c9zXKgJRWx5qSRyiV43lb3jhO3X7oN1xZix1dx1TeEXnXyTfCSOeW1NA4Yg 2+j6kZcmOwsheYTuR8CzkeNLcrvRvo+8LCmyI/juMI+/x17zECqK3Ft1jW6Plq42gNAD jFjNSike++rDF9At5VjxWWvfUfN8qXTNL13RK1W5kpb/Yg49v9Pn54JDI8GCaCA0/5KD EzbA==
- In-reply-to: <CADjGqHu5KYqFWdawfBu6PR5pGyZN_iZSXx690edLO+FtpKfM1A@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHu5KYqFWdawfBu6PR5pGyZN_iZSXx690edLO+FtpKfM1A@mail.gmail.com>
Of course, two minutes after I send my message, I had a thought.
I need to _use_ the 'msg' function before it will be defined. Before that,
it is the regular thing that I showed in my previous example, but once I
_use_ it, then it gets loaded, and is available.
Do I have that right?
So 'autoload' does not mean "load this right now" but rather "be prepared
to load this when it is asked for" ?
Tj
--
TJ Luoma
TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
<http://rhymeswithdiploma.com/>)
Twitter: @tjluoma <http://twitter.com/tjluoma>
On Mon, Aug 13, 2018 at 9:49 AM TJ Luoma <luomat@xxxxxxxxx> wrote:
>
> I'm in the midst of an effort to try to learn some of zsh's more powerful
> features, since I've been using zsh forever and feel like I only use 1% of
> what it can do.
>
> One of the things that I've wanted to do for awhile is separate out some
> of my more complex functions to remove them from my .zshrc file and put
> them into their own files. This should make them easier to track/change/etc
> and it makes things a lot easier to read and debug.
>
> Unfortunately, I can't seem to get it to work right. I'm sure I'm doing
> something wrong because I don't really know what I'm doing, so I'll explain
> what I've tried, and hopefully someone can explain where I've gone wrong.
>
> I added this to my .zshrc
>
> if [ -d "$ZDOTDIR/functions" ]
> then
> fpath=($ZDOTDIR/functions $fpath)
> fi
>
> The goal there was to add '$ZDOTDIR/functions' to the functions list,
> which I think is the right way to do this.
>
> I can verify that works, I think, by using 'echo $fpath':
>
> $ echo $fpath
> /Users/luomat/Dropbox/dotfiles/zsh/completion
> /Users/luomat/Dropbox/dotfiles/zsh/functions
> /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions
> /usr/share/zsh/5.3/functions
>
> /Users/luomat/Dropbox/dotfiles is my $ZDOTDIR
>
> The first file in '/Users/luomat/Dropbox/dotfiles/zsh/functions' is called
> 'msg'. For simplicity's sake, let's assume the contents of 'msg' is simply
> this:
>
> function msg {
>
> echo "$@"
>
> }
>
> (It's actually more complicated than that, but that's the overall idea.)
>
> I tried that, and then I tried
>
> autoload msg
>
> and I didn't get an error, but when I check 'which msg' I get this:
>
> msg () {
> # undefined
> builtin autoload -X
> }
>
> so I've messed up something along the line.
>
> Any help would be appreciated.
>
> Thanks!
>
> Tj
>
>
> --
> TJ Luoma
> TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
> Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
> <http://rhymeswithdiploma.com/>)
> Twitter: @tjluoma <http://twitter.com/tjluoma>
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author