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.
49 lines
1.4 KiB
Bash
Executable File
49 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
# 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)
|
|
|
|
BASE_URL="https://git.miomio.moe/mio/easyzsh/raw/branch/master"
|
|
|
|
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
|
|
|
|
mkdir -p "$(dirname "$destination")"
|
|
temporary=$(mktemp "$HOME/.config/.easyzsh-XXXXXX")
|
|
trap 'rm -f "$temporary"' EXIT
|
|
|
|
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
|
|
echo "Installed $destination"
|
|
done
|