From 71e00938a72393f09ebab9d87be27dc5d06b701e Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Sat, 25 Jan 2020 00:55:07 +0100 Subject: [PATCH] plugin.zsh: Standard $0 handling and $fpath extending --- history-search-multi-word.plugin.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/history-search-multi-word.plugin.zsh b/history-search-multi-word.plugin.zsh index 9feb05c..93a389d 100644 --- a/history-search-multi-word.plugin.zsh +++ b/history-search-multi-word.plugin.zsh @@ -7,10 +7,16 @@ # to ~/.zshrc. # -0="${(%):-%N}" # this gives immunity to functionargzero being unset -HSMW_REPO_DIR="${0%/*}" -if [[ -z "$ZPLG_CUR_PLUGIN" && "${fpath[(r)$HSMW_REPO_DIR]}" != $HSMW_REPO_DIR ]]; then - fpath+=( "$HSMW_REPO_DIR" ) +# According to the standard: +# http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" + +HSMW_REPO_DIR="${0:h}" + +if [[ ${zsh_loaded_plugins[-1]} != */history-search-multi-word && -z ${fpath[(r)${0:h}]} ]] +then + fpath+=( "${0:h}" ) fi autoload history-search-multi-word hsmw-context-main