From 9b24b09040453ea2e94a61ce543616accb05b7c1 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 23 Jan 2023 18:05:14 +0000 Subject: [PATCH] adopt for homebrew path --- bin/install.sh | 6 +++--- exports | 45 ++++++++++++++++++++++++++++++--------------- gitconfig | 15 ++++++++------- zshrc | 12 +++++++++--- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/bin/install.sh b/bin/install.sh index f6dccf4..ee7ccaa 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -54,9 +54,9 @@ echo " ✓ done$(tput sgr0)" # ---------------------------------------------------------------------- # Switch to using brew-installed zsh as default shell -if ! grep -F -q '/usr/local/bin/zsh' /etc/shells; then - echo '/usr/local/bin/zsh' | sudo tee -a /etc/shells; - chsh -s /usr/local/bin/zsh; +if ! grep -F -q '/opt/homebrew/bin/zsh' /etc/shells; then + echo '/opt/homebrew/bin/zsh' | sudo tee -a /etc/shells; + chsh -s /opt/homebrew/bin/zsh; fi; echo "$(tput setaf 64)=============================================" diff --git a/exports b/exports index 3282b3d..00e83ef 100644 --- a/exports +++ b/exports @@ -8,35 +8,50 @@ export LANG="en_US" # PATH # --------------------------------------------------- -PATH_OPENSSL=/usr/local/opt/openssl/bin +# Homebrew path differs between Intel/Apple Silicon +# See https://apple.stackexchange.com/questions/437618/why-is-homebrew-installed-in-opt-homebrew-on-apple-silicon-macs +# Hardcoded paths because `brew --prefix ...` is slow +if [[ $(uname -m) == 'arm64' ]]; then + PATH_HOMEBREW=/opt/homebrew +else + PATH_HOMEBREW=/usr/local +fi + +PATH_OPENSSL=$PATH_HOMEBREW/opt/openssl/bin # PATH_RUBY=$(brew --prefix ruby)/bin -# PATH_GEMS=/usr/local/lib/ruby/gems/2.6.0/bin -PATH_PYTHON=/usr/local/opt/python/libexec/bin -PATH_GO=/usr/local/opt/go/libexec/bin +# PATH_GEMS=$PATH_HOMEBREW/lib/ruby/gems/2.6.0/bin +PATH_PYTHON=$PATH_HOMEBREW/opt/python/libexec/bin +PATH_GO=$PATH_HOMEBREW/opt/go/libexec/bin #PATH_RUST=$HOME/.cargo/bin export GOPATH=$HOME/.go/ -export PATH=$HOME/.bin:/usr/local/bin:$PATH_OPENSSL:$PATH_PYTHON:$GOPATH/bin:$PATH_GO:$PATH +export PATH=$HOME/.bin:/$PATH_HOMEBREW/bin:$PATH_OPENSSL:$PATH_PYTHON:$GOPATH/bin:$PATH_GO:$PATH # define CDPATHs which are autocompleted from when doing cd export CDPATH=$CDPATH:~/Code # nvm +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + # defer loading until needed for faster shell startup -declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`) +#declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`) -NODE_GLOBALS+=("node") -NODE_GLOBALS+=("nvm") +#NODE_GLOBALS+=("node") +#NODE_GLOBALS+=("nvm") -load_nvm () { - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -} +#load_nvm () { +# export NVM_DIR="$HOME/.nvm" +# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +#} -for cmd in "${NODE_GLOBALS[@]}"; do - eval "${cmd}(){ unset -f ${NODE_GLOBALS}; load_nvm; ${cmd} \$@ }" -done +#for cmd in "${NODE_GLOBALS[@]}"; do +# eval "${cmd}(){ unset -f ${NODE_GLOBALS}; load_nvm; ${cmd} \$@ }" +#done # pip should only run if there is a virtualenv currently activated export PIP_REQUIRE_VIRTUALENV=true # cache pip-installed packages to avoid re-downloading export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache + +export GPG_TTY=$(tty) + diff --git a/gitconfig b/gitconfig index 94ebdfd..aa4a0db 100644 --- a/gitconfig +++ b/gitconfig @@ -10,7 +10,7 @@ [user] name = Matthias Kretschmann email = m@kretschmann.io - signingKey = DD7831FC + signingKey = BD3C1F3EDD7831FC [commit] gpgSign = true @@ -60,6 +60,12 @@ [fetch] prune = true +[pull] + rebase = false + +[init] + defaultBranch = main + [status] showUntrackedFiles = all @@ -89,9 +95,4 @@ clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process -[pull] - rebase = false -[gpg] - program = /usr/local/bin/gpg -[init] - defaultBranch = main + diff --git a/zshrc b/zshrc index f1255ae..0e1fad6 100644 --- a/zshrc +++ b/zshrc @@ -80,8 +80,14 @@ if [[ $#h -gt 0 ]]; then zstyle ':completion:*:(ssh|scp|rsync|slogin):*' hosts $h fi -source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh +if [[ $(uname -m) == 'arm64' ]]; then + PATH_HOMEBREW=/opt/homebrew +else + PATH_HOMEBREW=/usr/local +fi + +source $PATH_HOMEBREW/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +source $PATH_HOMEBREW/share/zsh-autosuggestions/zsh-autosuggestions.zsh # source <(kubectl completion zsh) # @@ -93,4 +99,4 @@ source ~/.exports source ~/.aliases source ~/.private -# zprof +# zprof \ No newline at end of file