diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..d70a0b8
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,14 @@
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ day: "monday"
+ time: "05:30"
+ timezone: "UTC"
+ open-pull-requests-limit: 5
+ groups:
+ github-actions:
+ patterns:
+ - "*"
diff --git a/.github/renovate.json b/.github/renovate.json
deleted file mode 100644
index cd0763e..0000000
--- a/.github/renovate.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
- "extends": ["local>z-shell/.github:renovate-config"]
-}
diff --git a/.github/workflows/check-linux.yml b/.github/workflows/check-linux.yml
index 1e9a62a..3961425 100644
--- a/.github/workflows/check-linux.yml
+++ b/.github/workflows/check-linux.yml
@@ -4,15 +4,15 @@ on:
push:
branches: [main]
paths:
- - "lib/sh/**"
- - "lib/zsh/**"
+ - "public/sh/**"
+ - "public/zsh/**"
- "tests/**"
- ".github/workflows/check-linux.yml"
pull_request:
branches: [main]
paths:
- - "lib/sh/**"
- - "lib/zsh/**"
+ - "public/sh/**"
+ - "public/zsh/**"
- "tests/**"
- ".github/workflows/check-linux.yml"
workflow_dispatch:
@@ -34,7 +34,7 @@ jobs:
- name: ☑️ ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
with:
- scandir: "./lib/sh"
+ scandir: "./public/sh"
build:
runs-on: ubuntu-latest
@@ -50,15 +50,15 @@ jobs:
- name: "⚙️ Check: unit fixtures"
run: sh ./tests/installers.sh
- name: "⚙️ Check: install.sh -- -i skip"
- run: sh -x ./lib/sh/install.sh -- -i skip; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -i skip; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install.sh -- -a annex"
- run: sh -x ./lib/sh/install.sh -- -a annex; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -a annex; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install.sh -- -a loader"
- run: sh -x ./lib/sh/install.sh -- -a loader; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -a loader; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install.sh -- -a zunit"
- run: sh -x ./lib/sh/install.sh -- -a zunit; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -a zunit; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install_zpmod.sh"
- run: sh -x ./lib/sh/install_zpmod.sh
+ run: sh -x ./public/sh/install_zpmod.sh
- name: ⚙️ Load zpmod module
run: |
module_path+=( "${XDG_DATA_HOME:-$HOME/.local/share}/zi/zmodules/zpmod/Src" )
@@ -66,4 +66,4 @@ jobs:
zpmod source-study -l
shell: zsh {0}
- name: "⚙️ Check: init.zsh sync drift"
- run: sh lib/sh/sync-init.sh
+ run: sh public/sh/sync-init.sh --local ./public/zsh/init.zsh --remote ./public/zsh/init.zsh --checksum-url ./public/checksum.txt
diff --git a/.github/workflows/check-macos.yml b/.github/workflows/check-macos.yml
index 1d1d8e0..4b7a1cc 100644
--- a/.github/workflows/check-macos.yml
+++ b/.github/workflows/check-macos.yml
@@ -5,15 +5,15 @@ on:
push:
branches: [main]
paths:
- - "lib/sh/**"
- - "lib/zsh/**"
+ - "public/sh/**"
+ - "public/zsh/**"
- "tests/**"
- ".github/workflows/check-macos.yml"
pull_request:
branches: [main]
paths:
- - "lib/sh/**"
- - "lib/zsh/**"
+ - "public/sh/**"
+ - "public/zsh/**"
- "tests/**"
- ".github/workflows/check-macos.yml"
workflow_dispatch:
@@ -35,7 +35,7 @@ jobs:
- name: ☑️ ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
with:
- scandir: "./lib/sh"
+ scandir: "./public/sh"
build:
runs-on: macos-latest
@@ -50,15 +50,15 @@ jobs:
- name: "⚙️ Check: unit fixtures"
run: sh ./tests/installers.sh
- name: "⚙️ Check: install.sh -- -i skip"
- run: sh -x ./lib/sh/install.sh -- -i skip; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -i skip; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install.sh -- -a annex"
- run: sh -x ./lib/sh/install.sh -- -a annex; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -a annex; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install.sh -- -a loader"
- run: sh -x ./lib/sh/install.sh -- -a loader; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -a loader; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install.sh -- -a zunit"
- run: sh -x ./lib/sh/install.sh -- -a zunit; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
+ run: sh -x ./public/sh/install.sh -- -a zunit; command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" ~/.zi
- name: "⚙️ Check: install_zpmod.sh"
- run: sh -x ./lib/sh/install_zpmod.sh
+ run: sh -x ./public/sh/install_zpmod.sh
- name: ⚙️ Load zpmod module
run: |
module_path+=( "${XDG_DATA_HOME:-$HOME/.local/share}/zi/zmodules/zpmod/Src" )
diff --git a/.github/workflows/checksum.yml b/.github/workflows/checksum.yml
index 53dafe7..7eb8e22 100644
--- a/.github/workflows/checksum.yml
+++ b/.github/workflows/checksum.yml
@@ -3,10 +3,10 @@ name: "🆗 Checksum"
on:
push:
paths:
- - "lib/sh/install_zpmod.sh"
- - "lib/sh/install.sh"
- - "lib/sh/sync-init.sh"
- - "lib/zsh/init.zsh"
+ - "public/sh/install_zpmod.sh"
+ - "public/sh/install.sh"
+ - "public/sh/sync-init.sh"
+ - "public/zsh/init.zsh"
- ".github/workflows/checksum.yml"
workflow_dispatch: {}
@@ -28,15 +28,15 @@ jobs:
uses: jmgilman/actions-generate-checksum@3ea6dc9bf8eecf28e2ecc982fab683484a1a8561 # v1.0.1
with:
patterns: |
- lib/sh/install_zpmod.sh
- lib/sh/install.sh
- lib/sh/sync-init.sh
- lib/zsh/init.zsh
- - run: mv checksum.txt lib/
+ public/sh/install_zpmod.sh
+ public/sh/install.sh
+ public/sh/sync-init.sh
+ public/zsh/init.zsh
+ - run: mv checksum.txt public/
- name: "🆗 Commit"
- uses: z-shell/.github/actions/commit@d36763069484d7b5bf3d958e8517dbb682942c82 # v1.0.9
+ uses: z-shell/.github/actions/commit@3222f53692e448ed6e2caf8b8722e74fb2ca2461 # v1.1.1
with:
commitMessage: Checksum ${{ github.sha }}
- workDir: lib
+ workDir: public
commitUserName: ${{ secrets.ACTIONS_USER }}
commitUserEmail: ${{ secrets.ACTIONS_MAIL }}
diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml
index 351dbeb..c521d6d 100644
--- a/.github/workflows/deploy-gh-pages.yml
+++ b/.github/workflows/deploy-gh-pages.yml
@@ -7,7 +7,7 @@ on:
branches: [main]
tags: ["v*.*.*"]
paths:
- - "lib/**"
+ - "public/**"
- ".github/workflows/deploy-gh-pages.yml"
permissions:
@@ -49,7 +49,7 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
- publish_dir: ./lib
+ publish_dir: ./public
user_name: ${{ secrets.ACTIONS_USER }}
user_email: ${{ secrets.ACTIONS_MAIL }}
commit_message: ${{ steps.prepare_deploy.outputs.commit_message }}
diff --git a/.github/workflows/rclone-action.yml b/.github/workflows/rclone-action.yml
index 9533f39..7945f8b 100644
--- a/.github/workflows/rclone-action.yml
+++ b/.github/workflows/rclone-action.yml
@@ -2,10 +2,7 @@
name: "🔄 Rclone"
on:
push:
- branches: [main]
- paths:
- - "lib/**"
- - ".github/workflows/rclone-action.yml"
+ branches: [gh-pages]
workflow_dispatch: {}
permissions:
@@ -21,13 +18,13 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
- local_path: "lib"
+ local_path: "."
remote_path: "r2:r2-store/src"
steps:
- name: "⤵️ Check out code from GitHub"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "⏫ Run rclone/r2-store"
- uses: z-shell/.github/actions/rclone@d36763069484d7b5bf3d958e8517dbb682942c82 # v1.0.9
+ uses: z-shell/.github/actions/rclone@3222f53692e448ed6e2caf8b8722e74fb2ca2461 # v1.1.1
with:
config: ${{ secrets.R2_STORE }}
args: "copy --check-first ${{ env.local_path }} ${{ env.remote_path }}"
diff --git a/.github/workflows/win-install.yml b/.github/workflows/win-install.yml
index 365e6bc..73d452a 100644
--- a/.github/workflows/win-install.yml
+++ b/.github/workflows/win-install.yml
@@ -4,14 +4,14 @@ name: ⚙️ Windows Install
on:
pull_request:
paths:
- - "lib/sh/**"
- - "lib/zsh/**"
+ - "public/sh/**"
+ - "public/zsh/**"
- "tests/**"
- ".github/workflows/win-install.yml"
push:
paths:
- - "lib/sh/**"
- - "lib/zsh/**"
+ - "public/sh/**"
+ - "public/zsh/**"
- "tests/**"
- ".github/workflows/win-install.yml"
workflow_dispatch: {}
@@ -28,7 +28,7 @@ jobs:
- name: ☑️ ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
with:
- scandir: "./lib/sh"
+ scandir: "./public/sh"
run-install:
runs-on: windows-latest
timeout-minutes: 30
@@ -50,15 +50,15 @@ jobs:
- name: 🪟 Run Install
run: |
sh ./tests/installers.sh
- sh -x ./lib/sh/install.sh -- -i skip
+ sh -x ./public/sh/install.sh -- -i skip
command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" /home/runneradmin/.zi
- sh -x ./lib/sh/install.sh -- -a annex
+ sh -x ./public/sh/install.sh -- -a annex
command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" /home/runneradmin/.zi
- sh -x ./lib/sh/install.sh -- -a loader
+ sh -x ./public/sh/install.sh -- -a loader
command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" /home/runneradmin/.zi
- sh -x ./lib/sh/install.sh -- -a zunit
+ sh -x ./public/sh/install.sh -- -a zunit
command rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/zi" /home/runneradmin/.zi
- sh -x ./lib/sh/install.sh -- -a zpmod
+ sh -x ./public/sh/install.sh -- -a zpmod
shell: C:\tools\cygwin\bin\bash.exe --login -o igncr '{0}'
- name: 🪟 Smoke-test — verify zi.zsh present
run: |
diff --git a/docs/README.md b/docs/README.md
index 7b2fa8c..a7c209e 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,63 +1,76 @@
-
-
-
-
❮ Zi ❯
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ ❮ Src ❯
+
+
+ ✨ Z-Shell source library — snippets, installer scripts and shared utilities
+
+
+ |
+
+
+ |
+
+ |
+
+
+
### Content
-- Wiki Pages:
- - https://wiki.zshell.dev
-- Loader:
- - https://init.zshell.dev
-- Installer:
- - https://get.zshell.dev
-- R2:
- - https://r2.zshell.dev
-- IPFS:
- - https://ipfs.zshell.dev
-- jsDeliver:
- - https://cdn.jsdelivr.net/gh/z-shell/src@main/
+- **Wiki Pages**: [wiki.zshell.dev](https://wiki.zshell.dev)
+- **Loader**: [init.zshell.dev](https://init.zshell.dev)
+- **Installer**: [get.zshell.dev](https://get.zshell.dev)
+- **jsDeliver CDN**: [cdn.jsdelivr.net/gh/z-shell/src@main/](https://cdn.jsdelivr.net/gh/z-shell/src@main/)
### Maintainer — Verify and Sync Loader
-Check whether the local `lib/zsh/init.zsh` matches the canonical GitHub raw `main` copy:
+Check whether the local `public/zsh/init.zsh` matches the canonical GitHub raw `main` copy:
```sh
-sh lib/sh/sync-init.sh
+sh public/sh/sync-init.sh
```
Replace the local file if it drifts:
```sh
-sh lib/sh/sync-init.sh --write
+sh public/sh/sync-init.sh --write
```
Run against local fixtures (no network required, useful in tests):
```sh
-sh lib/sh/sync-init.sh \
+sh public/sh/sync-init.sh \
--local /tmp/my-init.zsh \
--remote /tmp/remote-init.zsh \
--checksum-url /tmp/checksum.txt
@@ -66,5 +79,9 @@ sh lib/sh/sync-init.sh \
Skip checksum validation:
```sh
-sh lib/sh/sync-init.sh --no-checksum
+sh public/sh/sync-init.sh --no-checksum
```
+
+---
+
+> This repository is compatible with [Zi](https://github.com/z-shell/zi)
diff --git a/lib/checksum.txt b/lib/checksum.txt
deleted file mode 100644
index 0a46d9e..0000000
--- a/lib/checksum.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-5d8fdd881b84548f38c1d5ffc6d5f46a18919d8dd6c1398d69abe055dd76ef98 lib/sh/install_zpmod.sh
-eb744a0aa3d03c4c2a6c9cfb5b9088389ce4bc9027d272dfd0b52dbb7b04e348 lib/sh/install.sh
-83d9f0dc013376b5aa03b7a11f3908058da176df3407ac6e2872857d7c9658fd lib/sh/sync-init.sh
-66dc5bb0575d44e4e1192e229204abe1ac47979a05ee3c3bb23afc2b9b493637 lib/zsh/init.zsh
diff --git a/lib/zsh/snippets/welcome.zsh b/lib/zsh/snippets/welcome.zsh
deleted file mode 100755
index 6b513a8..0000000
--- a/lib/zsh/snippets/welcome.zsh
+++ /dev/null
@@ -1,4 +0,0 @@
-+zi-message "{auto}\`Welcome to Zi :)\`"
-sleep 1
-+zi-message "{hi}I am the snippet\!"
-zi delete https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/snippets/welcome.zsh
diff --git a/lib/_headers b/public/_headers
similarity index 100%
rename from lib/_headers
rename to public/_headers
diff --git a/public/checksum.txt b/public/checksum.txt
new file mode 100644
index 0000000..22dce7f
--- /dev/null
+++ b/public/checksum.txt
@@ -0,0 +1,4 @@
+348b78e992d28ecebd23940d06944629ef7f8f9d93c17ef3469cd6eebd288451 public/sh/install_zpmod.sh
+7408a1045f330a6e73bda55c6c7b48be7873a4e7f1fb00d7db989827cc9224a9 public/sh/install.sh
+f8519bf7e3e42ad67cc9cff6d82a8367641611fc687b2f6793e26bd55dbbb553 public/sh/sync-init.sh
+98f54a779985719e390b3e4559b7b0ac22101caac91d0569d41cd9229a05c6de public/zsh/init.zsh
diff --git a/lib/index.html b/public/index.html
similarity index 100%
rename from lib/index.html
rename to public/index.html
diff --git a/lib/sh/install.sh b/public/sh/install.sh
similarity index 68%
rename from lib/sh/install.sh
rename to public/sh/install.sh
index 03522ac..694ceed 100755
--- a/lib/sh/install.sh
+++ b/public/sh/install.sh
@@ -36,17 +36,80 @@ while getopts ":i:a:b:" opt; do
done
shift $((OPTIND - 1))
+SCRIPT_DIR=""
+LOCAL_INIT_ZSH=""
+LOCAL_INSTALL_ZPMOD=""
+case "$0" in
+*/?*)
+ SCRIPT_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)" || SCRIPT_DIR=""
+ ;;
+*) ;;
+esac
+
+if [ -n "${SCRIPT_DIR}" ]; then
+ if [ -f "${SCRIPT_DIR}/../zsh/init.zsh" ]; then
+ LOCAL_INIT_ZSH="${SCRIPT_DIR}/../zsh/init.zsh"
+ fi
+ if [ -f "${SCRIPT_DIR}/install_zpmod.sh" ]; then
+ LOCAL_INSTALL_ZPMOD="${SCRIPT_DIR}/install_zpmod.sh"
+ fi
+fi
+
+fetch_to_file() {
+ _dest="$1"
+ shift
+ _has_fetcher=0
+
+ for _src; do
+ [ -n "${_src}" ] || continue
+ case "${_src}" in
+ http://* | https://*)
+ if command -v curl >/dev/null 2>&1; then
+ _has_fetcher=1
+ if command curl -fsSL "${_src}" -o "${_dest}" 2>/dev/null; then
+ return 0
+ fi
+ elif command -v wget >/dev/null 2>&1; then
+ _has_fetcher=1
+ if command wget -qO "${_dest}" "${_src}" 2>/dev/null; then
+ return 0
+ fi
+ fi
+ ;;
+ *)
+ if [ -r "${_src}" ]; then
+ command cp "${_src}" "${_dest}"
+ return 0
+ fi
+ ;;
+ esac
+ done
+
+ if [ "${_has_fetcher}" -eq 0 ]; then
+ printf '%s\n' "-- ERROR -- curl or wget is required to download installer assets" >&2
+ fi
+ return 1
+}
+
if [ "${AOPT}" = loader ]; then
ZI_CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/zi"
+ loader_tmp="${WORKDIR}/init.zsh.tmp"
command mkdir -p "${ZI_CONFIG_DIR}"
- if command -v curl >/dev/null 2>&1; then
- command curl -fsSL https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/init.zsh -o "${ZI_CONFIG_DIR}/init.zsh"
- elif command -v wget >/dev/null 2>&1; then
- command wget -qO "${ZI_CONFIG_DIR}/init.zsh" https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/init.zsh
+ set +e
+ fetch_to_file "${ZI_CONFIG_DIR}/init.zsh" \
+ "${LOCAL_INIT_ZSH}" \
+ "https://raw.githubusercontent.com/z-shell/src/main/public/zsh/init.zsh" \
+ "https://raw.githubusercontent.com/z-shell/src/main/lib/zsh/init.zsh"
+ fetch_status=$?
+ set -e
+ if [ "${fetch_status}" -ne 0 ]; then
+ printf '%s\n' "-- ERROR -- failed to retrieve init.zsh" >&2
+ exit 1
fi
- command chmod go-w "${ZI_CONFIG_DIR}" && command chmod a+x "${ZI_CONFIG_DIR}/init.zsh"
# shellcheck disable=SC2016
- command sed -i 's|: ${ZI\[STREAM\]:="main"}|: ${ZI[STREAM]:="'"${BOPT}"'"}|' "${ZI_CONFIG_DIR}/init.zsh"
+ command sed 's|: ${ZI\[STREAM\]:="main"}|: ${ZI[STREAM]:="'"${BOPT}"'"}|' "${ZI_CONFIG_DIR}/init.zsh" >"${loader_tmp}" &&
+ command mv "${loader_tmp}" "${ZI_CONFIG_DIR}/init.zsh"
+ command chmod go-w "${ZI_CONFIG_DIR}" && command chmod a+x "${ZI_CONFIG_DIR}/init.zsh"
fi
if [ -z "${ZI_HOME-}" ]; then
@@ -58,7 +121,7 @@ if [ -z "${ZI_BIN_DIR_NAME-}" ]; then
fi
if ! test -d "${ZI_HOME}"; then
- command mkdir "${ZI_HOME}"
+ command mkdir -p "${ZI_HOME}"
command chmod go-w "${ZI_HOME}"
fi
@@ -68,17 +131,20 @@ if ! command -v git >/dev/null 2>&1; then
fi
# Get the download-progress bar tool
-if command -v curl >/dev/null 2>&1; then
- command mkdir -p /tmp/zi
- cd /tmp/zi || exit 1
- command curl -fsSLO https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh &&
- command chmod a+x /tmp/zi/git-process-output.zsh
-elif command -v wget >/dev/null 2>&1; then
- command mkdir -p /tmp/zi
- cd /tmp/zi || exit 1
- command wget -q https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh &&
- command chmod a+x /tmp/zi/git-process-output.zsh
+command mkdir -p /tmp/zi
+cd /tmp/zi || exit 1
+set +e
+fetch_to_file /tmp/zi/git-process-output.zsh \
+ "" \
+ "https://raw.githubusercontent.com/z-shell/zi/main/public/zsh/git-process-output.zsh" \
+ "https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh"
+fetch_status=$?
+set -e
+if [ "${fetch_status}" -ne 0 ]; then
+ printf '%s\n' "-- ERROR -- failed to retrieve git-process-output.zsh" >&2
+ exit 1
fi
+command chmod a+x /tmp/zi/git-process-output.zsh
if test -d "${ZI_HOME}/${ZI_BIN_DIR_NAME}/.git"; then
cd "${ZI_HOME}/${ZI_BIN_DIR_NAME}" || exit 1
@@ -168,36 +234,28 @@ EOF
ZPMOD_PROFILE() {
_zpmod_sh=""
- case "$0" in
- */*)
- _script_dir="$(cd "$(dirname "$0")" 2>/dev/null && pwd)" || _script_dir=""
- ;;
- *)
- _script_dir=""
- ;;
- esac
-
- if [ -n "${_script_dir}" ] && [ -f "${_script_dir}/install_zpmod.sh" ]; then
- _zpmod_sh="${_script_dir}/install_zpmod.sh"
+ if [ -n "${LOCAL_INSTALL_ZPMOD}" ]; then
+ _zpmod_sh="${LOCAL_INSTALL_ZPMOD}"
else
_zpmod_sh="${WORKDIR}/install_zpmod.sh"
- _zpmod_url="https://raw.githubusercontent.com/z-shell/zi-src/main/lib/sh/install_zpmod.sh"
- if command -v curl >/dev/null 2>&1; then
- command curl -fsSL "${_zpmod_url}" -o "${_zpmod_sh}"
- elif command -v wget >/dev/null 2>&1; then
- command wget -qO "${_zpmod_sh}" "${_zpmod_url}"
- else
- printf '%s\n' "-- ERROR -- curl or wget is required to download install_zpmod.sh" >&2
- exit 1
- fi
- if [ ! -s "${_zpmod_sh}" ]; then
+ set +e
+ fetch_to_file "${_zpmod_sh}" \
+ "" \
+ "https://raw.githubusercontent.com/z-shell/src/main/public/sh/install_zpmod.sh" \
+ "https://raw.githubusercontent.com/z-shell/src/main/lib/sh/install_zpmod.sh"
+ fetch_status=$?
+ set -e
+ if [ "${fetch_status}" -ne 0 ]; then
printf '%s\n' "-- ERROR -- failed to download install_zpmod.sh" >&2
exit 1
fi
command chmod a+x "${_zpmod_sh}"
fi
- exec sh "${_zpmod_sh}" "$@"
+ if [ "$#" -gt 0 ]; then
+ exec sh "${_zpmod_sh}" "$@"
+ fi
+ exec sh "${_zpmod_sh}"
}
CLOSE_PROFILE() {
@@ -211,7 +269,11 @@ CLOSE_PROFILE() {
MAIN() {
if [ "${AOPT}" = zpmod ]; then
- ZPMOD_PROFILE "$@"
+ if [ "$#" -gt 0 ]; then
+ ZPMOD_PROFILE "$@"
+ else
+ ZPMOD_PROFILE
+ fi
else
MAIN_PROFILE
ANNEX_PROFILE
@@ -227,4 +289,8 @@ EOF
exit 0
}
-MAIN "${@}"
+if [ "$#" -gt 0 ]; then
+ MAIN "$@"
+else
+ MAIN
+fi
diff --git a/lib/sh/install_zpmod.sh b/public/sh/install_zpmod.sh
similarity index 94%
rename from lib/sh/install_zpmod.sh
rename to public/sh/install_zpmod.sh
index c49b99c..9bc9ed9 100755
--- a/lib/sh/install_zpmod.sh
+++ b/public/sh/install_zpmod.sh
@@ -124,10 +124,20 @@ MAIN() {
col_info2="[32m"
col_rst="[0m"
- setup_environment "$@"
- setup_zpmod_repository "$@"
- build_zpmod_module "$@"
+ if [ "$#" -gt 0 ]; then
+ setup_environment "$@"
+ setup_zpmod_repository "$@"
+ build_zpmod_module "$@"
+ else
+ setup_environment
+ setup_zpmod_repository
+ build_zpmod_module
+ fi
exit 0
}
-MAIN "${@}"
+if [ "$#" -gt 0 ]; then
+ MAIN "$@"
+else
+ MAIN
+fi
diff --git a/lib/sh/sync-init.sh b/public/sh/sync-init.sh
similarity index 81%
rename from lib/sh/sync-init.sh
rename to public/sh/sync-init.sh
index 5cc30ac..fe19ec6 100755
--- a/lib/sh/sync-init.sh
+++ b/public/sh/sync-init.sh
@@ -2,14 +2,14 @@
# -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=sh sw=2 ts=2 et
#
-# sync-init.sh — verify and optionally sync local lib/zsh/init.zsh with remote.
+# sync-init.sh — verify and optionally sync local public/zsh/init.zsh with remote.
#
# Usage:
-# sh lib/sh/sync-init.sh [OPTIONS]
+# sh public/sh/sync-init.sh [OPTIONS]
#
# Options:
# --write Replace local file with remote copy (requires valid checksum)
-# --local PATH Local file to compare (default: lib/zsh/init.zsh)
+# --local PATH Local file to compare (default: public/zsh/init.zsh)
# --remote URL|PATH Remote URL or local path (default: GitHub raw main)
# --checksum-url URL|PATH Checksum.txt URL or path (default: GitHub raw main)
# --no-checksum Skip checksum validation of remote content
@@ -28,10 +28,10 @@ trap 'rm -rf "${WORKDIR:?}"' EXIT INT TERM
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
-DEFAULT_LOCAL="${REPO_ROOT}/lib/zsh/init.zsh"
-DEFAULT_REMOTE="https://raw.githubusercontent.com/z-shell/zi-src/main/lib/zsh/init.zsh"
-DEFAULT_CHECKSUM_URL="https://raw.githubusercontent.com/z-shell/zi-src/main/lib/checksum.txt"
-CHECKSUM_KEY="lib/zsh/init.zsh"
+DEFAULT_LOCAL="${REPO_ROOT}/public/zsh/init.zsh"
+DEFAULT_REMOTE="https://raw.githubusercontent.com/z-shell/src/main/public/zsh/init.zsh"
+DEFAULT_CHECKSUM_URL="https://raw.githubusercontent.com/z-shell/src/main/public/checksum.txt"
+CHECKSUM_KEY="public/zsh/init.zsh"
OPT_LOCAL="${DEFAULT_LOCAL}"
OPT_REMOTE="${DEFAULT_REMOTE}"
@@ -43,14 +43,14 @@ OPT_NO_CHECKSUM=0
print_help() {
cat </dev/null 2>&1; then
+ command curl -fsSL "${_url}"
+ elif command -v wget >/dev/null 2>&1; then
+ command wget -qO- "${_url}"
+ else
+ printf '%s\n' "[1;31m▓▒░[0m No curl or wget available." >&2
+ return 1
+ fi
+}
+
+_legacy_url() {
+ _url="$1"
+ case "${_url}" in
+ https://raw.githubusercontent.com/z-shell/src/main/public/*)
+ printf '%s\n' "https://raw.githubusercontent.com/z-shell/src/main/lib/${_url#https://raw.githubusercontent.com/z-shell/src/main/public/}"
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
# Fetch a URL or copy a local readable path to stdout.
_fetch() {
_src="$1"
+ _legacy_src=""
+ _fetch_status=0
case "${_src}" in
http://* | https://*)
- if command -v curl >/dev/null 2>&1; then
- command curl -fsSL "${_src}"
- elif command -v wget >/dev/null 2>&1; then
- command wget -qO- "${_src}"
- else
- printf '%s\n' "[1;31m▓▒░[0m No curl or wget available." >&2
- return 1
+ set +e
+ _fetch_url "${_src}"
+ _fetch_status=$?
+ set -e
+ if [ "${_fetch_status}" -eq 0 ]; then
+ return 0
fi
+ set +e
+ _legacy_src="$(_legacy_url "${_src}" 2>/dev/null)"
+ _legacy_status=$?
+ set -e
+ if [ "${_legacy_status}" -eq 0 ] && [ -n "${_legacy_src}" ]; then
+ set +e
+ _fetch_url "${_legacy_src}"
+ _fetch_status=$?
+ set -e
+ if [ "${_fetch_status}" -eq 0 ]; then
+ return 0
+ fi
+ fi
+ printf '%s\n' "[1;31m▓▒░[0m Failed to fetch: ${_src}" >&2
+ return 1
;;
*)
if [ -r "${_src}" ]; then
diff --git a/lib/zsh/init.zsh b/public/zsh/init.zsh
similarity index 99%
rename from lib/zsh/init.zsh
rename to public/zsh/init.zsh
index 01add00..ad19e78 100755
--- a/lib/zsh/init.zsh
+++ b/public/zsh/init.zsh
@@ -57,7 +57,7 @@ _zi_setup() {
[[ -d "$tmp_dir" ]] || command mkdir -p "$tmp_dir"
show_process="${tmp_dir}/git-process.zsh"
- process_url="https://raw.githubusercontent.com/z-shell/zi/main/lib/zsh/git-process-output.zsh"
+ process_url="https://raw.githubusercontent.com/z-shell/zi/main/public/zsh/git-process-output.zsh"
if [[ ! -f "$show_process" ]]; then
if _zi_fetch "$process_url" > "${tmp_dir}/git-process.zsh"; then
diff --git a/lib/zsh/snippets/.gitkeep b/public/zsh/snippets/.gitkeep
similarity index 100%
rename from lib/zsh/snippets/.gitkeep
rename to public/zsh/snippets/.gitkeep
diff --git a/lib/zsh/snippets/color.zsh b/public/zsh/snippets/color.zsh
similarity index 100%
rename from lib/zsh/snippets/color.zsh
rename to public/zsh/snippets/color.zsh
diff --git a/lib/zsh/snippets/revolver b/public/zsh/snippets/revolver
similarity index 100%
rename from lib/zsh/snippets/revolver
rename to public/zsh/snippets/revolver
diff --git a/public/zsh/snippets/welcome.zsh b/public/zsh/snippets/welcome.zsh
new file mode 100755
index 0000000..576fac9
--- /dev/null
+++ b/public/zsh/snippets/welcome.zsh
@@ -0,0 +1,4 @@
++zi-message "{auto}\`Welcome to Zi :)\`"
+sleep 1
++zi-message "{hi}I am the snippet\!"
+zi delete https://raw.githubusercontent.com/z-shell/src/main/public/zsh/snippets/welcome.zsh
diff --git a/tests/installers.sh b/tests/installers.sh
index 5e58b13..48aac94 100755
--- a/tests/installers.sh
+++ b/tests/installers.sh
@@ -47,11 +47,11 @@ sha256_file() {
}
check_syntax() {
- sh -n "${ROOT}/lib/sh/install.sh"
- sh -n "${ROOT}/lib/sh/install_zpmod.sh"
- sh -n "${ROOT}/lib/sh/sync-init.sh"
+ sh -n "${ROOT}/public/sh/install.sh"
+ sh -n "${ROOT}/public/sh/install_zpmod.sh"
+ sh -n "${ROOT}/public/sh/sync-init.sh"
command -v zsh >/dev/null 2>&1 || fail "zsh is required for init.zsh syntax checks"
- zsh -n "${ROOT}/lib/zsh/init.zsh"
+ zsh -n "${ROOT}/public/zsh/init.zsh"
pass "script syntax"
}
@@ -60,7 +60,7 @@ check_checksums() {
[ -n "${expected}" ] || continue
actual="$(sha256_file "${ROOT}/${path}")"
[ "${actual}" = "${expected}" ] || fail "checksum mismatch for ${path}"
- done <"${ROOT}/lib/checksum.txt"
+ done <"${ROOT}/public/checksum.txt"
pass "checksums"
}
@@ -104,11 +104,11 @@ if [ -z "${out}" ] && [ "${remote_name}" -eq 1 ]; then
fi
case "${url}" in
- */lib/zsh/init.zsh)
+ */public/zsh/init.zsh)
if [ -n "${out}" ]; then
- cp "${ZI_SRC_TEST_ROOT}/lib/zsh/init.zsh" "${out}"
+ cp "${ZI_SRC_TEST_ROOT}/public/zsh/init.zsh" "${out}"
else
- cat "${ZI_SRC_TEST_ROOT}/lib/zsh/init.zsh"
+ cat "${ZI_SRC_TEST_ROOT}/public/zsh/init.zsh"
fi
;;
*/git-process-output.zsh)
@@ -119,7 +119,7 @@ cat
SCRIPT
chmod a+x "${out}"
;;
- */lib/sh/install_zpmod.sh)
+ */public/sh/install_zpmod.sh)
[ -n "${out}" ] || { printf '%s\n' "curl test double: missing output path" >&2; exit 64; }
cat > "${out}" <<'SCRIPT'
#!/usr/bin/env sh
@@ -180,7 +180,7 @@ test_loader_install() {
XDG_DATA_HOME="${data}" \
ZI_SRC_TEST_ROOT="${ROOT}" \
PATH="${FAKE_BIN}:${PATH}" \
- sh "${ROOT}/lib/sh/install.sh" -a loader -b feature/test >/dev/null
+ sh "${ROOT}/public/sh/install.sh" -a loader -b feature/test >/dev/null
# shellcheck disable=SC2016
contains "${config}/zi/init.zsh" ': ${ZI[STREAM]:="feature/test"}'
@@ -190,13 +190,29 @@ test_loader_install() {
pass "loader install uses XDG paths and branch override"
}
+test_xdg_data_home_install() {
+ home="${TMP_ROOT}/default-home"
+ data="${TMP_ROOT}/missing-root/data-home"
+ command mkdir -p "${home}"
+
+ HOME="${home}" \
+ ZDOTDIR="${home}" \
+ XDG_DATA_HOME="${data}" \
+ ZI_SRC_TEST_ROOT="${ROOT}" \
+ PATH="${FAKE_BIN}:${PATH}" \
+ sh "${ROOT}/public/sh/install.sh" -i skip >/dev/null
+
+ [ -f "${data}/zi/bin/zi.zsh" ] || fail "install did not create the XDG data home"
+ pass "XDG data home install creates parent directories"
+}
+
test_standalone_zpmod_delegation() {
standalone_dir="${TMP_ROOT}/standalone"
home="${TMP_ROOT}/zpmod-home"
data="${TMP_ROOT}/zpmod-data"
marker="${TMP_ROOT}/zpmod-marker"
command mkdir -p "${standalone_dir}" "${home}" "${data}"
- command cp "${ROOT}/lib/sh/install.sh" "${standalone_dir}/install.sh"
+ command cp "${ROOT}/public/sh/install.sh" "${standalone_dir}/install.sh"
HOME="${home}" \
ZDOTDIR="${home}" \
@@ -218,22 +234,22 @@ test_sync_init() {
printf '%s\n' '# remote init fixture' >"${remote_file}"
command cp "${remote_file}" "${local_file}"
remote_hash="$(sha256_file "${remote_file}")"
- printf '%s %s\n' "${remote_hash}" 'lib/zsh/init.zsh' >"${checksum_file}"
+ printf '%s %s\n' "${remote_hash}" 'public/zsh/init.zsh' >"${checksum_file}"
- sh "${ROOT}/lib/sh/sync-init.sh" \
+ sh "${ROOT}/public/sh/sync-init.sh" \
--local "${local_file}" \
--remote "${remote_file}" \
--checksum-url "${checksum_file}" >/dev/null
printf '%s\n' '# stale init fixture' >"${local_file}"
- if sh "${ROOT}/lib/sh/sync-init.sh" \
+ if sh "${ROOT}/public/sh/sync-init.sh" \
--local "${local_file}" \
--remote "${remote_file}" \
--checksum-url "${checksum_file}" >/dev/null 2>&1; then
fail "sync-init mismatch check unexpectedly succeeded"
fi
- sh "${ROOT}/lib/sh/sync-init.sh" \
+ sh "${ROOT}/public/sh/sync-init.sh" \
--write \
--local "${local_file}" \
--remote "${remote_file}" \
@@ -247,5 +263,6 @@ check_syntax
check_checksums
write_fake_tools
test_loader_install
+test_xdg_data_home_install
test_standalone_zpmod_delegation
test_sync_init