refactor(shell): thin stubs with managed ~/.config/zsh tree

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.
This commit is contained in:
Jeffrey
2026-08-06 14:36:08 +08:00
parent ed5365859c
commit f8dcc29a2f
14 changed files with 546 additions and 391 deletions
+70
View File
@@ -0,0 +1,70 @@
# Runs after oh-my-zsh so these aliases win over omz defaults.
alias myip="wget -qO- https://wtfismyip.com/text"
alias l="eza --hyperlink -lA --sort=modified --reverse --classify"
alias e="exit"
alias ip="ip --color=auto"
## EZA - the better ls command
alias a='eza -la --git --colour-scale all -g --smart-group --icons always --hyperlink'
alias aa='eza -la --git --colour-scale all -g --smart-group --icons always -s modified -r --hyperlink'
# rm moves files to Trash while tolerating standard rm flags: -f suppresses
# missing-file errors; other flags are no-ops (trash backends are already
# recursive). Files whose names start with "-" still need /bin/rm.
# Shell snapshots (Claude Code etc.) restore functions but not global arrays,
# so rm() re-resolves the backend when _TRASH_CMD is empty at call time.
_resolve_trash_cmd() {
if [[ "$OSTYPE" == darwin* && -x /usr/bin/trash ]]; then
typeset -ga _TRASH_CMD=(/usr/bin/trash)
elif [[ "$OSTYPE" == darwin* ]] && command -v rmtrash &> /dev/null; then
typeset -ga _TRASH_CMD=(rmtrash)
elif [[ "$OSTYPE" != darwin* ]] && command -v gio &> /dev/null; then
typeset -ga _TRASH_CMD=(gio trash)
elif [[ "$OSTYPE" != darwin* ]] && command -v trash-put &> /dev/null; then
typeset -ga _TRASH_CMD=(trash-put)
fi
}
_resolve_trash_cmd
if (( ${#_TRASH_CMD[@]} )); then
rm() {
(( ${#_TRASH_CMD[@]} )) || _resolve_trash_cmd
(( ${#_TRASH_CMD[@]} )) || { command rm "$@"; return }
local force=0 arg
local -a paths existing
for arg in "$@"; do
case "$arg" in
--) ;;
-*f*) force=1 ;;
-*) ;;
*) paths+=("$arg") ;;
esac
done
(( ${#paths[@]} )) || return 0
if (( force )); then
for arg in "${paths[@]}"; do
[[ -e "$arg" || -L "$arg" ]] && existing+=("$arg")
done
(( ${#existing[@]} )) || return 0
"${_TRASH_CMD[@]}" "${existing[@]}"
else
"${_TRASH_CMD[@]}" "${paths[@]}"
fi
}
fi
# Now source fzf.zsh , otherwise Ctrl+r is overwritten by ohmyzsh
if [[ -x "$HOME/.fzf/bin/fzf" ]] && ! fzf --zsh >/dev/null 2>&1; then
path=("$HOME/.fzf/bin" ${path:#$HOME/.fzf/bin})
fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_OPS="--extended"
# Initialize zoxide (smarter cd command)
command -v zoxide &> /dev/null && eval "$(zoxide init zsh)"
# Short jump alias; expands at use time after zoxide defines `z`.
alias j="z"
# k plugin ships a `k` function; only alias when it actually loaded.
if (( $+functions[k] )); then
alias k="k -h"
fi