From ca9e52da6accfbf09a449e0e7be3a326b426acbf Mon Sep 17 00:00:00 2001 From: Arthur McLain Date: Sun, 12 Mar 2023 14:22:14 +0100 Subject: [PATCH] feat: search for the plugin file to source (close #118) (#119) * Update zap.zsh * Update README.md * Update zap.zsh --- README.md | 8 +------- zap.zsh | 3 +++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 65bc82b..cc977aa 100644 --- a/README.md +++ b/README.md @@ -118,13 +118,7 @@ rm -rf ~/.local/share/zap ## Notes -Will only work with plugins that are named conventionally, this means that the plugin file is the same name as the repository with the following extensions: - -- `.plugin.zsh` -- `.zsh` -- `.zsh-theme` - -For example: [vim](https://github.com/zap-zsh/vim) +For sourcing local files use `$HOME` instead of `~` when giving a full path to the file. diff --git a/zap.zsh b/zap.zsh index 8124861..f607534 100644 --- a/zap.zsh +++ b/zap.zsh @@ -13,6 +13,9 @@ function plug() { for ext in "${extensions[@]}"; do [[ -e "$plugin_dir/$plugin_name$ext" ]] && source "$plugin_dir/$plugin_name$ext" && return 0 [[ -e "$plugin_dir/${plugin_name#zsh-}$ext" ]] && source "$plugin_dir/${plugin_name#zsh-}$ext" && return 0 + # If the plugin file has a different name than $plugin_name + plugin_filename=$(command ls $plugin_dir | grep $ext) + [[ -n $plugin_filename ]] && [[ $(echo $plugin_filename | wc -l) == 1 ]] && source "$plugin_dir/$plugin_filename" && return 0 done }