From ba489c22a7a9dccb09c01995704b0aca19089aec Mon Sep 17 00:00:00 2001 From: Vladislav Doster Date: Sun, 2 Apr 2023 09:11:52 -0500 Subject: [PATCH] feat: link all brew kegs via brew.link-all-keg Signed-off-by: Vladislav Doster --- zsh/.config/zsh/functions/brew.link-all-keg | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 zsh/.config/zsh/functions/brew.link-all-keg diff --git a/zsh/.config/zsh/functions/brew.link-all-keg b/zsh/.config/zsh/functions/brew.link-all-keg new file mode 100755 index 00000000..f5d7047b --- /dev/null +++ b/zsh/.config/zsh/functions/brew.link-all-keg @@ -0,0 +1,30 @@ +#autoload + +emulate -L zsh +zmodload zsh/zutil || return + +local flag_help flag_verbose +local -a arg_extension=() + +local -a usage=( + "brew.link-kegs [-h|--help]" +) + +zmodload zsh/zutil +zparseopts -D -F -K -- {h,-help}=flag_help || return 1 + +[[ -z "$flag_help" ]] || { print -l $usage && return } + +local -a brew_keg_only=( + $( + brew info --installed --json=v1 \ + | jq --raw-output --compact-output 'map(select(.keg_only == true)) | map(.name) | @sh' + ) +) + +for keg in $brew_keg_only; do + export PATH="${HOMEBREW_PREFIX}/opt/${(Q)keg}/bin:${PATH}" + print -P -- "%F{green}==>%f ${keg} added to PATH" +done + +# vim: set expandtab filetype=zsh shiftwidth=2 softtabstop=2 tabstop=2: