zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.89k stars 124 forks source link

feat: Add %SYMBOL% substituting to non-clone time ices like atinit'', atload'', etc. #450

Open psprint opened 1 year ago

psprint commented 1 year ago

Description

There are many such symbol var-like symbols:

With this patch many has been fixed (like %ID%, %USER%, %PLUGIN% were returning empty strings, possibly breaking packages, where this undocumented feature is used) and support for load-time ices (like atload'', etc.) have been added.

Motivation and Context

I wanted to make %SYM% more widely used, it might yield interesting use cases. Maybe some new vars can be added? README is updated to mntion the feature.

Related Issue(s)

Usage examples

For example:

zinit id-as'plugin-%UID%' atload'print Loaded from dir: %DIR%, plugin id: %ID%' for zd

output is:

Loaded from dir: /home/q/.local/share/zinit/plugins/plugin-500, plugin id: plugin-500

How Has This Been Tested?

Types of changes

Checklist:

vladdoster commented 1 year ago

@psprint The commit fails on the linter

https://github.com/zdharma-continuum/zinit/actions/runs/3802251129/jobs/6467549407#step:6:10

psprint commented 1 year ago

It should now pass the linter.

vladdoster commented 1 year ago

The commit message should be all lowercase.

psprint commented 1 year ago

The commit message should be all lowercase.

@vladdoster: fixed

psprint commented 1 year ago

@vladdoster I don't know why README.md isn't formatted, could you help?

vladdoster commented 1 year ago

@psprint,

What is an actual use case for this?

psprint commented 1 year ago

It's an ability to include special var-like strings like '%USER%' or '%PLUGIN%' etc. In atload'',atinit'', etc. ices and not only in atclone'' etc. ices

sob., 29 kwi 2023, 06:26 użytkownik vladislav doster < @.***> napisał:

@psprint https://github.com/psprint,

What is an actual use case for this?

— Reply to this email directly, view it on GitHub https://github.com/zdharma-continuum/zinit/pull/450#issuecomment-1528647502, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOE4CGI6TNMNH4MXX436MDXDSKA5ANCNFSM6AAAAAATMI77DU . You are receiving this because you were mentioned.Message ID: @.***>

psprint commented 1 year ago

@vladdoster Oh, I see that I've already described the feature in PR message. As for the use case, it's: e.g.: ability to just write my-%PLUGIN% in id-as'' ice to obtain e.g.: my-dstask, i.e.:

zinit id-as'my-%PLUGIN%' from"gh-r" sbin'*->dstask' bpick'^*import*' \
        for @naggie/dstask

I think that such special vars are useful and needed from the point of view of versatility, to provide a complete support of the intentions of users (one could want such automatic plugin-name reference, for example).

psprint commented 1 year ago

@vladdoster: I've fixed the markdown in README.md (was exceeding 120 chars line lenght)

psprint commented 1 year ago

@vladdoste: Eh, mdformat is stil failing, I think that I'll give up, as I've run it without --check and then committed the result… Could you look?