zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: separating functions, fpath, and autoload
Date: Mon, 13 Aug 2018 09:49:02 -0400	[thread overview]
Message-ID: <CADjGqHu5KYqFWdawfBu6PR5pGyZN_iZSXx690edLO+FtpKfM1A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

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>

             reply	other threads:[~2018-08-13 13:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-13 13:49 TJ Luoma [this message]
2018-08-13 13:55 ` TJ Luoma
2018-08-13 13:56 ` Pier Paolo Grassi
2018-08-13 14:31   ` Daniel Shahaf
2018-08-13 15:38     ` ticking clock Ray Andrews
2018-08-13 16:29       ` Vin Shelton
2018-08-13 19:57         ` Ray Andrews
2018-08-13 21:54           ` Bart Schaefer
2018-08-13 22:45             ` Ray Andrews
2018-08-14 17:27               ` Bart Schaefer
2018-08-14 21:21                 ` Ray Andrews
2018-08-14 10:07       ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADjGqHu5KYqFWdawfBu6PR5pGyZN_iZSXx690edLO+FtpKfM1A@mail.gmail.com \
    --to=luomat@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).