first commit

This commit is contained in:
Arctic 2025-07-04 11:48:40 -05:00
commit 0610f4aeab
130 changed files with 9897 additions and 0 deletions

60
sc/setup Executable file
View file

@ -0,0 +1,60 @@
#!/bin/sh
self="$(dirname -- "$0")"
old=
new=
while getopts ':o:n:h' opt "$@"; do
case "$opt" in
h)
command cat <<\END
Usage: setup [-o old] -n new
END
exit
;;
o)
if [ -n "$old" ]; then
>&2 echo "[z4h/setup] error: duplicate option: -$opt"
exit 1
fi
old="$OPTARG"
;;
n)
if [ -n "$new" ]; then
>&2 echo "[z4h/setup] error: duplicate option: -$opt"
exit 1
fi
new="$OPTARG"
;;
\?) >&2 echo "[z4h/setup] error: invalid option: -$OPTARG" ; exit 1;;
:) >&2 echo "[z4h/setup] error: missing required argument: -$OPTARG"; exit 1;;
*) >&2 echo "[z4h/setup] internal error: unhandled option: -$opt" ; exit 1;;
esac
done
if [ "$OPTIND" -le $# ]; then
>&2 echo "[z4h/setup] error: unexpected positional argument"
exit 1
fi
if [ -z "$new" ]; then
>&2 echo "[z4h/setup] error: missing required option: -n"
exit 1
fi
command find "$self" -name '*.zwc' -exec rm -f -- '{}' '+' || exit
command mkdir -p -- "$new"/bin "$new"/fn "$new"/cache/ohmyzsh "$new"/tmp || exit
if [ ! -L "$new"/z4h.zsh ]; then
command cp -f -- "$self"/../z4h.zsh "$new"/ || exit
fi
if [ ! -e "$new"/cache/last-update-ts ]; then
echo -n >"$new"/cache/last-update-ts || exit
fi
if [ -n "$old" -a -d "$old"/stickycache ]; then
command rm -rf -- "$new"/stickycache || exit
command cp -r -- "$old"/stickycache "$new"/stickycache || exit
else
command mkdir -p -- "$new"/stickycache || exit
fi