summary refs log tree commit diff
path: root/dot_local/share/zsh/brew
diff options
context:
space:
mode:
authorAlen <alen@dotfiles.xyz>2025-01-19 03:26:44 +0400
committerAlen <alen@dotfiles.xyz>2025-01-19 03:26:44 +0400
commit43c982798c902315aba2f8865d0407c6ff70a180 (patch)
tree469de00c188d60d2859066cfa94bf2880b16eb46 /dot_local/share/zsh/brew
parent6e8b63f101e056f80cf6b7d17d07161bead1ceeb (diff)
Add batch of zsh plugins and kitting out
Diffstat (limited to 'dot_local/share/zsh/brew')
-rw-r--r--dot_local/share/zsh/brew/brew.plugin.zsh29
1 files changed, 29 insertions, 0 deletions
diff --git a/dot_local/share/zsh/brew/brew.plugin.zsh b/dot_local/share/zsh/brew/brew.plugin.zsh
new file mode 100644
index 0000000..e929174
--- /dev/null
+++ b/dot_local/share/zsh/brew/brew.plugin.zsh
@@ -0,0 +1,29 @@
+# Set up brew
+if [[ -f /opt/homebrew/bin/brew ]]; then
+    export HOMEBREW_NO_ENV_HINTS=1
+    export HOMEBREW_NO_ANALYTICS=1
+    eval "$(/opt/homebrew/bin/brew shellenv)"
+    fpath=("/opt/homebrew/share/zsh/site-functions" $fpath)
+
+    # Prefer GNU versions of certain tools
+    local tool_bin
+    for tool_bin in /opt/homebrew/opt/*/libexec/gnubin(N); do
+        if [[ "${tool_bin}" == */gsed/* ]]; then
+            continue  # Alias to gnu-sed
+        fi
+        export PATH="${tool_bin}${PATH+:$PATH}"
+        export MANPATH="$(dirname ${tool_bin})/gnuman${MANPATH+:$MANPATH}"
+    done
+
+    # Brew leaves and deps
+    brews() {
+        local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
+        local casks="$(brew list --cask)"
+        local blue="$(tput setaf 4)"
+        local bold="$(tput bold)"
+        local off="$(tput sgr0)"
+        echo "${blue}==>${off} ${bold}Formulae${off}"
+        echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
+        echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
+    }
+fi