Created
October 22, 2019 21:56
-
-
Save mattmc3/5ae9d027e02edc8798228ba1acba32ab to your computer and use it in GitHub Desktop.
ZSH - manually manage plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumes github and slash separated plugin names | |
github_plugins=( | |
zsh-users/zsh-autosuggestions | |
zsh-users/zsh-completions | |
zsh-users/zsh-history-substring-search | |
rupa/z | |
# theme | |
miekg/lean | |
# must be last | |
zdharma/fast-syntax-highlighting | |
) | |
for plugin in $github_plugins; do | |
# clone the plugin from github if it doesn't exist | |
if [[ ! -d ${ZDOTDIR:-$HOME}/.zsh_plugins/$plugin ]]; then | |
mkdir -p ${ZDOTDIR:-$HOME}/.zsh_plugins/${plugin%/*} | |
git clone --depth 1 --recursive https://github.com/$plugin.git ${ZDOTDIR:-$HOME}/.zsh_plugins/$plugin | |
fi | |
# load the plugin | |
for initscript in ${plugin#*/}.zsh ${plugin#*/}.plugin.zsh ${plugin#*/}.sh; do | |
if [[ -f ${ZDOTDIR:-$HOME}/.zsh_plugins/$plugin/$initscript ]]; then | |
source ${ZDOTDIR:-$HOME}/.zsh_plugins/$plugin/$initscript | |
break | |
fi | |
done | |
done | |
# clean up | |
unset github_plugins | |
unset plugin | |
unset initscript | |
alias plugpull="find ${ZDOTDIR:-$HOME}/.zsh_plugins -type d -exec test -e '{}/.git' ';' -print0 | xargs -I {} -0 git -C {} pull" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment