From b79b7968166df0238df8aa61e975b9bcecbabf06 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Sat, 10 Aug 2024 13:48:27 +0100 Subject: [PATCH] Move $PATH and ENV exports to top of file - We need to build $PATH properly before we do other setup - With the previous order FPATH=$(brew --prefix)/share/zsh-completions:$FPATH was failing because eval "$(/opt/homebrew/bin/brew shellenv)" was after the invocation of brew - This lead to all zsh completions failing to be loaded --- .zshrc | 109 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/.zshrc b/.zshrc index e0f59a0..3a7146e 100644 --- a/.zshrc +++ b/.zshrc @@ -15,7 +15,57 @@ ### Constants #### -readonly INITIAL_DIR="${HOME}/Documents/Projects" +INITIAL_DIR="${HOME}/Documents/Projects" + + +### Homebrew ### + +eval "$(/opt/homebrew/bin/brew shellenv)" +# Add Homebrew to PATH + + +### Enviroment Variable Exports ### + +if [[ -x "/usr/local/bin/brew" ]]; then + export HOMEBREW_BREWFILE=$HOME/Documents/Projects/dotfiles/.extra/Brewfile + # Set location of Brewfile +fi + +if [[ -x "/usr/local/opt/ruby/bin/ruby" ]]; then + export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH" + # macOS ships with a version of Ruby at /usr/bin/ruby + # /usr/bin also contains versions of gem and bundler + # We need these ruby paths at the front of $PATH to override the default installed ruby bianries + # At some point in the future Apple will remove scripting language runtimes so this will need revised + # https://tidbits.com/2019/06/25/apple-to-deprecate-scripting-languages-in-future-versions-of-macos/ +fi + +if [[ -x "$(command -v go)" ]]; then + export GOPATH=$HOME/Documents/Projects/go + export PATH=$PATH:$GOPATH/bin + # Go +fi + +if [[ -x "/usr/local/bin/python3" && -x "$HOME/Library/Python/3.9/bin/virtualenv" ]]; then + # Should the second check be "$HOME/Library/Python/*/bin/virtualenv" this will need manually + # changed when python moves to version 4.x + + export PATH=$PATH:$HOME/Library/Python/3.9/bin + # Required for virtualenv as installed by pip + # pip3 show virtualenv +fi + + +if [[ -d "/Applications/Secretive.app" ]]; then + export SSH_AUTH_SOCK=$HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh +fi + + +export IIOEnableOOP=YES +# Enabled the undocumeted ImageIO sandbox +# Tells ImageIO to parse images our of process in the ImageIOXPCService process instead +# https://rtx.meta.security/mitigation/2023/09/11/Sandboxing-ImageIO-in-macOS.html + ### Prompt ### @@ -82,11 +132,11 @@ unsetopt case_glob # If “zsh compinit: insecure directories” run # chmod -R go-w "$(brew --prefix)/share" if type brew &>/dev/null; then - FPATH=$(brew --prefix)/share/zsh-completions:$FPATH + FPATH=$(brew --prefix)/share/zsh-completions:$FPATH - autoload -Uz compinit - compinit - fi + autoload -Uz compinit + compinit +fi # Case insensitive path-completion zstyle ':completion:*' matcher-list 'm: @@ -153,55 +203,6 @@ setopt HIST_IGNORE_SPACE # Do not store command lines starting with a space -### Homebrew ### - -eval "$(/opt/homebrew/bin/brew shellenv)" -# Add Homebrew to PATH - - -### Enviroment Variable Exports ### - -if [[ -x "/usr/local/bin/brew" ]]; then - export HOMEBREW_BREWFILE=$HOME/Documents/Projects/dotfiles/.extra/Brewfile - # Set location of Brewfile -fi - -if [[ -x "/usr/local/opt/ruby/bin/ruby" ]]; then - export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH" - # macOS ships with a version of Ruby at /usr/bin/ruby - # /usr/bin also contains versions of gem and bundler - # We need these ruby paths at the front of $PATH to override the default installed ruby bianries - # At some point in the future Apple will remove scripting language runtimes so this will need revised - # https://tidbits.com/2019/06/25/apple-to-deprecate-scripting-languages-in-future-versions-of-macos/ -fi - -if [[ -x "$(command -v go)" ]]; then - export GOPATH=$HOME/Documents/Projects/go - export PATH=$PATH:$GOPATH/bin - # Go -fi - -if [[ -x "/usr/local/bin/python3" && -x "$HOME/Library/Python/3.9/bin/virtualenv" ]]; then - # Should the second check be "$HOME/Library/Python/*/bin/virtualenv" this will need manually - # changed when python moves to version 4.x - - export PATH=$PATH:$HOME/Library/Python/3.9/bin - # Required for virtualenv as installed by pip - # pip3 show virtualenv -fi - - -if [[ -d "/Applications/Secretive.app" ]]; then - export SSH_AUTH_SOCK=$HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh -fi - - -export IIOEnableOOP=YES -# Enabled the undocumeted ImageIO sandbox -# Tells ImageIO to parse images our of process in the ImageIOXPCService process instead -# https://rtx.meta.security/mitigation/2023/09/11/Sandboxing-ImageIO-in-macOS.html - - ### Change into Inital Directory ### if [[ -d "${INITIAL_DIR}" ]]; then