cmc/dotfiles

Using GNU Stow to manage my dotfiles.

clone: git clone https://gitbay.org/cmc/dotfiles.git

main: common/zsh/.zshrc · raw

  1# ==============================================================================
  2# 1. OS-SPECIFIC CONFIGURATION
  3# ==============================================================================
  4
  5if [[ "$(uname)" == "Darwin" ]]; then
  6  # macOS - Check for custom path first, then standard paths
  7  if [ -d "$HOME/Documents/.brew" ]; then
  8    # Custom installation path
  9    BREW_PREFIX="$HOME/Documents/.brew"
 10    # Created by `pipx` on 2026-03-25 16:52:28
 11    export PATH="$PATH:/Users/ccleberg/.local/bin"
 12  elif [ -d "/opt/homebrew" ]; then
 13    # Standard path for Apple Silicon Macs
 14    BREW_PREFIX="/opt/homebrew"
 15  else
 16    # Standard path for Intel Macs
 17    BREW_PREFIX="/usr/local"
 18  fi
 19elif [[ "$(uname)" == "Linux" ]]; then
 20  # Linux (Linuxbrew)
 21  BREW_PREFIX="/home/linuxbrew/.linuxbrew"
 22fi
 23
 24# If a Homebrew installation was found, add it to the shell environment
 25if [ -n "$BREW_PREFIX" ]; then
 26  eval "$($BREW_PREFIX/bin/brew shellenv)"
 27fi
 28
 29# ==============================================================================
 30# 2. PRE-INITIALIZATION (Instant Prompt)
 31# ==============================================================================
 32
 33if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
 34  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
 35fi
 36
 37# ==============================================================================
 38# 3. ENVIRONMENT VARIABLES & PATH
 39# ==============================================================================
 40
 41export PATH="$HOME/.local/xonsh-env/xbin:$PATH"
 42export GOPATH=$HOME/go
 43export PATH=$PATH:$GOPATH/bin
 44export PATH="$BREW_PREFIX/bin:$PATH"
 45export GPG_TTY=$(tty)
 46
 47# borgbackup
 48if [[ "$(uname)" == "Linux" ]]; then
 49  export BORG_CACHE_DIR="/tank/borg-cache"
 50  mkdir -p /tank/borg-cache
 51fi
 52
 53# NVM Configuration
 54export NVM_DIR="$HOME/.nvm"
 55NVM_SH_PATH="$BREW_PREFIX/opt/nvm/nvm.sh"
 56
 57_load_nvm() {
 58  unset -f nvm node npm npx
 59  [[ -s "$NVM_SH_PATH" ]] && source "$NVM_SH_PATH"
 60}
 61
 62nvm() {
 63  _load_nvm
 64  nvm "$@"
 65}
 66
 67node() {
 68  _load_nvm
 69  node "$@"
 70}
 71
 72npm() {
 73  _load_nvm
 74  npm "$@"
 75}
 76
 77npx() {
 78  _load_nvm
 79  npx "$@"
 80}
 81
 82# History Settings
 83HISTFILE=~/.histfile
 84HISTSIZE=30000
 85SAVEHIST=30000
 86setopt SHARE_HISTORY
 87setopt HIST_IGNORE_ALL_DUPS
 88setopt HIST_IGNORE_SPACE
 89setopt HIST_REDUCE_BLANKS
 90
 91# ==============================================================================
 92# 4. COMPLETION & UI SETTINGS
 93# ==============================================================================
 94
 95bindkey -e
 96zstyle :compinstall filename "$HOME/.zshrc"
 97autoload -Uz compinit
 98compinit -C
 99
100# p10k
101P10K_THEME_PATH="$BREW_PREFIX/share/powerlevel10k/powerlevel10k.zsh-theme"
102if [[ -f "$P10K_THEME_PATH" ]]; then
103  source "$P10K_THEME_PATH"
104fi
105[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
106
107# ==============================================================================
108# 5. ALIASES
109# ==============================================================================
110
111alias l='eza -lah --icons --git --group-directories-first --header'
112alias cd="z"
113alias cat="bat --paging=never"
114alias mkdir="mkdir -p"
115alias grep="rg"
116alias find="fd"
117alias emacs="emacs -nw"
118alias xclean="fd -H '.DS_Store' -t f -x rm"
119alias python="python3"
120alias docker-update='for d in ~/docker/*/; do (cd "$d" && sudo docker compose pull && sudo docker compose up -d); done'
121alias doom="~/.config/emacs/bin/doom"
122
123# Git
124alias g='git'
125alias gs='git status'
126alias ga='git add'
127alias gaa='git add --all'
128alias gc='git commit -v'
129alias gcm='git commit -m'
130alias gca='git commit --amend --no-edit'
131alias gb='git branch'
132alias gco='git checkout'
133alias gcob='git checkout -b'
134alias gma='git checkout main'
135
136# ==============================================================================
137# 6. PLUGINS (Must be loaded after aliases for best results)
138# ==============================================================================
139
140# Zsh Autosuggestions
141ZSH_AUTOSUGGESTIONS_PATH="$BREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
142if [[ -f "$ZSH_AUTOSUGGESTIONS_PATH" ]]; then
143  source "$ZSH_AUTOSUGGESTIONS_PATH"
144fi
145
146# Syntax Highlighting
147ZSH_SYNTAX_HIGHLIGHTING_PATH="$BREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
148if [[ -f "$ZSH_SYNTAX_HIGHLIGHTING_PATH" ]]; then
149  source "$ZSH_SYNTAX_HIGHLIGHTING_PATH"
150fi
151
152# ==============================================================================
153# 7. SYNTAX HIGHLIGHTING CUSTOMIZATION
154# ==============================================================================
155
156# Must be defined AFTER the plugin is sourced
157# Colors available: black, red, green, yellow, blue, magenta, cyan, white
158# Styles: bold, underline
159
160ZSH_HIGHLIGHT_STYLES[alias]='fg=cyan,bold'
161ZSH_HIGHLIGHT_STYLES[command]='fg=green'
162ZSH_HIGHLIGHT_STYLES[builtin]='fg=magenta'
163ZSH_HIGHLIGHT_STYLES[path]='fg=white,underline'
164ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red,bold'
165
166# zoxide
167eval "$(zoxide init zsh)"
168
169# bun completions
170[ -s "/Users/cmc/.bun/_bun" ] && source "/Users/cmc/.bun/_bun"
171
172# bun
173export BUN_INSTALL="$HOME/.bun"
174export PATH="$BUN_INSTALL/bin:$PATH"
175
176alias claude-mem='/Users/cmc/.bun/bin/bun "/Users/cmc/.claude/plugins/marketplaces/thedotmack/plugin/scripts/worker-service.cjs"'
177
178# openssl
179export PATH="${HOMEBREW_PREFIX}/opt/openssl/bin:$PATH"
180export PATH="$HOME/.local/bin:$PATH"
181
182# Rust / cargo binaries
183export PATH="$HOME/.cargo/bin:$PATH"