romkatv / zsh-bench

Benchmark for interactive Zsh
MIT License
592 stars 27 forks source link

.Zshrc diy++ fsyh #15

Closed JustCauseWhyNot closed 2 years ago

JustCauseWhyNot commented 2 years ago

I apologize if this isn't the right format, or location to ask this question. How would one right there diy plugin manger .zshrc so that it keeps plugins updated? Would you have to write it so every time .zshrc ran it would have to clone the plugins repo?

romkatv commented 2 years ago

You'll need to write a script to update plugins. If you keep all your plugins under ~/.zsh (so you'll have ~/.zsh/powerlevel10k and so on), the script can look like this:

#!/usr/bin/env zsh
#
# Usage: zsh-update
#
# Updates all plugins under ~/.zsh.
#
# It's recommended to restart zsh with `exec zsh` after running `zsh-update`.

() {
  local dir
  for dir in ~/.zsh/*(/); do
    git -C $dir pull
  done
} "$@"

Save it in zsh-update, make the file executable and place it somewhere in your PATH (I would use ~/bin).

Note: I haven't tested the script. If it doesn't work, please fix it yourself.

romkatv commented 2 years ago

Oh, you want it for a zshrc that compiles sources, right? If so, the easiest way would be to delete the directories and restart zsh with exec zsh. If you keep all plugins under ~/.zsh, that would be as simple as rm -rf ~/.zsh && exec zsh

JustCauseWhyNot commented 2 years ago

Thank you for your assistance.