brew.plugin.zsh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. if (( ! $+commands[brew] )); then
  2. if [[ -x /opt/homebrew/bin/brew ]]; then
  3. BREW_LOCATION="/opt/homebrew/bin/brew"
  4. elif [[ -x /usr/local/bin/brew ]]; then
  5. BREW_LOCATION="/usr/local/bin/brew"
  6. elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
  7. BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew"
  8. elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then
  9. BREW_LOCATION="$HOME/.linuxbrew/bin/brew"
  10. else
  11. return
  12. fi
  13. # Only add Homebrew installation to PATH, MANPATH, and INFOPATH if brew is
  14. # not already on the path, to prevent duplicate entries. This aligns with
  15. # the behavior of the brew installer.sh post-install steps.
  16. eval "$("$BREW_LOCATION" shellenv)"
  17. unset BREW_LOCATION
  18. fi
  19. if [[ -z "$HOMEBREW_PREFIX" ]]; then
  20. # Maintain compatability with potential custom user profiles, where we had
  21. # previously relied on always sourcing shellenv. OMZ plugins should not rely
  22. # on this to be defined due to out of order processing.
  23. export HOMEBREW_PREFIX="$(brew --prefix)"
  24. fi
  25. alias bcubc='brew upgrade --cask && brew cleanup'
  26. alias bcubo='brew update && brew outdated --cask'
  27. alias bcubc='brew upgrade --cask && brew cleanup'
  28. alias brewp='brew pin'
  29. alias brewsp='brew list --pinned'
  30. alias bubc='brew upgrade && brew cleanup'
  31. alias bugbc='brew upgrade --greedy && brew cleanup'
  32. alias bubo='brew update && brew outdated'
  33. alias bubu='bubo && bubc'
  34. alias bubug='bubo && bugbc'
  35. alias buf='brew upgrade --formula'
  36. alias buz='brew uninstall --zap'
  37. function brews() {
  38. local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
  39. local casks="$(brew list --cask 2>/dev/null)"
  40. local blue="$(tput setaf 4)"
  41. local bold="$(tput bold)"
  42. local off="$(tput sgr0)"
  43. echo "${blue}==>${off} ${bold}Formulae${off}"
  44. echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
  45. echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
  46. }