1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-25 23:30:08 +00:00

feat(brew): run brew shellenv command at plugin load (#10874)

This commit is contained in:
Carlo Sala 2022-07-12 18:40:39 +02:00 committed by GitHub
parent 4c82a2eedf
commit d2dc3bd2da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 7 deletions

View file

@ -8,19 +8,23 @@ To use it, add `brew` to the plugins array of your zshrc file:
plugins=(... brew) plugins=(... brew)
``` ```
## Shellenv
This plugin also executes `brew shellenv` at plugin load to set up many useful variables, such as `HOMEBREW_PREFIX` or `HOMEBREW_REPOSITORY`.
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
|----------|---------------------------------------|---------------------------------------------------------------------| | -------- | ------------------------------------- | ------------------------------------------------------------------- |
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | | `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | | `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | | `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. | | `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
| `bubu` | `bubo && bubc` | Do the last two operations above. | | `bubu` | `bubo && bubc` | Do the last two operations above. |
| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). | | `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
## Completion ## Completion

View file

@ -1,11 +1,35 @@
if (( ! $+commands[brew] )); then
if [[ -x /opt/homebrew/bin/brew ]]; then
BREW_LOCATION="/opt/homebrew/bin/brew"
elif [[ -x /usr/local/bin/brew ]]; then
BREW_LOCATION="/usr/local/bin/brew"
elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew"
elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then
BREW_LOCATION="$HOME/.linuxbrew/bin/brew"
else
return
fi
fi
if [[ -z "$HOMEBREW_PREFIX" ]]; then
if [[ -z $BREW_LOCATION ]]; then
eval "$(brew shellenv)"
else
eval "$("$BREW_LOCATION" shellenv)"
fi
fi
unset BREW_LOCATION
alias bcubc='brew upgrade --cask && brew cleanup'
alias bcubo='brew update && brew outdated --cask'
alias brewp='brew pin' alias brewp='brew pin'
alias brewsp='brew list --pinned' alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup' alias bubc='brew upgrade && brew cleanup'
alias bubo='brew update && brew outdated'
alias bubu='bubo && bubc' alias bubu='bubo && bubc'
alias buf='brew upgrade --formula' alias buf='brew upgrade --formula'
alias bcubo='brew update && brew outdated --cask'
alias bcubc='brew upgrade --cask && brew cleanup'
function brews() { function brews() {
local formulae="$(brew leaves | xargs brew deps --installed --for-each)" local formulae="$(brew leaves | xargs brew deps --installed --for-each)"