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:
+16
-2
@@ -44,16 +44,19 @@ fi
|
||||
main_bin="$TEMP_DIR/main-bin"
|
||||
main_home="$TEMP_DIR/main-home"
|
||||
mkdir -p "$main_bin" "$main_home"
|
||||
for command_name in zsh git curl tar fc-cache eza zoxide autoconf; do
|
||||
for command_name in zsh git curl tar fc-cache eza zoxide autoconf trash; do
|
||||
ln -s /usr/bin/true "$main_bin/$command_name"
|
||||
done
|
||||
ln -s /usr/bin/false "$main_bin/wget"
|
||||
cp "$ROOT/README.md" "$main_home/.zshrc"
|
||||
printf '%s\n' 'existing-zshenv' >"$main_home/.zshenv"
|
||||
if HOME="$main_home" PATH="$main_bin:/usr/bin:/bin" /bin/bash "$ROOT/install.sh" --non-interactive >/dev/null 2>&1; then
|
||||
fail "install.sh returned success after the zshrc download failed"
|
||||
fi
|
||||
cmp -s "$ROOT/README.md" "$main_home/.zshrc" ||
|
||||
fail "install.sh replaced .zshrc after its download failed"
|
||||
printf '%s\n' 'existing-zshenv' | cmp -s - "$main_home/.zshenv" ||
|
||||
fail "install.sh replaced .zshenv after a download failed"
|
||||
|
||||
fnm_home="$TEMP_DIR/fnm-home"
|
||||
mkdir -p "$fnm_home/.local/share/fnm"
|
||||
@@ -65,7 +68,7 @@ for script in "$ROOT"/*.sh; do
|
||||
bash -n "$script"
|
||||
done
|
||||
|
||||
for config in "$ROOT/.zshrc" "$ROOT"/zshrc/*.zsh; do
|
||||
for config in "$ROOT/.zshenv" "$ROOT/.zshrc" "$ROOT"/zshrc/*.zsh; do
|
||||
zsh -n "$config"
|
||||
done
|
||||
|
||||
@@ -73,10 +76,21 @@ grep -q 'NVM_VERSION="v0.40.4"' "$ROOT/install_nvm.sh" || fail "nvm version is s
|
||||
grep -q 'apt-get install -y unzip' "$ROOT/install_fnm.sh" || fail "Ubuntu unzip installation is missing"
|
||||
grep -q 'tail -1 || true' "$ROOT/install_merlin_worker.sh" || fail "a missing PYTHONPATH remains fatal"
|
||||
grep -Fq 'mktemp "$HOME/.zshrc.download.' "$ROOT/install.sh" || fail ".zshrc is not downloaded on its target filesystem"
|
||||
grep -Fq 'mktemp "$HOME/.zshenv.download.' "$ROOT/install.sh" || fail ".zshenv is not downloaded on its target filesystem"
|
||||
grep -Fq 'mktemp "$HOME/.config/.easyzsh-' "$ROOT/patch.sh" || fail "patch downloads can be sourced while incomplete"
|
||||
grep -Fq '"$ZSH_CONFIGS_DIR"/*(DN)' "$ROOT/.zshrc" || fail "existing extensionless Zsh configs are ignored"
|
||||
grep -Fq "alias rm='/usr/bin/trash'" "$ROOT/.zshrc" || fail "macOS rm does not use the native Trash"
|
||||
grep -Fq "alias rm='gio trash'" "$ROOT/.zshrc" || fail "Linux rm does not use the desktop Trash"
|
||||
grep -Fq 'libglib2.0-bin' "$ROOT/install.sh" || fail "Ubuntu Trash support is not installed"
|
||||
grep -Fq 'cp -Pp "$HOME/.zshrc"' "$ROOT/install.sh" || fail ".zshrc symlinks are not preserved in backups"
|
||||
grep -Fq '[ -L "$HOME/.zshrc" ]' "$ROOT/install.sh" || fail "broken .zshrc symlinks are not backed up"
|
||||
grep -Fq 'cp -Pp "$HOME/.zshenv"' "$ROOT/install.sh" || fail ".zshenv symlinks are not preserved in backups"
|
||||
grep -Fq '[ -L "$HOME/.zshenv" ]' "$ROOT/install.sh" || fail "broken .zshenv symlinks are not backed up"
|
||||
grep -Fq 'brew shellenv' "$ROOT/.zshenv" || fail "Homebrew is not initialized in .zshenv"
|
||||
grep -Fq '/usr/local/bin/brew' "$ROOT/.zshenv" || fail "Intel Homebrew path is missing from .zshenv"
|
||||
if grep -Fq 'brew shellenv' "$ROOT/.zshrc"; then
|
||||
fail "Homebrew still initializes from interactive-only .zshrc"
|
||||
fi
|
||||
[[ ! -e "$ROOT/install/fnm.sh" ]] || fail "vendored fnm installer still exists"
|
||||
if grep -Eq '^[[:space:]]*export MLX_USER_TOKEN=' "$ROOT"/zshrc/*.zsh; then
|
||||
fail "a static MLX user token remains"
|
||||
|
||||
Reference in New Issue
Block a user