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

Re: Feature suggestion for autoload



On 2008-07-17 at 01:44 +0200, Richard Hartmann wrote:
> What I meant was 'autoload every file you find in fpath'. That suggestion
> is moot now, though.

While it may be moot, this might be helpful anyway.

You might want to look at the demonstration start-up files supplied with
zsh.  StartupFiles/ sub-directory of the source, no idea what any given
distribution does with them.

The provided example to do just this is:
----------------------------8< cut here >8------------------------------
# Autoload all shell functions from all directories in $fpath (following
# symlinks) that have the executable bit on (the executable bit is not
# necessary, but gives you an easy way to stop the autoloading of a
# particular shell function). $fpath should not be empty for this to work.
for func in $^fpath/*(N-.x:t); autoload $func
----------------------------8< cut here >8------------------------------

My preferred OS (FreeBSD) happens to not preserve executability on the
zsh-supplied files for the Port, so I end up with:

 autoload ${^fpath}/*(N-.:t)
 typeset -U fpath
 fpath=(~/bin/zsh-funcs $fpath)
 set -A _foo ~/bin/zsh-funcs/*(N-.x:t)
 [[ ${#_foo} -gt 0 ]] && autoload $_foo
 unset _foo

Just two examples.

-Phil



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