Skip to content

Instantly share code, notes, and snippets.

@suweller
Last active November 6, 2025 13:54
Show Gist options
  • Select an option

  • Save suweller/b6005d7c2b085040a4f723267ee7af71 to your computer and use it in GitHub Desktop.

Select an option

Save suweller/b6005d7c2b085040a4f723267ee7af71 to your computer and use it in GitHub Desktop.
workbrew // workaroundbrew // embrew
# Work around for brew
# https://console.workbrew.com/documentation/troubleshooting#how-do-i-fix-my-code-zsh-code-completions
#
# - Attempts to only intercept breaking brew invocations
# - Uses sudo to claim homebrew files to current user
# - Uses sudo to lend homebrew files to workbrew user
# - Uses NerdFont icons to dress up the prompts
local workbrew_bleed=(
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/Cellar/zsh/5.9/share/zsh/functions
/opt/homebrew/Cellar/zsh/5.9/share/zsh
)
# Transparently lend ownership to workbrew user
embrew() {
echo "\e[0;32m 󱍅 This is a custom function wrapping brew\e[0m"
echo " \$workbrew_bleed="
printf " %s\n" $workbrew_bleed
echo " 󰇷\e[0;31m sudo chown -R workbrew \$workbrew_bleed\e[0m to fix:\e[0;32m brew\e[0m $@"
sudo chown -R workbrew $workbrew_bleed
/opt/workbrew/bin/brew "$@"
echo " 󰇷\e[0;31m sudo chown -RL $(id -run) \$workbrew_bleed\e[0m to fix:\e[0;32m brew\e[0m $1"
sudo chown -RL $(id -run) $workbrew_bleed
}
# Wrap workbrew paths in embrew for affected commands
brew() {
case $1 in
doctor)
embrew "$@"
;;
install | uninstall | upgrade | update)
embrew "$@"
echo "\e[0;32m 󱍅 zgenom reset: Resetting zgenom caches\e[0m"
# zgenom reset # Reset zgenom managed completions cache
;;
*)
/opt/workbrew/bin/brew "$@"
;;
esac
}
# MIT License
#
# Copyright (c) 2025 Steven Weller
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment