From 844304b2cd12b5ee7e2db9987d4d9b9d2b3500d5 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 29 Jun 2021 17:04:04 +0800 Subject: [PATCH] feat: standardized handling `$0` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For all kinds of plugin managers to get the plugin’s location properly, we need to handle `$0` correctly. --- zsh-autosuggestions.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zsh-autosuggestions.plugin.zsh b/zsh-autosuggestions.plugin.zsh index 16c2256..a7751d6 100644 --- a/zsh-autosuggestions.plugin.zsh +++ b/zsh-autosuggestions.plugin.zsh @@ -1 +1,6 @@ -source ${0:A:h}/zsh-autosuggestions.zsh +# According to the standard: +# https://github.com/zdharma/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc +0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}" +0="${${(M)0:#/*}:-$PWD/$0}" + +source ${0:h}/zsh-autosuggestions.zsh