brew.plugin.zsh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 ba='brew autoremove'
  34. alias bci='brew info --cask'
  35. alias bcin='brew install --cask'
  36. alias bcl='brew list --cask'
  37. alias bcn='brew cleanup'
  38. alias bco='brew outdated --cask'
  39. alias bcrin='brew reinstall --cask'
  40. alias bcubc='brew upgrade --cask && brew cleanup'
  41. alias bcubo='brew update && brew outdated --cask'
  42. alias bcup='brew upgrade --cask'
  43. alias bfu='brew upgrade --formula'
  44. alias bi='brew install'
  45. alias bl='brew list'
  46. alias bo='brew outdated'
  47. alias brewp='brew pin'
  48. alias brewsp='brew list --pinned'
  49. alias bsl='brew services list'
  50. alias bsoff='brew services stop'
  51. alias bsoffa='bsoff --all'
  52. alias bson='brew services start'
  53. alias bsona='bson --all'
  54. alias bsr='brew services run'
  55. alias bsra='bsr --all'
  56. alias bu='brew update'
  57. alias bubo='brew update && brew outdated'
  58. alias bubu='bubo && bup'
  59. alias bubug='bubo && bugbc'
  60. alias bugbc='brew upgrade --greedy && brew cleanup'
  61. alias bup='brew upgrade'
  62. alias bup='brew upgrade'
  63. alias buz='brew uninstall --zap'
  64. function brews() {
  65. local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
  66. local casks="$(brew list --cask 2>/dev/null)"
  67. local blue="$(tput setaf 4)"
  68. local bold="$(tput bold)"
  69. local off="$(tput sgr0)"
  70. echo "${blue}==>${off} ${bold}Formulae${off}"
  71. echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
  72. echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
  73. }