From b442b78034de3a7c41d4a21c02ac38144432dd1e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 14:32:27 +0000 Subject: [PATCH] perf: replace grep -q here-string with ZSH built-in pattern matching Replace `grep -q "literal" <<< "\$var"` with `[[ "\$var" == *pattern* ]]` in macos-notvscode.zsh (4 occurrences) and aliases/go.zsh (1 occurrence). ZSH built-in string matching requires no subshell or external process, making these checks faster and more portable. Affected functions: - is-at-home (macos-notvscode.zsh): 2 occurrences - is-displaylink-connected (macos-notvscode.zsh): 2 occurrences - golangci-lint-with-retry (aliases/go.zsh): 1 occurrence Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- zsh/aliases/go.zsh | 2 +- zsh/macos-notvscode.zsh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zsh/aliases/go.zsh b/zsh/aliases/go.zsh index f2e8c228..79948043 100644 --- a/zsh/aliases/go.zsh +++ b/zsh/aliases/go.zsh @@ -33,7 +33,7 @@ golangci-lint-with-retry() { if output=$(golangci-lint run --fix 2>&1); then echo "$output" return 0 - elif grep -q "parallel golangci-lint is running" <<< "$output"; then + elif [[ "$output" == *"parallel golangci-lint is running"* ]]; then echo "Attempt $attempt/$max_attempts: Waiting for parallel golangci-lint to finish..." sleep 1 ((attempt++)) diff --git a/zsh/macos-notvscode.zsh b/zsh/macos-notvscode.zsh index d9032fa2..4e99aec6 100644 --- a/zsh/macos-notvscode.zsh +++ b/zsh/macos-notvscode.zsh @@ -5,16 +5,16 @@ is-at-home() { [[ "$OSTYPE" != darwin* ]] && return 1 local usb_info usb_info=$(ioreg -p IOUSB) && - grep -q "Plugable USBC-6950U" <<< "$usb_info" && - grep -q "TS4" <<< "$usb_info" && + [[ "$usb_info" == *"Plugable USBC-6950U"* ]] && + [[ "$usb_info" == *TS4* ]] && networksetup -getnetworkserviceenabled "Thunderbolt Ethernet Slot 2" | grep -q Enabled } is-displaylink-connected() { [[ "$OSTYPE" != darwin* ]] && return 1 local display_info display_info=$(system_profiler SPDisplaysDataType) - grep -q "ARZOPA" <<< "$display_info" || - grep -q "TYPE-C" <<< "$display_info" + [[ "$display_info" == *ARZOPA* ]] || + [[ "$display_info" == *TYPE-C* ]] } restart-displaylink() { if [[ "$OSTYPE" != darwin* ]]; then