feat(shell): add .zshenv Homebrew init and Trash-backed rm

Move brew shellenv into .zshenv so PATH is available outside
interactive shells, and make install guarantee a Trash backend
for safer rm aliases on both macOS and Linux.
This commit is contained in:
mio
2026-07-26 16:28:09 +08:00
parent 17ecc5f67c
commit 9377023e28
4 changed files with 62 additions and 15 deletions
+11 -5
View File
@@ -1,8 +1,3 @@
# Homebrew initialization
if [ -d '/opt/homebrew' ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# 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.
@@ -222,6 +217,17 @@ source "$ZSH/oh-my-zsh.sh"
# Configs that can only work after "source $ZSH/oh-my-zsh.sh", such as Aliases that depend oh-my-zsh plugins
# ponytail: Trash aliases accept paths, not every rm flag; add a wrapper only if flag compatibility is required.
if [[ "$OSTYPE" == darwin* && -x /usr/bin/trash ]]; then
alias rm='/usr/bin/trash'
elif [[ "$OSTYPE" == darwin* ]] && command -v rmtrash &> /dev/null; then
alias rm='rmtrash'
elif [[ "$OSTYPE" != darwin* ]] && command -v gio &> /dev/null; then
alias rm='gio trash'
elif [[ "$OSTYPE" != darwin* ]] && command -v trash-put &> /dev/null; then
alias rm='trash-put'
fi
# Now source fzf.zsh , otherwise Ctr+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})