Skip to content

Commit

Permalink
feat: search for the plugin file to source (close #118) (#119)
Browse files Browse the repository at this point in the history
* Update zap.zsh

* Update README.md

* Update zap.zsh
  • Loading branch information
trimclain committed Mar 12, 2023
1 parent 3564bef commit ca9e52d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!----------------------------------------------------------------------------->

Expand Down
3 changes: 3 additions & 0 deletions zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ca9e52d

Please sign in to comment.