From f076985c573d332dfa474948a9251e83839f1827 Mon Sep 17 00:00:00 2001 From: Frank Peleato Date: Thu, 26 Mar 2026 12:02:00 -0600 Subject: [PATCH] refactor: use pure zsh for JSON parsing instead of awk Replace awk-based JSON parsing with native zsh regex matching and file reading. This removes the external command dependency and is slightly faster. Made-with: Cursor --- config/p10k-classic.zsh | 6 ++++-- config/p10k-lean-8colors.zsh | 6 ++++-- config/p10k-lean.zsh | 6 ++++-- config/p10k-rainbow.zsh | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index fbf88310..323f0f91 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -1682,8 +1682,10 @@ dir=${dir:h} done [[ -z $sf_config ]] && return - local org - org=$(command awk -F'"' '/target-org/{print $4}' "$sf_config" 2>/dev/null) + local content + content=$(<"$sf_config") || return + [[ $content =~ '"target-org"[[:space:]]*:[[:space:]]*"([^"]*)"' ]] || return + local org=$match[1] [[ -z $org ]] && return p10k segment -b 4 -f 255 -i $'\uf0c2' -t "$org" } diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index 7ddf862a..a6b1de8a 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -1657,8 +1657,10 @@ dir=${dir:h} done [[ -z $sf_config ]] && return - local org - org=$(command awk -F'"' '/target-org/{print $4}' "$sf_config" 2>/dev/null) + local content + content=$(<"$sf_config") || return + [[ $content =~ '"target-org"[[:space:]]*:[[:space:]]*"([^"]*)"' ]] || return + local org=$match[1] [[ -z $org ]] && return p10k segment -b 4 -f 255 -i $'\uf0c2' -t "$org" } diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 9e170fd4..c9958e91 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -1657,8 +1657,10 @@ dir=${dir:h} done [[ -z $sf_config ]] && return - local org - org=$(command awk -F'"' '/target-org/{print $4}' "$sf_config" 2>/dev/null) + local content + content=$(<"$sf_config") || return + [[ $content =~ '"target-org"[[:space:]]*:[[:space:]]*"([^"]*)"' ]] || return + local org=$match[1] [[ -z $org ]] && return p10k segment -b 4 -f 255 -i $'\uf0c2' -t "$org" } diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 20cf1269..58bb2577 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -1775,8 +1775,10 @@ dir=${dir:h} done [[ -z $sf_config ]] && return - local org - org=$(command awk -F'"' '/target-org/{print $4}' "$sf_config" 2>/dev/null) + local content + content=$(<"$sf_config") || return + [[ $content =~ '"target-org"[[:space:]]*:[[:space:]]*"([^"]*)"' ]] || return + local org=$match[1] [[ -z $org ]] && return p10k segment -b 4 -f 255 -i $'\uf0c2' -t "$org" }