fix: misc bugfixes across lib, plugins, and tools

- fix(cli): fix omz pr test subshell variable scope issue
- fix(functions): fix takezip parsing wrong line from unzip -l output
- fix(history): handle empty HISTSIZE/SAVEHIST to prevent comparison error
- fix(git): add version guard for gclf alias (--also-filter-submodules)
- fix(macos/spotify): fix typo USER_CONFG_FILE -> USER_CONFIG_FILE
- fix(docker): handle empty container list in dsta alias
- fix(npm): replace deprecated npm bin with npm prefix in npmE alias
- fix(kubectl): add kgen alias using .metadata.creationTimestamp
- fix(grep): rename GREP_OPTIONS to local variable grep_opts
- fix(theme-and-appearance): fix OpenBSD ls alias order to match comment
This commit is contained in:
diaoyunxi 2026-07-08 04:51:43 +00:00
commit d6c14ecdbd
10 changed files with 26 additions and 16 deletions

View file

@ -615,12 +615,13 @@ function _omz::pr::test {
builtin cd -q "$ZSH"
# Get the ohmyzsh git remote
command git remote -v | while read remote url _; do
local found=0
while read remote url _; do
case "$url" in
https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
esac
done
done <<< "$(command git remote -v)"
(( $found )) || {
_omz::log error "could not find the ohmyzsh git remote. Aborting..."

View file

@ -65,7 +65,9 @@ function takezip() {
data="$(mktemp)"
curl -L "$1" > "$data"
unzip "$data" -d "./"
thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
# Parse the first actual file entry from unzip -l output, skipping header lines and separators
thedir="$(unzip -l "$data" | awk 'NR>3 && !/^-/ && NF>=4 {print $4; exit}')"
thedir="${thedir%%/*}"
rm "$data"
cd "$thedir"
}

View file

@ -10,20 +10,21 @@ else
}
# Ignore these folders (if the necessary grep flags are available)
EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}"
local EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}"
local grep_opts
# Check for --exclude-dir, otherwise check for --exclude. If --exclude
# isn't available, --color won't be either (they were released at the same
# time (v2.5): https://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007
if grep-flags-available --color=auto --exclude-dir=.cvs; then
GREP_OPTIONS="--color=auto --exclude-dir=$EXC_FOLDERS"
grep_opts="--color=auto --exclude-dir=$EXC_FOLDERS"
elif grep-flags-available --color=auto --exclude=.cvs; then
GREP_OPTIONS="--color=auto --exclude=$EXC_FOLDERS"
grep_opts="--color=auto --exclude=$EXC_FOLDERS"
fi
if [[ -n "$GREP_OPTIONS" ]]; then
if [[ -n "$grep_opts" ]]; then
# export grep, egrep and fgrep settings
alias grep="grep $GREP_OPTIONS"
alias grep="grep $grep_opts"
alias egrep="grep -E"
alias fgrep="grep -F"
@ -34,7 +35,6 @@ else
fi
# Clean up
unset GREP_OPTIONS EXC_FOLDERS
unfunction grep-flags-available
fi

View file

@ -36,8 +36,8 @@ esac
## History file configuration
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
[ -z "$HISTSIZE" ] || [ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
[ -z "$SAVEHIST" ] || [ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
## History command configuration
setopt extended_history # record timestamp of command in HISTFILE

View file

@ -57,8 +57,8 @@ case "$OSTYPE" in
# with color and multibyte support) are available from ports.
# `colorls` will be installed on purpose and can't be pulled in by installing
# coreutils (which might be installed for ), so prefer it to `gls`.
test-ls-args gls --color && alias ls='gls --color=tty'
test-ls-args colorls -G && alias ls='colorls -G'
test-ls-args gls --color && alias ls='gls --color=tty'
;;
(darwin|freebsd)*)
# This alias works by default just using $LSCOLORS

View file

@ -29,7 +29,7 @@ alias 'drm!'='docker container rm -f'
alias dsprune='docker system prune'
alias dst='docker container start'
alias drs='docker container restart'
alias dsta='docker stop $(docker ps -q)'
alias dsta='docker ps -q | xargs -r docker stop'
alias dstp='docker container stop'
alias dsts='docker stats'
alias dtop='docker top'

View file

@ -167,7 +167,12 @@ alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gclean='git clean --interactive -d'
alias gcl='git clone --recurse-submodules'
alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules'
# gclf: clone with --filter and --shallow-submodules, requires Git >= 2.36 for --also-filter-submodules
if is-at-least 2.36.0 "$git_version"; then
alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules'
else
alias gclf='git clone --recursive --shallow-submodules --filter=blob:none'
fi
function gccd() {
setopt localoptions extendedglob

View file

@ -42,6 +42,8 @@ alias kdelf='kubectl delete -f'
alias kdelk='kubectl delete -k'
alias kge='kubectl get events --sort-by=".lastTimestamp"'
alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
alias kgen='kubectl get events --sort-by=".metadata.creationTimestamp"'
alias kgenw='kubectl get events --sort-by=".metadata.creationTimestamp" --watch'
# Pod management.
alias kgp='kubectl get pods'

View file

@ -194,7 +194,7 @@ while [ $# -gt 0 ]; do
-d "grant_type=client_credentials" \
)
if ! [[ "${SPOTIFY_TOKEN_RESPONSE_DATA}" =~ "access_token" ]]; then
cecho "Authorization failed, please check ${USER_CONFG_FILE}"
cecho "Authorization failed, please check ${USER_CONFIG_FILE}"
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
showAPIHelp
return 1

View file

@ -32,7 +32,7 @@ alias npmF='npm i -f'
# Execute command from node_modules folder based on current directory
# i.e npmE gulp
alias npmE='PATH="$(npm bin)":"$PATH"'
alias npmE='PATH="$(npm prefix)/node_modules/.bin":"$PATH"'
# Check which npm modules are outdated
alias npmO="npm outdated"