dotfiles/.zshrc
ilia 78f7874055
All checks were successful
CI / skip-ci-check (pull_request) Successful in 19s
CI / secret-scan (pull_request) Successful in 17s
Sync live zsh + Cursor pack for family Macs
Bring .zshrc up to the current machine config (portable paths), ship
homelab/ansible shell helpers, shared Cursor rules/skills, and an
install.sh so Irina can clone and run ./install.sh --ira.
2026-07-26 16:00:43 -04:00

159 lines
4.9 KiB
Bash

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Path to your Oh My Zsh installation.
export ZSH="${ZSH:-$HOME/.oh-my-zsh}"
# Optional Node via nvm (Homebrew or ~/.nvm)
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
source "$NVM_DIR/nvm.sh"
elif command -v brew >/dev/null 2>&1; then
_nvm_prefix="$(brew --prefix nvm 2>/dev/null)" || true
[[ -n "$_nvm_prefix" && -s "$_nvm_prefix/nvm.sh" ]] && source "$_nvm_prefix/nvm.sh"
unset _nvm_prefix
fi
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(
git
z
sudo
extract
command-not-found
dirhistory
web-search
zsh-autosuggestions
zsh-syntax-highlighting
zsh-history-substring-search
)
[[ -f "$ZSH/oh-my-zsh.sh" ]] && source "$ZSH/oh-my-zsh.sh"
# Prompt theme (shipped in this repo as .p10k.zsh)
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# pnpm
export PNPM_HOME="${PNPM_HOME:-$HOME/Library/pnpm}"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) [[ -d "$PNPM_HOME" ]] && export PATH="$PNPM_HOME:$PATH" ;;
esac
command -v direnv >/dev/null 2>&1 && eval "$(direnv hook zsh)"
[[ -f ~/.fzf.zsh ]] && source ~/.fzf.zsh
# Optional local tools (skip quietly if missing)
[[ -x "/Applications/LibreOffice.app/Contents/MacOS/soffice" ]] && \
alias libreoffice="/Applications/LibreOffice.app/Contents/MacOS/soffice"
[[ -x "$HOME/Documents/code/free-claude-code/claude-pick" ]] && \
alias ccode="$HOME/Documents/code/free-claude-code/claude-pick"
[[ -f "$HOME/Documents/code/hermes/scripts/hermes-mac.zsh" ]] && \
source "$HOME/Documents/code/hermes/scripts/hermes-mac.zsh"
# ── Custom aliases ───────────────────────────────────────────────────────────
alias reload="source ~/.zshrc && echo 'ZSH config reloaded from ~/.zshrc'"
alias editrc="${EDITOR:-nano} ~/.zshrc"
alias c="clear"
alias cls="clear"
if [[ "$OSTYPE" == darwin* ]]; then
alias ls="ls -G"
else
alias ls="ls --color=auto"
fi
alias l="ls -lah"
alias ll="ls -lah"
alias la="ls -A"
alias md="mkdir -p"
alias grep="grep --color=auto"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias cd..="cd .."
alias h="cd ~"
alias cdc="cd ~/Documents/code"
alias df="df -h"
alias du="du -h"
alias ps="ps aux"
alias cpu="lscpu 2>/dev/null || sysctl -a | grep -E 'cpu|machdep'"
alias top="btop 2>/dev/null || top"
alias ports="lsof -nP -iTCP -sTCP:LISTEN 2>/dev/null || ss -tulpn"
if [[ "$OSTYPE" == darwin* ]]; then
alias free="vm_stat"
alias mem="vm_stat"
alias localip="ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1"
else
alias free="free -h"
alias mem="free -m"
alias localip="ip route get 1.2.3.4 | awk '{print \$7}'"
alias ports="ss -tulpn"
fi
alias myip="curl -s http://ipecho.net/plain; echo"
alias py="python3"
alias pip="pip3"
alias venv="python3 -m venv"
alias activate="source venv/bin/activate"
alias d="docker"
alias dc="docker compose"
alias dcu="docker compose up -d"
alias dcd="docker compose down"
alias dcb="docker compose build"
alias dps="docker ps"
alias di="docker images"
alias now="date +'%Y-%m-%d %H:%M:%S'"
alias today="date +'%Y-%m-%d'"
if command -v apt >/dev/null 2>&1; then
alias update="sudo apt update && sudo apt upgrade -y"
alias install="sudo apt install"
alias remove="sudo apt remove"
alias search="apt search"
fi
alias chmox="chmod +x"
alias own="sudo chown -R $USER:$USER"
# Safety nets — prompt before delete/overwrite
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias nfresh="rm -rf node_modules/ package-lock.json && npm install"
# Homelab / ansible shortcuts (no-op helpers if ansible not cloned)
export ANSIBLE_DIR="${ANSIBLE_DIR:-$HOME/Documents/code/ansible}"
export PERSONAL_SCRIPTS_DIR="${PERSONAL_SCRIPTS_DIR:-$HOME/Documents/code/personal-scripts}"
export LEVKIN_DIR="${LEVKIN_DIR:-$HOME/Documents/code/levkin}"
_DOTFILES_DIR="${DOTFILES_DIR:-}"
if [[ -z "$_DOTFILES_DIR" ]]; then
if [[ -L "$HOME/.zshrc" ]]; then
_link="$(readlink "$HOME/.zshrc")"
[[ "$_link" != /* ]] && _link="$HOME/$_link"
_DOTFILES_DIR="$(cd "$(dirname "$_link")" && pwd)"
unset _link
elif [[ -n "${(%):-%x}" ]]; then
# When sourced from a real file path
_DOTFILES_DIR="$(cd "$(dirname "${(%):-%x}")" && pwd)"
fi
fi
# Fallbacks if install put the repo in the usual place
[[ -z "$_DOTFILES_DIR" && -f "$HOME/Documents/code/dotfiles/zsh/homelab.zsh" ]] && _DOTFILES_DIR="$HOME/Documents/code/dotfiles"
[[ -n "$_DOTFILES_DIR" && -f "$_DOTFILES_DIR/zsh/homelab.zsh" ]] && source "$_DOTFILES_DIR/zsh/homelab.zsh"
# Machine-local overrides (gitignored when living in the repo; usually ~/.zshrc.local)
[[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local"