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

Feature request: it would be nice to have a Znap command to ask if a plugin is cloned #14

Closed
mattmc3 opened this issue Dec 22, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@mattmc3
Copy link
Contributor

mattmc3 commented Dec 22, 2020

Maybe I'm thinking about this wrong and don't know the "znap way" of doing this, but currently I have code like this in my .zshrc:

if [[ ! -d $(znap path)/zsh-autosuggestions ]]; then
    znap clone zsh-users/zsh-autosuggestions
fi
znap source zsh-autosuggestions

It seems like that pattern might be better served with a convenience command within znap. One idea I had was adding an 'exists' subcommand.

if ! znap exists zsh-autosuggestions; then
    znap clone zsh-users/zsh-autosuggestions
fi
znap source zsh-autosuggestions

Another option would be to revamp the znap ls command to not actually ls, but return a list that can be properly stored in a list.

plugins=$(\ls $(znap path))
# or, if ls returned a simple list...
# plugins=$(znap ls)
if ! (($plugins[(Ie)zsh-autosuggestions])); then
    znap clone zsh-users/zsh-autosuggestions
fi
znap source zsh-autosuggestions

And, finally, perhaps an all-in-one-command would be another possibility:

# bundle does a clone if it has to, and sources the plugin
znap bundle zsh-users/zsh-autosuggestions

Is there a canonical znap way to accomplish what I'm doing, or is there a feature we can get added to znap to achieve this better?

@marlonrichert
Copy link
Owner

The canonical "Znap way" of doing this is to znap clone everything once on the command line only. 🙂

Why would you need to check in your .zshrc file whether you have installed a plugin?

@mattmc3
Copy link
Contributor Author

mattmc3 commented Dec 24, 2020

I frequently log into new machines (Raspberry Pis, servers, virtual machines, etc.) and grab my dotfiles via git to setup my ZSH set up the way I prefer. I like having that all happen in one step. I also frequently switch branches in my ZSH config to experiment with new tools, and when I switch back to my main branch I prefer ZSH to self-heal by setting itself back up automatically without extra steps. Nearly every other ZSH plugin manager I've tried in the past (antibody, antigen, zgen, zplug, zinit) has this ability.

marlonrichert added a commit that referenced this issue Dec 25, 2020
You can now pass any of the URL forms that `znap clone` accepts to `znap
prompt` or `znap source`, and they will call `znap clone` with it,
before performing their own functions.

Implements issue #14.
@marlonrichert
Copy link
Owner

marlonrichert commented Dec 25, 2020

All right, it's there now. If you now do znap source zsh-users/zsh-autosuggestions instead of znap source zsh-autosuggestions, it will automatically call znap clone with the same arguments, if there is no zsh-autosuggestions repo yet. This works for znap prompt, too. And you can even pass entire URLs to them, if you want, since those are accepted by znap clone, too.

@novirium
Copy link

Hi, just came across this while giving Znap a go: This feature appears to have been broken in a recent commit - the call to .znap.clone is no longer receiving any arguments, I think $1 is being cleared by the anonymous function added here and here?

marlonrichert added a commit that referenced this issue Jan 11, 2021
Fixes a bug mentioned in issue #14.
@marlonrichert
Copy link
Owner

Whoops! Thanks for reporting. Should be fixed now.

@marlonrichert marlonrichert added the enhancement New feature or request label Feb 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants