dev: automated commit - 2025-09-05 14:49:59
This commit is contained in:
parent
6018f7b0dc
commit
c84dfa059e
9 changed files with 555 additions and 251 deletions
|
|
@ -1,14 +1,7 @@
|
|||
PLUGIN_DIR="$HOME/.local/share/zsh/plugins"
|
||||
PLUGIN_LOCK="$PLUGIN_DIR/.plugins.lock"
|
||||
[ -d "$PLUGIN_DIR" ] || mkdir -p "$PLUGIN_DIR"
|
||||
mkdir -p "$PLUGIN_DIR"
|
||||
|
||||
# Reinstall function
|
||||
update-plugins() {
|
||||
rm -fr "$PLUGIN_DIR"
|
||||
echo "Plugin lock removed. Restart your shell to reinstall plugins."
|
||||
}
|
||||
|
||||
# Define plugins: "github_repo name"
|
||||
# Install plugins (only if missing)
|
||||
plugins=(
|
||||
"romkatv/zsh-defer"
|
||||
"zsh-users/zsh-autosuggestions"
|
||||
|
|
@ -21,28 +14,64 @@ plugins=(
|
|||
"zsh-users/zsh-syntax-highlighting"
|
||||
)
|
||||
|
||||
# Only install plugins if lock file doesn't exist
|
||||
if [ ! -f "$PLUGIN_LOCK" ]; then
|
||||
# Plugin management function
|
||||
zap() {
|
||||
echo "⚡ Updating plugins..."
|
||||
|
||||
# Update plugins sequentially (clean output)
|
||||
for plugin in "${plugins[@]}"; do
|
||||
plugin_name=${plugin##*/}
|
||||
|
||||
if [ ! -d "$PLUGIN_DIR/$plugin_name" ]; then
|
||||
echo "Installing $plugin_name"
|
||||
git clone --quiet "https://github.com/$plugin" "$PLUGIN_DIR/$plugin_name" --depth=1
|
||||
else
|
||||
old_hash=$(git -C "$PLUGIN_DIR/$plugin_name" rev-parse HEAD 2>/dev/null)
|
||||
|
||||
git -C "$PLUGIN_DIR/$plugin_name" fetch --quiet
|
||||
git -C "$PLUGIN_DIR/$plugin_name" reset --hard origin/HEAD --quiet
|
||||
|
||||
new_hash=$(git -C "$PLUGIN_DIR/$plugin_name" rev-parse HEAD 2>/dev/null)
|
||||
|
||||
if [ "$old_hash" = "$new_hash" ]; then
|
||||
echo "✓ $plugin_name (up to date)"
|
||||
else
|
||||
echo "↑ $plugin_name (${old_hash:0:7} → ${new_hash:0:7})"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
date > "$PLUGIN_LOCK"
|
||||
fi
|
||||
|
||||
for dir in "$PLUGIN_DIR"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
plugin_name=$(basename "$dir")
|
||||
if [[ ! " ${plugins[@]##*/} " =~ " $plugin_name " ]]; then
|
||||
echo "Removing unused plugin: $plugin_name"
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Plugin update complete!"
|
||||
}
|
||||
|
||||
for plugin in "${plugins[@]}"; do
|
||||
plugin_name=${plugin##*/}
|
||||
[ -d "$PLUGIN_DIR/$plugin_name" ] || git clone --quiet "https://github.com/$plugin" "$PLUGIN_DIR/$plugin_name" --depth=1
|
||||
done
|
||||
|
||||
# Source plugins
|
||||
source "$PLUGIN_DIR/zsh-defer/zsh-defer.plugin.zsh"
|
||||
source "$PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||
source "$PLUGIN_DIR/zsh-autopair/autopair.zsh"
|
||||
source "$PLUGIN_DIR/zsh-history-substring-search/zsh-history-substring-search.zsh"
|
||||
source "$PLUGIN_DIR/fzf-tab/fzf-tab.plugin.zsh"
|
||||
source "$PLUGIN_DIR/fzf/shell/completion.zsh"
|
||||
source "$PLUGIN_DIR/fzf/shell/key-bindings.zsh"
|
||||
|
||||
# Defer heavy plugins for faster startup
|
||||
zsh-defer source "$PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||
zsh-defer source "$PLUGIN_DIR/zsh-autopair/autopair.zsh"
|
||||
zsh-defer source "$PLUGIN_DIR/zsh-history-substring-search/zsh-history-substring-search.zsh"
|
||||
zsh-defer source "$PLUGIN_DIR/fzf-tab/fzf-tab.plugin.zsh"
|
||||
zsh-defer source "$PLUGIN_DIR/fzf/shell/completion.zsh"
|
||||
zsh-defer source "$PLUGIN_DIR/fzf/shell/key-bindings.zsh"
|
||||
zsh-defer source "$PLUGIN_DIR/vim/vim.plugin.zsh"
|
||||
|
||||
source "$PLUGIN_DIR/minimal/minimal.zsh"
|
||||
source "$PLUGIN_DIR/vim/vim.plugin.zsh"
|
||||
|
||||
# Source config files
|
||||
source "$ZDOTDIR/opts.zsh"
|
||||
|
|
@ -51,6 +80,6 @@ source "$ZDOTDIR/maintenance.zsh"
|
|||
|
||||
# Defer loading
|
||||
zsh-defer source "$PLUGIN_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||
for config in mise.zsh tmux.zsh functions.zsh alias.zsh keymap.zsh path.zsh pnpm.zsh opts.zsh; do
|
||||
for config in mise.zsh tmux.zsh functions.zsh alias.zsh keymap.zsh path.zsh pnpm.zsh; do
|
||||
zsh-defer source "$ZDOTDIR/$config"
|
||||
done
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue