Skip to content

Commit

Permalink
Move $PATH and ENV exports to top of file
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
0xmachos committed Aug 10, 2024
1 parent 684b703 commit b79b796
Showing 1 changed file with 55 additions and 54 deletions.
109 changes: 55 additions & 54 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b79b796

Please sign in to comment.