diff --git a/zap.zsh b/zap.zsh index 1420933..950f7ff 100644 --- a/zap.zsh +++ b/zap.zsh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC1090 export ZAP_DIR="$HOME/.local/share/zap" export ZAP_PLUGIN_DIR="$ZAP_DIR/plugins" @@ -8,23 +9,17 @@ else export ZAP_ZSHRC=$ZDOTDIR/.zshrc fi -_try_source() { - # shellcheck disable=SC1090 - [ -f "$1" ] && source "$1" -} - plug() { plugin="$1" if [ -f "$plugin" ]; then source "$plugin" else - local full_plugin_name="$1" local git_ref="$2" - local plugin_name=$(echo "$full_plugin_name" | cut -d "/" -f 2) + local plugin_name=$(basename "$plugin") local plugin_dir="$ZAP_PLUGIN_DIR/$plugin_name" if [ ! -d "$plugin_dir" ]; then echo "🔌$plugin_name" - git clone "https://github.com/${full_plugin_name}.git" "$plugin_dir" > /dev/null 2>&1 + git clone "https://github.com/${plugin}.git" "$plugin_dir" > /dev/null 2>&1 if [ -n "$git_ref" ]; then git -C "$plugin_dir" checkout "$git_ref" > /dev/null 2>&1 fi @@ -34,9 +29,10 @@ plug() { fi echo -e "\e[1A\e[K⚡$plugin_name" fi - _try_source "$plugin_dir/$plugin_name.plugin.zsh" - _try_source "$plugin_dir/$plugin_name.zsh" - _try_source "$plugin_dir/$plugin_name.zsh-theme" + local full_path="$plugin_dir/$plugin$name" + [[ -f "$full_path.plugin.zsh" ]] && source "$full_path.plugin.zsh" + [[ -f "$full_path.zsh" ]] && source "$full_path.zsh" + [[ -f "$full_path.zsh-theme" ]] && source "$full_path.zsh-theme" fi }