From 4d3379c69f2d36d9b831dfdd7043e3f6921024ea Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Tue, 16 Nov 2021 12:48:20 -0800 Subject: [PATCH] make brew work on the m1 --- runcoms/zshenv | 10 +++++----- runcoms/zshrc | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/runcoms/zshenv b/runcoms/zshenv index 16057a7..f065c52 100644 --- a/runcoms/zshenv +++ b/runcoms/zshenv @@ -10,8 +10,6 @@ if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; t source "${ZDOTDIR:-$HOME}/.zprofile" fi -export PATH="$HOME/.dotfiles/bin:$HOME/.cargo/bin:/usr/local/bin:$HOME/.local/bin:$PATH" - if command -v brew &> /dev/null; then if [[ -s `brew --prefix`/share/chruby/chruby.sh ]]; then source `brew --prefix`/share/chruby/chruby.sh @@ -23,6 +21,8 @@ if command -v direnv &> /dev/null; then eval "$(direnv hook zsh)" fi -if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh; fi -if [ -e /Users/alpha/.nix-profile/etc/profile.d/nix.sh ]; then . /Users/alpha/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer -. "$HOME/.cargo/env" +if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi +if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/etc/profile.d/nix.sh; fi # added by Nix installer +if [ -e $HOME/.cargo/env ]; then . "$HOME/.cargo/env"; fi + +export PATH="$HOME/.dotfiles/bin:$HOME/.local/bin:$PATH" diff --git a/runcoms/zshrc b/runcoms/zshrc index 959d460..22de256 100644 --- a/runcoms/zshrc +++ b/runcoms/zshrc @@ -33,20 +33,28 @@ alias tmux="direnv exec / tmux" function eject { command hdiutil eject `df | grep Volumes | grep -i "$@" | ruby -ne 'puts $_[/^[^ ]*/]'`; } +if [ -e /opt/homebrew/bin/brew ]; then + eval "$(/opt/homebrew/bin/brew shellenv)" +fi +if [ -e /usr/local/bin/brew ]; then + eval "$(/usr/local/bin/brew shellenv)" +fi +brew_prefix=$(brew --prefix) + if [ $commands[chruby] ]; then chruby ruby fi [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -if [ -e /usr/local/opt/fzf/shell/completion.zsh ]; then - source /usr/local/opt/fzf/shell/key-bindings.zsh - source /usr/local/opt/fzf/shell/completion.zsh +if [ -e $brew_prefix/opt/fzf/shell/completion.zsh ]; then + source $brew_prefix/opt/fzf/shell/key-bindings.zsh + source $brew_prefix/opt/fzf/shell/completion.zsh fi -if [ -e /usr/local/bin/terraform ]; then +if [ -e $brew_prefix/bin/terraform ]; then autoload -U +X bashcompinit && bashcompinit - complete -o nospace -C /usr/local/bin/terraform terraform + complete -o nospace -C $brew_prefix/bin/terraform terraform fi if [ $commands[fzf] ]; then