mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
feat(z): update to version afaf2965 (#12136)
Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
This commit is contained in:
parent
f43ee85d8f
commit
667fdbf774
4 changed files with 47 additions and 25 deletions
|
|
@ -100,20 +100,30 @@ With no ARGUMENT, list the directory history in ascending rank.
|
|||
}
|
||||
|
||||
# Load zsh/datetime module, if necessary
|
||||
(( $+EPOCHSECONDS )) || zmodload zsh/datetime
|
||||
|
||||
# Load zsh/files, if necessary
|
||||
[[ ${builtins[zf_chown]} == 'defined' &&
|
||||
${builtins[zf_mv]} == 'defined' &&
|
||||
${builtins[zf_rm]} == 'defined' ]] ||
|
||||
zmodload -F zsh/files b:zf_chown b:zf_mv b:zf_rm
|
||||
|
||||
# Load zsh/system, if necessary
|
||||
[[ ${modules[zsh/system]} == 'loaded' ]] || zmodload zsh/system &> /dev/null
|
||||
(( ${+EPOCHSECONDS} )) || zmodload zsh/datetime
|
||||
|
||||
# Global associative array for internal use
|
||||
typeset -gA ZSHZ
|
||||
|
||||
# Fallback utilities in case Zsh lacks zsh/files (as is the case with MobaXterm)
|
||||
ZSHZ[CHOWN]='chown'
|
||||
ZSHZ[MV]='mv'
|
||||
ZSHZ[RM]='rm'
|
||||
# Try to load zsh/files utilities
|
||||
if [[ ${builtins[zf_chown]-} != 'defined' ||
|
||||
${builtins[zf_mv]-} != 'defined' ||
|
||||
${builtins[zf_rm]-} != 'defined' ]]; then
|
||||
zmodload -F zsh/files b:zf_chown b:zf_mv b:zf_rm &> /dev/null
|
||||
fi
|
||||
# Use zsh/files, if it is available
|
||||
[[ ${builtins[zf_chown]-} == 'defined' ]] && ZSHZ[CHOWN]='zf_chown'
|
||||
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
|
||||
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
|
||||
|
||||
|
||||
# Load zsh/system, if necessary
|
||||
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null
|
||||
|
||||
# Make sure ZSHZ_EXCLUDE_DIRS has been declared so that other scripts can
|
||||
# simply append to it
|
||||
(( ${+ZSHZ_EXCLUDE_DIRS} )) || typeset -gUa ZSHZ_EXCLUDE_DIRS
|
||||
|
|
@ -145,7 +155,7 @@ is-at-least 5.3.0 && ZSHZ[PRINTV]=1
|
|||
zshz() {
|
||||
|
||||
# Don't use `emulate -L zsh' - it breaks PUSHD_IGNORE_DUPS
|
||||
setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT EXTENDED_GLOB
|
||||
setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT EXTENDED_GLOB UNSET
|
||||
(( ZSHZ_DEBUG )) && setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL
|
||||
|
||||
local REPLY
|
||||
|
|
@ -277,7 +287,7 @@ zshz() {
|
|||
|
||||
if (( ret != 0 )); then
|
||||
# Avoid clobbering the datafile if the write to tempfile failed
|
||||
zf_rm -f "$tempfile"
|
||||
${ZSHZ[RM]} -f "$tempfile"
|
||||
return $ret
|
||||
fi
|
||||
|
||||
|
|
@ -285,16 +295,17 @@ zshz() {
|
|||
owner=${ZSHZ_OWNER:-${_Z_OWNER}}
|
||||
|
||||
if (( ZSHZ[USE_FLOCK] )); then
|
||||
zf_mv "$tempfile" "$datafile" 2> /dev/null || zf_rm -f "$tempfile"
|
||||
${ZSHZ[MV]} "$tempfile" "$datafile" 2> /dev/null || ${ZSHZ[RM]} -f "$tempfile"
|
||||
|
||||
if [[ -n $owner ]]; then
|
||||
zf_chown ${owner}:"$(id -ng ${owner})" "$datafile"
|
||||
${ZSHZ[CHOWN]} ${owner}:"$(id -ng ${owner})" "$datafile"
|
||||
fi
|
||||
else
|
||||
if [[ -n $owner ]]; then
|
||||
zf_chown "${owner}":"$(id -ng "${owner}")" "$tempfile"
|
||||
${ZSHZ[CHOWN]} "${owner}":"$(id -ng "${owner}")" "$tempfile"
|
||||
fi
|
||||
zf_mv -f "$tempfile" "$datafile" 2> /dev/null || zf_rm -f "$tempfile"
|
||||
${ZSHZ[MV]} -f "$tempfile" "$datafile" 2> /dev/null ||
|
||||
${ZSHZ[RM]} -f "$tempfile"
|
||||
fi
|
||||
|
||||
# In order to make z -x work, we have to disable zsh-z's adding
|
||||
|
|
@ -306,7 +317,7 @@ zshz() {
|
|||
}
|
||||
|
||||
############################################################
|
||||
# Read the curent datafile contents, update them, "age" them
|
||||
# Read the current datafile contents, update them, "age" them
|
||||
# when the total rank gets high enough, and print the new
|
||||
# contents to STDOUT.
|
||||
#
|
||||
|
|
@ -884,6 +895,9 @@ alias ${ZSHZ_CMD:-${_Z_CMD:-z}}='zshz 2>&1'
|
|||
# ZSHZ
|
||||
############################################################
|
||||
_zshz_precmd() {
|
||||
# Protect against `setopt NO_UNSET'
|
||||
setopt LOCAL_OPTIONS UNSET
|
||||
|
||||
# Do not add PWD to datafile when in HOME directory, or
|
||||
# if `z -x' has just been run
|
||||
[[ $PWD == "$HOME" ]] || (( ZSHZ[DIRECTORY_REMOVED] )) && return
|
||||
|
|
@ -931,7 +945,7 @@ add-zsh-hook chpwd _zshz_chpwd
|
|||
# Completion
|
||||
############################################################
|
||||
|
||||
# Standarized $0 handling
|
||||
# Standardized $0 handling
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
|
@ -958,7 +972,7 @@ ZSHZ[FUNCTIONS]='_zshz_usage
|
|||
# Enable WARN_NESTED_VAR for functions listed in
|
||||
# ZSHZ[FUNCTIONS]
|
||||
############################################################
|
||||
(( ZSHZ_DEBUG )) && () {
|
||||
(( ${+ZSHZ_DEBUG} )) && () {
|
||||
if is-at-least 5.4.0; then
|
||||
local x
|
||||
for x in ${=ZSHZ[FUNCTIONS]}; do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue