From cb98b2eab46421ed0d7bd341f3d3b17fc550bdd1 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Fri, 26 Jul 2024 14:44:55 +0200 Subject: [PATCH] fix(zsh): update plugin handling --- .gitignore | 1 + .zshrc | 37 ++++++++++++++++++++++++++++--------- bootstrap.sh | 2 -- 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16d3c4d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.cache diff --git a/.zshrc b/.zshrc index abc9380..eb1766d 100644 --- a/.zshrc +++ b/.zshrc @@ -1,3 +1,6 @@ + +_here="$(dirname -- "$(readlink -f -- "${HOME}/.zshrc")")" + ########### # Options # ########### @@ -12,8 +15,8 @@ setopt INTERACTIVECOMMENTS ################### # Ref: https://zsh.sourceforge.io/Doc/Release/Parameters.html -path+=("${HOME}/.local/bin") -fpath+=("${HOME}/.zsh_functions") +path=("${HOME}/.local/bin" "${path[@]}") +fpath=("${_here}/.zsh_functions" "${fpath[@]}") export PATH export MAIL="/var/spool/mail/$USER" export MAILCHECK=60 @@ -100,14 +103,31 @@ fi # Plugins # ########### -# Bootstrap -if [[ ! -d ~/.antidote ]]; then - git clone --depth=1 https://github.com/mattmc3/antidote.git ~/.antidote +if [[ ! -d "${_here}/.cache" ]]; then + mkdir "${_here}/.cache" fi -# Plugins are declared in ~/.zsh_plugins.txt -source ~/.antidote/antidote.zsh -antidote load +_antidote="${_here}/.cache/.antidote" +_plugins="${_here}/.zsh_plugins.txt" +_plugins_cache="${_here}/.cache/.zsh_plugins.zsh" + +if [[ ! -d "$_antidote" ]]; then + git clone --depth=1 https://github.com/mattmc3/antidote.git "$_antidote" +fi + +if [[ ! -f "${_plugins}" ]]; then + touch "${_plugins}" +fi + +fpath=("${_antidote}/functions" "${fpath[@]}") +autoload -Uz antidote + +if [[ ! "${_plugins_cache}" -nt "${_plugins}" ]]; then + antidote bundle <"${_plugins}" >"${_plugins_cache}" +fi + +# shellcheck source=.cache/.zsh_plugins.zsh +source "${_plugins_cache}" ############# # Functions # @@ -174,7 +194,6 @@ alias ssh='ssh_with_title' ########## # Prompt # ########## -# eval "$(starship init zsh)" autoload -Uz promptinit promptinit diff --git a/bootstrap.sh b/bootstrap.sh index 1fc1f18..9e8758c 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -40,8 +40,6 @@ SYMLINKS=( ".xinitrc" ".xinit-scripts" ".zshrc" - ".zsh_functions" - ".zsh_plugins.txt" ".p10k.zsh" ".gtkrc-2.0" ".config/tmux"