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

Documentation Idea #2

Closed
black7375 opened this issue Mar 9, 2021 · 3 comments
Closed

Documentation Idea #2

black7375 opened this issue Mar 9, 2021 · 3 comments

Comments

@black7375
Copy link

Zinit Wiki

I think this is useful and worth mentioning in the official document.

Before/After
It's intuitive what kind of situation you need.

Null Plugin Eval
It is good to have an example when caching non-plugin things. (like with id-as)

@NICHOLAS85
Copy link
Owner

Sure I could improve the documentation to include some Before/After invocations and Null Plugin examples. Feel free to share some examples here and I'll look into including them.

@black7375
Copy link
Author

black7375 commented Mar 9, 2021

Before/After

  • Simple
    zoxide is a good example.
    It is simple and because README states to use eval.
## Before
zinit ice as"command" from"gh-r" mv"zoxide* -> zoxide"  \
      atclone"./zoxide init zsh > init.zsh"  atpull"%atclone" src"init.zsh" nocompile'!'
zinit light ajeetdsouza/zoxide

## After
zinit ice as"command" from"gh-r" mv"zoxide* -> zoxide" \
      eval"./zoxide init zsh"
zinit light ajeetdsouza/zoxide```
  • Others
    It's a bit more complicated case.
## Before
# trapd00r/LSCOLORS: https://zdharma.org/zinit/wiki/LS_COLORS-explanation/
zinit ice atclone"dircolors -b LS_COLORS > init.zsh" \
      atpull"%atclone" pick"init.zsh" nocompile'!' \
      atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”'
zinit light trapd00r/LS_COLORS

# dbrgn/tealdeer
_tldr-setting() {
    tldr --update
    local comp="$(tldr 2>/dev/null --list)"
    echo "complete -W \"$comp\" tldr" > init.zsh
}
zinit ice as"command" from"gh-r" \
      mv"tldr* -> tldr" atclone"_tldr-setting" atpull"%atclone" pick"init.zsh"
zinit light dbrgn/tealdeer


## After
# trapd00r/LSCOLORS
zinit ice wait"2" eval"dircolors -b LS_COLORS" \
      atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”'
zinit light trapd00r/LS_COLORS

# dbrgn/tealdeer
zinit ice wait"2" as"command" from"gh-r" \
      mv"tldr* -> tldr" atclone"./tldr --update" atpull"%atclone" \
      eval'echo "complete -W \"$(./tldr 2>/dev/null --list)\" tldr"'
zinit light dbrgn/tealdeer

Null Plugin Eval
You can use it to cache eval results.
Use with a id-as.

## Before
# thefuck -- simple example
eval $(thefuck --alias)

# kubectl -- complex example
if [[ "${+commands[kubectl]}" == 1 ]]; then
    eval $(kubectl completion zsh)
fi

## After
# thefuck
zinit ice id-as"thefuck_alias" eval"thefuck --alias"
zinit light zdharma/null

# kubectl
zinit ice id-as"kubectl_completion" has"kubectl" \
      eval"kubectl completion zsh"
zinit light zdharma/null

Will this be enough?
If README becomes complicated, it is also good to link this issue.

@NICHOLAS85
Copy link
Owner

Alright included some examples and linked this issue as a reference for more!

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

No branches or pull requests

2 participants