Split always-on PATH/env, login hooks, and interactive UX into a managed tree under ~/.config/zsh, with never-overwrite local/ hooks. Agents and interactive shells share one PATH owner; deploy.sh applies the layout safely across machines.
121 lines
3.5 KiB
Bash
121 lines
3.5 KiB
Bash
# Interactive bootstrap: omz, plugins, personal overlays, completions.
|
|
# PATH is owned by env/00-path.zsh; do not rebuild it here.
|
|
|
|
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
|
# Initialization code that may require console input (password prompts, [y/n]
|
|
# confirmations, etc.) must go above this block; everything else may go below.
|
|
# 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
|
|
|
|
export TERM="xterm-256color"
|
|
|
|
# Skip oh-my-zsh's completion security audit (compaudit). The completion dirs are
|
|
# machine-owned and not group/world-writable, so the per-startup audit only costs time.
|
|
export ZSH_DISABLE_COMPFIX=true
|
|
|
|
# Path to your oh-my-zsh installation.
|
|
export ZSH=$HOME/.oh-my-zsh
|
|
|
|
# Agent/AI terminals (Cursor's agent sets CURSOR_AGENT) get a light, fast theme;
|
|
# interactive shells use powerlevel10k.
|
|
if [[ -n "$CURSOR_AGENT" ]]; then
|
|
ZSH_THEME="robbyrussell"
|
|
else
|
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
|
fi
|
|
|
|
# How often to auto-update (days). Replaces the older UPDATE_ZSH_DAYS variable.
|
|
zstyle ':omz:update' frequency 30
|
|
|
|
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
|
|
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
|
# Add wisely, as too many plugins slow down shell startup.
|
|
plugins=(
|
|
# zsh-completions INSTALL METHOD CHANGED https://github.com/zsh-users/zsh-completions/issues/603
|
|
zsh-autosuggestions
|
|
zsh-syntax-highlighting
|
|
history-substring-search
|
|
systemd
|
|
k
|
|
extract
|
|
sudo
|
|
fzf-tab
|
|
poetry
|
|
# web-search
|
|
# httpie
|
|
# git
|
|
# python
|
|
# docker
|
|
# lol
|
|
# pip
|
|
# pyenv
|
|
# redis-cli
|
|
# screen
|
|
# zsh-wakatime # enable if you use wakatime with 'https://github.com/wbingli/zsh-wakatime'
|
|
)
|
|
# Plugins can be added in ~/.config/zshrc/*.zsh like:
|
|
# plugins+=(zsh-nvm)
|
|
# Remove plugins from the default list with:
|
|
# plugins=(${plugins:#pluginname})
|
|
|
|
fpath+=$ZSH/custom/plugins/zsh-completions/src
|
|
|
|
# Setup Homebrew completions for macOS
|
|
if [[ "$OSTYPE" == "darwin"* ]] && command -v brew &> /dev/null; then
|
|
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
|
|
fi
|
|
|
|
mkdir -p ~/.cache/zsh
|
|
autoload -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump
|
|
|
|
SAVEHIST=50000
|
|
|
|
# CUSTOM FUNCTIONS
|
|
|
|
# cheat sheets (github.com/chubin/cheat.sh)
|
|
cheat() {
|
|
if [ "$2" ]; then
|
|
curl "https://cheat.sh/$1/$2+$3+$4+$5+$6+$7+$8+$9+$10"
|
|
else
|
|
curl "https://cheat.sh/$1"
|
|
fi
|
|
}
|
|
|
|
speedtest() {
|
|
setopt localoptions pipefail
|
|
curl -fsSL https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -
|
|
}
|
|
|
|
dadjoke() {
|
|
curl https://icanhazdadjoke.com
|
|
}
|
|
|
|
# Strip macOS junk from a zip (requires `zip`). Usage: cleanzip archive.zip
|
|
cleanzip() {
|
|
zip -d "$@" __MACOSX/\* \*/.DS_Store
|
|
}
|
|
|
|
# Find geo info from IP
|
|
ipgeo() {
|
|
if [ "$1" ]; then
|
|
curl "https://api.db-ip.com/v2/free/$1"
|
|
else
|
|
curl "https://api.db-ip.com/v2/free/$(myip)"
|
|
fi
|
|
}
|
|
|
|
# Personal / tool overlays under ~/.config/zshrc/ (before oh-my-zsh so plugins apply).
|
|
# Managed interactive code lives in ~/.config/zsh/interactive/; do not put machine
|
|
# secrets here if they need to survive reinstall of managed files.
|
|
ZSH_CONFIGS_DIR="$HOME/.config/zshrc"
|
|
|
|
for file in "$ZSH_CONFIGS_DIR"/*(DN); do
|
|
if [ -f "$file" ]; then
|
|
source "$file"
|
|
fi
|
|
done
|
|
|
|
# Source oh-my-zsh after overlays so plugins+=(…) from ~/.config/zshrc take effect.
|
|
source "$ZSH/oh-my-zsh.sh"
|