zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.74k stars 122 forks source link

feat: feature – support miligrams – appimage compressed plugins #554

Closed psprint closed 5 months ago

psprint commented 11 months ago

Description

This is the first commit that introduces the miligrams support via new, embedded (shipped and loaded by default) mg annex. In this commit what's implemented is:

What's left is only allowing download of the miligrams from the GitHub Releases page. The planned syntax for this is: zi mg"user/repo" for my-plugin, that would look into the binary files and look up the most recent version of my-plugin.mg, like e.g.: my-plugin-v1.7.mg. The code already looks up the most recent version of the package, so zi for my-plugin.mg will load my-plugin-1.7.mg if it's the most recent version.

Related Issue(s)

553

Motivation and Context

I think that to have the plugins like eggs in python is a good update on the plugins in Zsh world. We can exploit the already existing, well spread and supported AppImages' features, like:

…to provide an egg like solution to Zsh.

I've implemented the feature as annex that's shipped with zinit. It's located in zinit.git/lib/annex/mg and is automatically loaded at end of zinit.zsh. It is a before-load hook, like unscope annex.

Usage examples

# Download an appimage directly, as the `zi mg"psprint/n-commodoer" for N-Commodore` syntax isn't yet implmented

wget \
     https://github.com/psprint/n-commodore/releases/download/nc-1.41/N-Commodore-1.41-x86_64.AppImage \
    -O $ZINIT[PLUGINS_DIR]/n-commodore-v1.41.mg

# load the plugin
zi keep mg for n-commodore

# use its `nc` provided command:
nc

How Has This Been Tested?

By interactive use.

Types of changes

Checklist:

psprint commented 11 months ago

@vladdoster @pschmitt @alichtman: ping. What's your opinion on this egg-like extension? Will it have any chance of merging?

psprint commented 11 months ago

feat: support downlaoding of miligrams

The syntax for downloading miligram is:

    zi mg"user/repo" for {FILE-NAME-ROOT}

For example, to load the n-commodore plugin that's currently shipped as miligram, one would do:

    zi mg"psprint/n-commodore" keep for N-Commodore

The output of this command is:

==> (Requesting `N-Commodore-v1.47.mg', version: nc-1.44…)
Hi! …/tmp/.mount_N-CommLbx7te/n-commodore.plugin.zsh…

The "Hi…" message comes from the plugin.zsh file of the plugin.

One can also use "debug" ice, the output will then be:

==> (Requesting `N-Commodore-v1.47.mg', version: nc-1.44…)
==> mg annex: args: N-Commodore
mg annex: Matched miligram to dir: /tmp/.mount_N-CommrJE53I
Hi! …/tmp/.mount_N-CommLbx7te/n-commodore.plugin.zsh…

What's currently left TODO is zi update support.

@vladdoster @pschmitt @alichtman: I hope that you get from vacation soon :smile: