From f62b2b1e4a756fffeb7568af8e6d42fd34a83158 Mon Sep 17 00:00:00 2001 From: Tri Vo Khac Date: Wed, 24 Jun 2026 11:13:00 +0700 Subject: [PATCH] fix(zsh): apply zshellcheck lint fixes - use [[ ]] over [ ], quote vars, shallow clone in zinit.zsh - typeset -A instead of declare -A - nullglob (N) and path array idiom in bin.zsh/default.zsh --- zsh/.config/zsh/config/bin.zsh | 8 ++++---- zsh/.config/zsh/config/default.zsh | 2 +- zsh/.config/zsh/zinit.zsh | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zsh/.config/zsh/config/bin.zsh b/zsh/.config/zsh/config/bin.zsh index 1eddb1f..6c098e5 100644 --- a/zsh/.config/zsh/config/bin.zsh +++ b/zsh/.config/zsh/config/bin.zsh @@ -16,8 +16,8 @@ if [[ ! -f "$MARKER_FILE" ]]; then for tool in $gnu_tools; do gnubin="/opt/homebrew/opt/$tool/libexec/gnubin" - if [ -d "$gnubin" ]; then - for bin in "$gnubin"/*; do + if [[ -d "$gnubin" ]]; then + for bin in "$gnubin"/*(N); do ln -sf "$bin" "$XDG_BIN_HOME/$(basename "$bin")" done fi @@ -33,10 +33,10 @@ local bin_paths=( "/opt/homebrew/opt/gnu-getopt/bin" ) for bin_path in "${bin_paths[@]}"; do - if [ -d "$bin_path" ]; then + if [[ -d "$bin_path" ]]; then case ":$PATH:" in *":$bin_path:"*) ;; - *) PATH="$bin_path:$PATH" ;; + *) path=("$bin_path" $path) ;; esac fi done diff --git a/zsh/.config/zsh/config/default.zsh b/zsh/.config/zsh/config/default.zsh index 7027ec4..d599410 100644 --- a/zsh/.config/zsh/config/default.zsh +++ b/zsh/.config/zsh/config/default.zsh @@ -12,5 +12,5 @@ export STARSHIP_CONFIG="$XDG_CONFIG_HOME"/starship/starship.toml export PNPM_HOME="$HOME/.local/share/pnpm" case ":$PATH:" in *":$PNPM_HOME/bin:"*) ;; - *) export PATH="$PNPM_HOME/bin:$PATH" ;; + *) path=("$PNPM_HOME/bin" $path) ;; esac diff --git a/zsh/.config/zsh/zinit.zsh b/zsh/.config/zsh/zinit.zsh index 5e653b1..c0ce594 100644 --- a/zsh/.config/zsh/zinit.zsh +++ b/zsh/.config/zsh/zinit.zsh @@ -1,11 +1,11 @@ #!/usr/bin/env zsh ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" -[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)" -[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +[[ ! -d "$ZINIT_HOME" ]] && mkdir -p "$(dirname "$ZINIT_HOME")" +[[ ! -d "$ZINIT_HOME/.git" ]] && git clone --depth 1 https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" # not to use aliases: zi or zini -declare -A ZINIT +typeset -A ZINIT ZINIT[NO_ALIASES]=1 ZINIT[LIST_COMMAND]='lsd --tree'