Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

psprint
Copy link
Contributor

@psprint psprint commented Dec 29, 2022

Description

There are many such symbol var-like symbols:

  • %ID% – id-as ice
  • %USER% – username (in user/plugin ID)
  • %PLUGIN% – plugin name (in user/plugin ID)
  • %URL% – snippet url
  • %DIR% – plugin directory path
  • %ZPFX% – value of $ZPFX
  • %OS% – $OSTYPE
  • %MACH% – $MACHTYPE
  • %CPU% – $CPUTYPE
  • %VENDOR% – $VENDOR
  • %HOST% – $HOST
  • %UID% – $UID (numerical user id)
  • %GID% – $GID (group #)

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@vladdoster
Copy link
Member

@psprint
Copy link
Contributor Author

psprint commented Feb 15, 2023

It should now pass the linter.

@vladdoster
Copy link
Member

The commit message should be all lowercase.

@psprint
Copy link
Contributor Author

psprint commented Feb 16, 2023

The commit message should be all lowercase.

@vladdoster: fixed

@psprint
Copy link
Contributor Author

psprint commented Feb 16, 2023

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

@vladdoster
Copy link
Member

@psprint,

What is an actual use case for this?

@psprint
Copy link
Contributor Author

psprint commented Apr 29, 2023 via email

@psprint
Copy link
Contributor Author

psprint commented Apr 29, 2023

@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 psprint force-pushed the substitute-atload branch 2 times, most recently from 20cc9a5 to d65c35a Compare April 29, 2023 19:37
@psprint
Copy link
Contributor Author

psprint commented Apr 29, 2023

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

There are many such symbol var-like symbols:

- %ID%          – id-as ice
- %USER%        – username (in user/plugin ID)
- %PLUGIN%      – plugin name (in user/plugin ID)
- %URL%         – snippet url
- %DIR%         – plugin directory path
- %ZPFX%        – value of $ZPFX
- %OS%          – `$OSTYPE`
- %MACH%        – `$MACHTYPE`
- %CPU%         – `$CPUTYPE`
- %VENDOR%      – `$VENDOR`
- %HOST%        – `$HOST`
- %UID%         – `$UID` (numerical user id)
- %GID%         – `$GID` (group #)

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.

For example:

```zsh
zinit id-as'plugin-%UID%' atload'print Loaded from dir: %DIR%, plugin id: %ID%' for zdharma-continuum/null
```

output is:

```
Loaded from dir: /home/q/.local/share/zinit/plugins/plugin-500, plugin id: plugin-500
```
@psprint
Copy link
Contributor Author

psprint commented Apr 29, 2023

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants