fix(fnm): load managed Node from always-on zsh layer
fnm lived in interactive-only ~/.config/zshrc, so ssh/agents/zsh -c missed fnm-managed node. Source ~/.config/zsh/*.zsh from .zshenv and install the fragment as zsh/fnm instead.
This commit is contained in:
@@ -2,31 +2,47 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BASE_URL="https://git.miomio.moe/mio/easyzsh/raw/branch/master/zshrc"
|
||||
# Install tool fragments from this repo into ~/.config.
|
||||
#
|
||||
# Bare name → zshrc/<name>.zsh → ~/.config/zshrc/<name>.zsh (interactive)
|
||||
# Path form → <path>.zsh → ~/.config/<path>.zsh
|
||||
# e.g. zsh/fnm → ~/.config/zsh/fnm.zsh (always-on)
|
||||
|
||||
ZSH_CONFIGS_DIR="$HOME/.config/zshrc"
|
||||
mkdir -p "$ZSH_CONFIGS_DIR"
|
||||
BASE_URL="https://git.miomio.moe/mio/easyzsh/raw/branch/master"
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
for arg in "$@"; do
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo "No arguments provided. Please specify the config files to download."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == */* ]]; then
|
||||
# Path form: one or more simple segments (zsh/fnm).
|
||||
if [[ "$arg" == *..* || "$arg" == /* || ! "$arg" =~ ^[A-Za-z0-9_-]+(/[A-Za-z0-9_-]+)+$ ]]; then
|
||||
echo "Invalid config path: $arg" >&2
|
||||
exit 1
|
||||
fi
|
||||
rel="${arg}.zsh"
|
||||
destination="$HOME/.config/${arg}.zsh"
|
||||
else
|
||||
if [[ -z "$arg" || "$arg" == *[![:alnum:]_-]* ]]; then
|
||||
echo "Invalid config name: $arg" >&2
|
||||
exit 1
|
||||
fi
|
||||
rel="zshrc/${arg}.zsh"
|
||||
destination="$HOME/.config/zshrc/${arg}.zsh"
|
||||
fi
|
||||
|
||||
destination="${ZSH_CONFIGS_DIR}/${arg}.zsh"
|
||||
temporary=$(mktemp "$HOME/.config/.easyzsh-${arg}.XXXXXX")
|
||||
trap 'rm -f "$temporary"' EXIT
|
||||
mkdir -p "$(dirname "$destination")"
|
||||
temporary=$(mktemp "$HOME/.config/.easyzsh-XXXXXX")
|
||||
trap 'rm -f "$temporary"' EXIT
|
||||
|
||||
if ! curl -fsSL "${BASE_URL}/${arg}.zsh" -o "$temporary"; then
|
||||
echo "Failed to download ${arg}.zsh from ${BASE_URL}"
|
||||
exit 1
|
||||
fi
|
||||
if ! curl -fsSL "${BASE_URL}/${rel}" -o "$temporary"; then
|
||||
echo "Failed to download ${rel} from ${BASE_URL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$temporary" "$destination"
|
||||
trap - EXIT
|
||||
done
|
||||
else
|
||||
echo "No arguments provided. Please specify the config files to download."
|
||||
exit 1
|
||||
fi
|
||||
mv "$temporary" "$destination"
|
||||
trap - EXIT
|
||||
echo "Installed $destination"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user