Last active
July 28, 2026 18:50
-
-
Save grantvanhorn/3e7da9d25bb10f3736d863dad43ba7ef to your computer and use it in GitHub Desktop.
[macOS] .zshrc — zinit plugins, eza aliases, nvm auto-switch, starship (part of setup-macos.sh flow)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================= | |
| # .zshrc — zsh shell configuration (macOS) | |
| # ============================================================================= | |
| # Installed by setup-macos.sh, but you can drop it in manually: | |
| # Destination: ~/.zshrc (then: exec zsh — or open a new terminal) | |
| # | |
| # REQUIREMENTS (Homebrew — https://brew.sh): | |
| # brew install starship eza | |
| # brew install --cask font-roboto-mono-nerd-font | |
| # - zinit (plugin manager) auto-installs itself + the plugins on first run. | |
| # - macOS ships zsh as the default shell. | |
| # - nvm is OPTIONAL (block below is guarded and no-ops if absent). | |
| # | |
| # The prompt is Starship (enabled at the bottom). Syntax-highlighting + | |
| # autosuggestions come from zinit — no OS-specific plugin paths needed. | |
| # ============================================================================= | |
| # Put Homebrew on PATH so brew-installed tools (starship, eza, nvim, tmux, node) | |
| # are found in every interactive shell. Apple Silicon uses /opt/homebrew; older | |
| # Intel Macs use /usr/local. Must come before anything that calls those tools. | |
| if [[ -x /opt/homebrew/bin/brew ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" | |
| elif [[ -x /usr/local/bin/brew ]]; then eval "$(/usr/local/bin/brew shellenv)"; fi | |
| setopt PROMPT_SUBST | |
| # zinit manual installation | |
| ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" | |
| [ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)" | |
| [ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" | |
| source "${ZINIT_HOME}/zinit.zsh" | |
| # PATH exports | |
| export PATH="$HOME/.local/bin:$PATH" | |
| # Aliases (use eza — `brew install eza`) | |
| alias ls='eza -l --git --header --time-style=long-iso --sort=type' | |
| alias ll='eza -laga --git --header --time-style=long-iso --sort=type' | |
| alias zsource="source ~/.zshrc" | |
| # Setup history | |
| HISTFILE=~/.history | |
| HISTSIZE=10000 | |
| SAVEHIST=50000 | |
| # The prompt is Starship — enabled at the bottom of this file. (Starship's init | |
| # must stay LAST so nothing overrides its PROMPT/precmd hooks.) | |
| # nvm (OPTIONAL; expected at ~/.nvm). If you use `brew install nvm` instead, | |
| # point NVM_DIR/source at "$(brew --prefix nvm)". Guarded, so it no-ops if absent. | |
| export NVM_DIR="$HOME/.nvm" | |
| set -h | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
| set +h | |
| # Auto-switch Node version based on .nvmrc (only when nvm is loaded) | |
| if typeset -f nvm_find_nvmrc > /dev/null 2>&1; then | |
| autoload -Uz add-zsh-hook | |
| load-nvmrc() { | |
| local nvmrc_path | |
| nvmrc_path="$(nvm_find_nvmrc)" | |
| if [ -n "$nvmrc_path" ]; then | |
| local nvmrc_node_version | |
| nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
| if [ "$nvmrc_node_version" = "N/A" ]; then | |
| nvm install | |
| elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then | |
| nvm use | |
| fi | |
| elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then | |
| echo "Reverting to nvm default version" | |
| nvm use default | |
| fi | |
| } | |
| add-zsh-hook chpwd load-nvmrc | |
| load-nvmrc | |
| fi | |
| zinit light zsh-users/zsh-autosuggestions | |
| zinit light zsh-users/zsh-syntax-highlighting | |
| zinit light zsh-users/zsh-completions | |
| zinit light agkozak/zsh-z | |
| # Syntax highlighting colors (set after plugin loads) | |
| ZSH_HIGHLIGHT_STYLES[command]='fg=#00FF00,bold' | |
| ZSH_HIGHLIGHT_STYLES[alias]='fg=#00FFFF,bold' | |
| ZSH_HIGHLIGHT_STYLES[builtin]='fg=#00FF00,bold' | |
| ZSH_HIGHLIGHT_STYLES[arg0]='fg=#00FF00,bold' | |
| ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#FF0000,bold' | |
| ZSH_HIGHLIGHT_STYLES[precommand]='fg=#FF00FF,bold' | |
| ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#FF00FF,bold' | |
| ZSH_HIGHLIGHT_STYLES[global-alias]='fg=#00FFFF,bold' | |
| ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=#00FFFF,bold' | |
| ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=#04C5F0' | |
| ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=#04C5F0' | |
| ZSH_HIGHLIGHT_STYLES[path]='fg=#ff7f41,underline' | |
| ZSH_HIGHLIGHT_STYLES[globbing]='fg=#00FFFF,bold' | |
| ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=#ffbe74,bold' | |
| ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=#ffbe74,bold' | |
| ZSH_HIGHLIGHT_STYLES[redirection]='fg=#FFFFFF,bold' | |
| ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=#FFFFFF,bold' | |
| ZSH_HIGHLIGHT_STYLES[assign]='fg=#FFFFFF' | |
| ZSH_HIGHLIGHT_STYLES[comment]='fg=#888888' | |
| # enable starship | |
| eval "$(starship init zsh)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment