From 3d97d39bdc49e5f56c73a1b045adf3721010f615 Mon Sep 17 00:00:00 2001 From: Tri Vo Khac <33442340+vokhactri@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:17:00 +0700 Subject: [PATCH] feat: enhance zsh bin setup to include GNU tools - Add support for GNU tools in PATH without 'g' prefix - Include additional bin paths for local binaries - Improve structure for adding directories to PATH --- zsh/.config/zsh/snippets/bin | 43 +++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/zsh/.config/zsh/snippets/bin b/zsh/.config/zsh/snippets/bin index dabfec5..068af8c 100644 --- a/zsh/.config/zsh/snippets/bin +++ b/zsh/.config/zsh/snippets/bin @@ -1,10 +1,37 @@ #!/usr/bin/env zsh -export LOCAL_BIN="$HOME/.local/bin" -if ! [ -d "$LOCAL_BIN" ]; then - mkdir -p "$LOCAL_BIN" -fi -case ":$PATH:" in - *":$LOCAL_BIN:"*) ;; - *) export PATH="$LOCAL_BIN:$PATH" ;; -esac +# Add GNU tools to PATH without 'g' prefix +local gnu_tools=( + "coreutils" + "findutils" + "gnu-tar" + "gnu-sed" + "gawk" + "gnu-indent" + "grep" +) + +for tool in $gnu_tools; do + local gnubin="/opt/homebrew/opt/$tool/libexec/gnubin" + if [ -d "$gnubin" ]; then + case ":$PATH:" in + *":$gnubin:"*) ;; + *) export PATH="$gnubin:$PATH" ;; + esac + fi +done + +# Add other bins separately since they have a different path structure +local bin_paths=( + "$HOME/.local/bin" + "/opt/homebrew/opt/gnu-getopt/bin" +) +for bin_path in $bin_paths; do + if [ -d "$bin_path" ]; then + case ":$PATH:" in + *":$bin_path:"*) ;; + *) export PATH="$bin_path:$PATH" ;; + esac + fi +done +