| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- PLUGIN_DIR="$HOME/.local/share/zsh/plugins"
- mkdir -p "$PLUGIN_DIR"
- plugins=(
- "blimmer/zsh-aws-vault"
- "romkatv/zsh-defer"
- "zsh-users/zsh-autosuggestions"
- "hlissner/zsh-autopair"
- "zsh-users/zsh-history-substring-search"
- "Aloxaf/fzf-tab"
- "junegunn/fzf"
- "subnixr/minimal"
- "zap-zsh/vim"
- "zsh-users/zsh-syntax-highlighting"
- )
- zap() {
- echo "⚡ Updating plugins..."
- 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
- 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 "$PLUGIN_DIR/zsh-defer/zsh-defer.plugin.zsh"
- source "$PLUGIN_DIR/zsh-aws-vault/zsh-aws-vault.plugin.zsh"
- _batch_defer() {
- local files=("$@")
- for file in "${files[@]}"; do
- [[ -f "$file" ]] && source "$file"
- done
- }
- 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"
- source "$PLUGIN_DIR/minimal/minimal.zsh"
- source "$ZDOTDIR/opts.zsh"
- # source "$ZDOTDIR/rose-pine.sh"
- source "$ZDOTDIR/tmux.zsh"
- zsh-defer _batch_defer "$ZDOTDIR/alias.zsh" "$ZDOTDIR/keymap.zsh" "$ZDOTDIR/path.zsh" "$ZDOTDIR/pnpm.zsh" "$ZDOTDIR/mise.zsh"
- local func_files=("$ZDOTDIR/functions"/*.zsh)
- zsh-defer _batch_defer "${func_files[@]}" "$ZDOTDIR/completions/external.zsh"
- zsh-defer _batch_defer \
- "$PLUGIN_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" \
- "$PLUGIN_DIR/fzf-tab/fzf-tab.plugin.zsh" \
- "$PLUGIN_DIR/fzf/shell/completion.zsh" \
- "$PLUGIN_DIR/fzf/shell/key-bindings.zsh" \
- "$PLUGIN_DIR/vim/vim.plugin.zsh"
- _compile_zsh_files() {
- (
- local files=(
- "$ZDOTDIR/init.zsh"
- "$ZDOTDIR/opts.zsh"
- "$ZDOTDIR/rose-pine.sh"
- "$ZDOTDIR/completions/external.zsh"
- "$ZDOTDIR/tmux.zsh"
- "$ZDOTDIR/alias.zsh"
- "$ZDOTDIR/keymap.zsh"
- "$ZDOTDIR/path.zsh"
- "$ZDOTDIR/pnpm.zsh"
- "$ZDOTDIR/mise.zsh"
- )
- for func_file in "$ZDOTDIR/functions"/*.zsh; do
- files+=("$func_file")
- done
- for file in "${files[@]}"; do
- [[ ! -f "$file" ]] && continue
- local zwc="${file}.zwc"
- if [[ "$file" -nt "$zwc" ]] || [[ ! -f "$zwc" ]]; then
- zcompile "$file" 2>/dev/null &
- fi
- done
- wait
- ) > /dev/null 2>&1 &!
- }
- zsh-defer _compile_zsh_files
|