jandamm/zgenom

Add autoupdate functionality

unixorn opened this issue · 6 comments

Moving this to a new issue.

I like the idea of having the autoupdate being part of core, defaulting to off. I also like the idea of moving things into a bindir and having the things in there not even get sourced unless ZGENOM_LOAD_XYZ is set to minimize startup impact.

I don't really know how autoload functions work all that well, that might be enough of a performance saver to go with that over not sourcing unused functionality.

Conceptually they're like bins (one file is one function) and they're only retrieved when used.
But instead of calling them directly they have to be registered first. Which creates kind of a shim. Not sure about the penalty of running the autoload but this could also be delayed by only autoloading when the user is initializing full zgenom (zgen.zsh) or even at a later point in time or via a ZGENOM_LOAD_XYZ.

The issue with bins is that they cannot mutate the current shell (which zgenom load and others do).

What do you think about integrating it as zgenom autoupdate?

The init file would then look like this:

source .../zgenom.zsh

zgenom autoupdate 

if ! zgenom saved; then
    zgenom load ...
fi

This would also allow to remove the checks for $ZGEN_DIR et al.

Have it as zgenom autoupdate, and have that only source the code and do anything when ZGENOM_AUTOUPDATE_DAYS is set and non-zero?

No, if you don't have anything set, I'd still assume 7 days.

Anyone who doesn't want to use autoupdate in their config shouldn't call it.

source .../zgenom.zsh

if ! zgenom saved; then
    zgenom load ...
fi

That sounds better. I'll code something up in the next couple of days.

Just a heads up - I'm on call this week, it doesn't look like I'm going to get to work on this till the weekend, or maybe Monday.