brew.plugin.zsh 2.1 KB

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