# zmodload zsh/zprof # ============================================================================= # ZSH Configuration # ============================================================================= # ----------------------------------------------------------------------------- # 1. Homebrew # ----------------------------------------------------------------------------- if [[ -f "/opt/homebrew/bin/brew" ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" fi # ----------------------------------------------------------------------------- # 2. PATH additions (check if directories exist before adding) # ----------------------------------------------------------------------------- typeset -U path # Ensure unique entries in PATH # Local binaries (mise, etc.) [[ -d "$HOME/.local/bin" ]] && path=("$HOME/.local/bin" $path) # Package managers [[ -d "$HOME/Library/pnpm" ]] && export PNPM_HOME="$HOME/Library/pnpm" && path=("$PNPM_HOME" $path) [[ -d "$HOME/.bun/bin" ]] && export BUN_INSTALL="$HOME/.bun" && path=("$BUN_INSTALL/bin" $path) # Optional tools # [[ -d "$HOME/.pkl" ]] && path=("$HOME/.pkl" $path) # [[ -d "$HOME/.git-ai/bin" ]] && path=("$HOME/.git-ai/bin" $path) # [[ -d "$HOME/.npm-global/bin" ]] && path=("$HOME/.npm-global/bin" $path) # [[ -d "$HOME/.opencode/bin" ]] && path=("$HOME/.opencode/bin" $path) export GPG_TTY=$(tty) # ----------------------------------------------------------------------------- # 3. Environment Variables # ----------------------------------------------------------------------------- export EDITOR="zed" export VISUAL="$EDITOR" export LANG="${LANG:-en_US.UTF-8}" # History export HIST_STAMPS="yyyy-mm-dd" export HISTSIZE=50000 export SAVEHIST=50000 export HISTFILE="${HISTFILE:-$HOME/.zsh_history}" # Explicit histfile setopt HIST_VERIFY # Show command before executing from history setopt HIST_REDUCE_BLANKS # Remove superfluous blanks setopt INC_APPEND_HISTORY # Write immediately, not on shell exit setopt EXTENDED_HISTORY setopt HIST_EXPIRE_DUPS_FIRST setopt HIST_IGNORE_DUPS setopt HIST_IGNORE_SPACE setopt SHARE_HISTORY # Quality of Life setopt AUTO_CD # cd by typing directory name setopt AUTO_PUSHD # Push dirs onto stack automatically setopt PUSHD_IGNORE_DUPS # Don't push duplicates setopt INTERACTIVE_COMMENTS # Allow comments in interactive shell setopt NO_BEEP # Disable beep on error # FZF export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --color=border:grey --color=query:cyan" # Lazy-load API keys on first use function __load_api_keys() { export OLLAMA_API_KEY=$(security find-generic-password -a $USER -s ollama_api_key -w 2>/dev/null) export OPENROUTER_API_KEY=$(security find-generic-password -a $USER -s openrouter_api_key -w 2>/dev/null) export OPENCODE_API_KEY=$(security find-generic-password -a $USER -s opencode_api_key -w 2>/dev/null) export RESEND_API_KEY=$(security find-generic-password -a $USER -s resend_api_key -w 2>/dev/null) unfunction __load_api_keys 2>/dev/null } # POP export POP_FROM=jacob@dalamb.me export POP_SIGNATURE="Sent with [Pop](https://github.com/charmbracelet/pop)!" # ----------------------------------------------------------------------------- # 4. Oh My Zsh # ----------------------------------------------------------------------------- export ZSH="$HOME/.oh-my-zsh" # Settings (must be before sourcing oh-my-zsh) zstyle ':omz:update' mode auto zstyle ':omz:plugins:alias-finder' autoload yes zstyle ':omz:plugins:keychain' agents gpg DISABLE_AUTO_TITLE="true" ENABLE_CORRECTION="true" COMPLETION_WAITING_DOTS="true" # Plugins plugins=( aliases brew bun command-not-found eza fzf gh git git-commit history httpie isodate macos node npm python sudo zsh-autosuggestions ) source "$ZSH/oh-my-zsh.sh" # ----------------------------------------------------------------------------- # 5. Tool Initializations (after oh-my-zsh) # ----------------------------------------------------------------------------- (( $+commands[starship] )) && cache_eval "starship" "starship init zsh" (( $+commands[zoxide] )) && cache_eval "zoxide" "zoxide init zsh" (( $+commands[fixit] )) && cache_eval "fixit" "fixit init zsh" [[ -f "$HOME/.atuin/bin/env" ]] && . "$HOME/.atuin/bin/env" (( $+commands[atuin] )) && cache_eval "atuin" "atuin init zsh" (( $+commands[mole] )) && cache_eval "mole" "mole completion zsh" [[ -s "$HOME/.bun/_bun" ]] && source "$HOME/.bun/_bun" # ----------------------------------------------------------------------------- # 6. Aliases # ----------------------------------------------------------------------------- alias pn='pnpm' alias nu='/opt/homebrew/bin/nu' # ----------------------------------------------------------------------------- # 7. Local/Private Configuration (always last) # ----------------------------------------------------------------------------- [[ -f "$HOME/.env.secrets" ]] && source "$HOME/.env.secrets" [[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local" # At the end, before local config # __load_api_keys # zprof