brew.plugin.zsh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
  26. fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
  27. fi
  28. alias bcubc='brew upgrade --cask && brew cleanup'
  29. alias bcubo='brew update && brew outdated --cask'
  30. alias bcubc='brew upgrade --cask && brew cleanup'
  31. alias brewp='brew pin'
  32. alias brewsp='brew list --pinned'
  33. alias bubc='brew upgrade && brew cleanup'
  34. alias bugbc='brew upgrade --greedy && brew cleanup'
  35. alias bubo='brew update && brew outdated'
  36. alias bubu='bubo && bubc'
  37. alias bubug='bubo && bugbc'
  38. alias bfu='brew upgrade --formula'
  39. alias buz='brew uninstall --zap'
  40. function brews() {
  41. local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
  42. local casks="$(brew list --cask 2>/dev/null)"
  43. local blue="$(tput setaf 4)"
  44. local bold="$(tput bold)"
  45. local off="$(tput sgr0)"
  46. echo "${blue}==>${off} ${bold}Formulae${off}"
  47. echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
  48. echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
  49. }