brew.plugin.zsh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 brewp='brew pin'
  28. alias brewsp='brew list --pinned'
  29. alias bubc='brew upgrade && brew cleanup'
  30. alias bubo='brew update && brew outdated'
  31. alias bubu='bubo && bubc'
  32. alias buf='brew upgrade --formula'
  33. function brews() {
  34. local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
  35. local casks="$(brew list --cask 2>/dev/null)"
  36. local blue="$(tput setaf 4)"
  37. local bold="$(tput bold)"
  38. local off="$(tput sgr0)"
  39. echo "${blue}==>${off} ${bold}Formulae${off}"
  40. echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
  41. echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
  42. }