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
This commit is contained in:
Curtis Rueden 2021-12-18 14:53:49 -06:00 committed by Marc Cornellà
parent 89a740be2d
commit 2d32e9be66
No known key found for this signature in database
GPG Key ID: 0314585E776A9C1B
19 changed files with 91 additions and 3 deletions

View File

@ -1,8 +1,12 @@
print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'} 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'} 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 # Remove old generated completion file
# TODO: 2021-12-28: remove this line
command rm -f "${0:A:h}/_cargo" command rm -f "${0:A:h}/_cargo"
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {

View File

@ -19,6 +19,11 @@ bindkey -a 'N' vi-join
bindkey -a 'j' vi-forward-word-end bindkey -a 'j' vi-forward-word-end
bindkey -a 'J' vi-forward-blank-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 # New less versions will read this file directly
export LESSKEYIN="${0:h:A}/colemak-less" export LESSKEYIN="${0:h:A}/colemak-less"

View File

@ -16,6 +16,11 @@ less_termcap[se]="${reset_color}"
less_termcap[us]="${fg_bold[green]}" less_termcap[us]="${fg_bold[green]}"
less_termcap[ue]="${reset_color}" 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. # Absolute path to this file's directory.
typeset __colored_man_pages_dir="${0:A:h}" typeset __colored_man_pages_dir="${0:A:h}"

View File

@ -13,6 +13,11 @@ alias dup='deno upgrade'
# COMPLETION FUNCTION # COMPLETION FUNCTION
if (( $+commands[deno] )); then 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 # remove old generated completion file
command rm -f "${0:A:h}/_deno" command rm -f "${0:A:h}/_deno"

View File

@ -13,6 +13,11 @@
autoload -Uz is-at-least autoload -Uz is-at-least
is-at-least 24 "${${(Az)"$(emacsclient --version 2>/dev/null)"}[2]}" || return 0 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 # Path to custom emacsclient launcher
export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh" export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh"

View File

@ -4,6 +4,11 @@
# #
# See the README for documentation. # 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}" _omz_emoji_plugin_dir="${0:h}"
() { () {

View File

@ -10,6 +10,11 @@
# % export emotty_set=nature # % 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 typeset -gAH _emotty_sets
local _emotty_plugin_dir="${0:h}" local _emotty_plugin_dir="${0:h}"
source "$_emotty_plugin_dir/emotty_stellar_set.zsh" source "$_emotty_plugin_dir/emotty_stellar_set.zsh"

View File

@ -1,4 +1,9 @@
if (( $+commands[fnm] )); then 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 # remove old generated completion file
command rm -f "${0:A:h}/_fnm" command rm -f "${0:A:h}/_fnm"

View File

@ -1,5 +1,10 @@
# Autocompletion for the GitHub CLI (gh). # Autocompletion for the GitHub CLI (gh).
if (( $+commands[gh] )); then 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 # remove old generated completion file
command rm -f "${0:A:h}/_gh" command rm -f "${0:A:h}/_gh"

View File

@ -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}" __GIT_PROMPT_DIR="${0:A:h}"
## Hook function definitions ## Hook function definitions

View File

@ -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" source "${0:A:h}/git-prompt.sh"
function git_prompt_info() { function git_prompt_info() {

View File

@ -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 source ${0:A:h}/history-substring-search.zsh

View File

@ -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" HITCHHIKER_DIR="${0:h}/fortunes"
# Aliases # Aliases

View File

@ -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 # Open the current directory in a Finder window
alias ofd='open_command $PWD' alias ofd='open_command $PWD'

View File

@ -1,8 +1,12 @@
print ${(%):-'%F{yellow}The `rustup` plugin is deprecated and has been moved to the `rust` plugin.'} 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'} 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 # Remove old generated completion file
# TODO: 2021-12-28: remove this line
command rm -f "${0:A:h}/_rustup" command rm -f "${0:A:h}/_rustup"
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {

View File

@ -46,6 +46,11 @@ else
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
fi 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. # Set the correct local config file to use.
if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
export ZSH_TMUX_CONFIG export ZSH_TMUX_CONFIG

View File

@ -7,4 +7,9 @@
# #
# @github.com/mfaerevaag/wd # @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' }" eval "wd() { source '${0:A:h}/wd.sh' }"

View File

@ -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" source "${0:h}/z.sh"

View File

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