Browse Source

refactor: handle `$0` according to the Zsh plugin standard (#10518)

For details and rationale, see:
https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html

Closes #10518
Curtis Rueden 2 years ago
parent
commit
2d32e9be66

+ 5 - 1
plugins/cargo/cargo.plugin.zsh

@@ -1,8 +1,12 @@
 print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
 print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
 
+# TODO: 2021-12-28: remove this block
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
 # Remove old generated completion file
-# TODO: 2021-12-28: remove this line
 command rm -f "${0:A:h}/_cargo"
 
 (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {

+ 5 - 0
plugins/colemak/colemak.plugin.zsh

@@ -19,6 +19,11 @@ bindkey -a 'N' vi-join
 bindkey -a 'j' vi-forward-word-end
 bindkey -a 'J' vi-forward-blank-word-end
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 # New less versions will read this file directly
 export LESSKEYIN="${0:h:A}/colemak-less"
 

+ 5 - 0
plugins/colored-man-pages/colored-man-pages.plugin.zsh

@@ -16,6 +16,11 @@ less_termcap[se]="${reset_color}"
 less_termcap[us]="${fg_bold[green]}"
 less_termcap[ue]="${reset_color}"
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 # Absolute path to this file's directory.
 typeset __colored_man_pages_dir="${0:A:h}"
 

+ 5 - 0
plugins/deno/deno.plugin.zsh

@@ -13,6 +13,11 @@ alias dup='deno upgrade'
 
 # COMPLETION FUNCTION
 if (( $+commands[deno] )); then
+  # Handle $0 according to the standard:
+  # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+  0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+  0="${${(M)0:#/*}:-$PWD/$0}"
+
   # remove old generated completion file
   command rm -f "${0:A:h}/_deno"
 

+ 5 - 0
plugins/emacs/emacs.plugin.zsh

@@ -13,6 +13,11 @@
 autoload -Uz is-at-least
 is-at-least 24 "${${(Az)"$(emacsclient --version 2>/dev/null)"}[2]}" || return 0
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 # Path to custom emacsclient launcher
 export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh"
 

+ 5 - 0
plugins/emoji/emoji.plugin.zsh

@@ -4,6 +4,11 @@
 #
 # See the README for documentation.
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 _omz_emoji_plugin_dir="${0:h}"
 
 () {

+ 5 - 0
plugins/emotty/emotty.plugin.zsh

@@ -10,6 +10,11 @@
 # % export emotty_set=nature
 # ------------------------------------------------------------------------------
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 typeset -gAH _emotty_sets
 local _emotty_plugin_dir="${0:h}"
 source "$_emotty_plugin_dir/emotty_stellar_set.zsh"

+ 5 - 0
plugins/fnm/fnm.plugin.zsh

@@ -1,4 +1,9 @@
 if (( $+commands[fnm] )); then
+  # Handle $0 according to the standard:
+  # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+  0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+  0="${${(M)0:#/*}:-$PWD/$0}"
+
   # remove old generated completion file
   command rm -f "${0:A:h}/_fnm"
 

+ 5 - 0
plugins/gh/gh.plugin.zsh

@@ -1,5 +1,10 @@
 # Autocompletion for the GitHub CLI (gh).
 if (( $+commands[gh] )); then
+  # Handle $0 according to the standard:
+  # # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+  0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+  0="${${(M)0:#/*}:-$PWD/$0}"
+
   # remove old generated completion file
   command rm -f "${0:A:h}/_gh"
 

+ 5 - 0
plugins/git-prompt/git-prompt.plugin.zsh

@@ -1,3 +1,8 @@
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 __GIT_PROMPT_DIR="${0:A:h}"
 
 ## Hook function definitions

+ 5 - 0
plugins/gitfast/gitfast.plugin.zsh

@@ -1,3 +1,8 @@
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 source "${0:A:h}/git-prompt.sh"
 
 function git_prompt_info() {

+ 5 - 1
plugins/history-substring-search/history-substring-search.plugin.zsh

@@ -1,4 +1,8 @@
-0=${(%):-%N}
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 source ${0:A:h}/history-substring-search.zsh
 
 

+ 5 - 0
plugins/hitchhiker/hitchhiker.plugin.zsh

@@ -1,3 +1,8 @@
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 HITCHHIKER_DIR="${0:h}/fortunes"
 
 # Aliases

+ 5 - 0
plugins/macos/macos.plugin.zsh

@@ -1,3 +1,8 @@
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 # Open the current directory in a Finder window
 alias ofd='open_command $PWD'
 

+ 5 - 1
plugins/rustup/rustup.plugin.zsh

@@ -1,8 +1,12 @@
 print ${(%):-'%F{yellow}The `rustup` plugin is deprecated and has been moved to the `rust` plugin.'}
 print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
 
+# TODO: 2021-12-28: remove this block
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
 # Remove old generated completion file
-# TODO: 2021-12-28: remove this line
 command rm -f "${0:A:h}/_rustup"
 
 (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {

+ 5 - 0
plugins/tmux/tmux.plugin.zsh

@@ -46,6 +46,11 @@ else
   export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
 fi
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 # Set the correct local config file to use.
 if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
   export ZSH_TMUX_CONFIG

+ 5 - 0
plugins/wd/wd.plugin.zsh

@@ -7,4 +7,9 @@
 #
 # @github.com/mfaerevaag/wd
 
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 eval "wd() { source '${0:A:h}/wd.sh' }"

+ 5 - 0
plugins/z/z.plugin.zsh

@@ -1 +1,6 @@
+# Handle $0 according to the standard:
+# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
 source "${0:h}/z.sh"

+ 1 - 0
plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh

@@ -11,6 +11,7 @@
 # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
 0="${${(M)0:#/*}:-$PWD/$0}"
+
 export ZNT_REPO_DIR="${0:h}"
 export ZNT_CONFIG_DIR="$HOME/.config/znt"