├── tests ├── tmp_home │ ├── .zsh │ │ ├── aliases.zsh │ │ ├── custom │ │ │ ├── lib │ │ │ │ ├── lib1.zsh │ │ │ │ └── lib2.zsh │ │ │ └── plugins │ │ │ │ ├── mytheme │ │ │ │ └── mytheme.zsh-theme │ │ │ │ ├── myplugin │ │ │ │ └── myplugin.plugin.zsh │ │ │ │ └── grizwold │ │ │ │ └── grizwold.plugin.zsh │ │ ├── functions │ │ │ └── myfunc │ │ ├── .zsh_plugins.txt │ │ └── .zplugins_fake_load │ └── .cache │ │ ├── antidote │ │ ├── ohmy │ │ │ └── ohmy │ │ │ │ ├── plugins │ │ │ │ ├── docker │ │ │ │ │ ├── _docker │ │ │ │ │ └── docker.plugin.zsh │ │ │ │ ├── macos │ │ │ │ │ ├── macos.plugin.zsh │ │ │ │ │ └── functions │ │ │ │ │ │ └── macos_func │ │ │ │ ├── extract │ │ │ │ │ └── extract.plugin.zsh │ │ │ │ └── magic-enter │ │ │ │ │ └── magic-enter.plugin.zsh │ │ │ │ ├── .mockgit │ │ │ │ └── config │ │ │ │ │ └── remote.origin.url │ │ │ │ ├── oh-my.sh │ │ │ │ ├── lib │ │ │ │ ├── lib1.zsh │ │ │ │ ├── lib2.zsh │ │ │ │ └── lib3.zsh │ │ │ │ ├── custom │ │ │ │ └── themes │ │ │ │ │ ├── ugly.zsh-theme │ │ │ │ │ └── pretty.zsh-theme │ │ │ │ └── themes │ │ │ │ └── pretty.zsh-theme │ │ ├── foo │ │ │ ├── baz │ │ │ │ ├── functions │ │ │ │ │ ├── _baz │ │ │ │ │ └── baz │ │ │ │ ├── .mockgit │ │ │ │ │ └── config │ │ │ │ │ │ └── remote.origin.url │ │ │ │ └── baz.plugin.zsh │ │ │ ├── bar │ │ │ │ ├── .mockgit │ │ │ │ │ └── config │ │ │ │ │ │ └── remote.origin.url │ │ │ │ └── bar.plugin.zsh │ │ │ └── qux │ │ │ │ ├── .mockgit │ │ │ │ └── config │ │ │ │ │ └── remote.origin.url │ │ │ │ └── qux.plugin.zsh │ │ └── getantidote │ │ │ └── zsh-defer │ │ │ ├── .mockgit │ │ │ └── config │ │ │ │ └── remote.origin.url │ │ │ └── zsh-defer.plugin.zsh │ │ └── antibody │ │ ├── git-AT-github.com-COLON-foo-SLASH-qux │ │ ├── .mockgit │ │ │ └── .gitkeep │ │ └── qux.plugin.zsh │ │ ├── https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar │ │ ├── .mockgit │ │ │ └── .gitkeep │ │ └── bar.plugin.zsh │ │ ├── https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-baz │ │ ├── .mockgit │ │ │ └── .gitkeep │ │ ├── functions │ │ │ ├── _baz │ │ │ └── baz │ │ └── baz.plugin.zsh │ │ ├── https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy │ │ ├── .mockgit │ │ │ └── .gitkeep │ │ ├── plugins │ │ │ ├── docker │ │ │ │ ├── _docker │ │ │ │ └── docker.plugin.zsh │ │ │ ├── macos │ │ │ │ ├── macos.plugin.zsh │ │ │ │ └── functions │ │ │ │ │ └── macos_func │ │ │ ├── extract │ │ │ │ └── extract.plugin.zsh │ │ │ └── magic-enter │ │ │ │ └── magic-enter.plugin.zsh │ │ ├── oh-my.sh │ │ ├── lib │ │ │ ├── lib1.zsh │ │ │ ├── lib2.zsh │ │ │ └── lib3.zsh │ │ ├── custom │ │ │ └── themes │ │ │ │ ├── ugly.zsh-theme │ │ │ │ └── pretty.zsh-theme │ │ └── themes │ │ │ └── pretty.zsh-theme │ │ └── https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer │ │ ├── .mockgit │ │ └── .gitkeep │ │ └── zsh-defer.plugin.zsh ├── testdata │ ├── .zsh_plugins_empty.txt │ ├── script-fooqux.zsh │ ├── script-foobar.zsh │ ├── real │ │ ├── .zsh_plugins.crlf.txt │ │ ├── .zsh_plugins.txt │ │ ├── repo-list.txt │ │ └── .zsh_plugins.zsh │ ├── .zsh_plugins_repos.txt │ ├── .zsh_plugins_purged.txt │ ├── .zsh_plugins.zsh │ ├── .zplugins_fake_load.zsh │ ├── .zplugins_fake_zcompile_static.zsh │ ├── .zsh_plugins_no_defer.zsh │ └── .zsh_plugins_multi_defer.zsh ├── _setup.zsh ├── functions │ ├── t_reset │ ├── t_unload_antidote │ ├── subenv │ ├── t_setup_real │ ├── t_teardown │ ├── t_setup │ └── mockgit ├── test_cmd_update.md ├── test_setopts_special.md ├── test_cmd_init.md ├── test_alt_zsh_defer_bundle.md ├── test_cmd_main.md ├── test_cmd_path.md ├── test_zcompile_static.md ├── test_cmd_install.md ├── test_cmd_list.md ├── test_zcompile_bundle.md ├── test_cmd_bundle.md ├── README.md ├── test_cmd_load.md ├── test_cmd_home.md ├── test_cmd_purge.md ├── test_zsetopts.md ├── test_antidote_core.md ├── test_fpath_rules.md ├── test_cmd_help.md ├── test_bundle_helpers.md ├── test_helpers.md ├── test_real.md └── test_antidote.md ├── .gitignore ├── functions ├── __antidote_print_path ├── __antidote_indent ├── __antidote_tourl ├── __antidote_version ├── antidote ├── __antidote_collect_input ├── __antidote_filter_defers ├── __antidote_bundle_name ├── __antidote_initfiles ├── antidote-home ├── __antidote_bundle_zcompile ├── antidote-help ├── __antidote_get_cachedir ├── antidote-init ├── __antidote_del ├── antidote-load ├── __antidote_usage ├── __antidote_parse_bundles ├── antidote-path ├── __antidote_setup ├── __antidote_bulk_clone ├── antidote-list ├── antidote-main ├── __antidote_bundle_type ├── antidote-bundle ├── __antidote_bundle_dir ├── antidote-install ├── __antidote_load_prep ├── antidote-purge ├── antidote-update ├── _antidote └── antidote-script ├── man ├── footer.md ├── antidote-path.md ├── antidote-help.md ├── antidote-purge.md ├── antidote-update.md ├── antidote-list.md ├── antidote-home.md ├── man1 │ ├── antidote-path.1 │ ├── antidote-help.1 │ ├── antidote-purge.1 │ ├── antidote-update.1 │ ├── antidote-list.1 │ ├── antidote-home.1 │ ├── antidote-init.1 │ ├── antidote-load.1 │ ├── antidote-install.1 │ ├── antidote-bundle.1 │ └── antidote.1 ├── antidote-init.md ├── antidote-load.md ├── antidote-install.md ├── antidote-bundle.md └── antidote.md ├── tools ├── bumpver ├── sloc ├── run-clitests └── buildman ├── .editorconfig ├── antidote ├── .bumpversion.cfg ├── antidote.zsh ├── .github ├── workflows │ └── test.yml └── CODE_OF_CONDUCT.md ├── LICENSE ├── makefile └── README.md /tests/tmp_home/.zsh/aliases.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing aliases.zsh..." 2 | -------------------------------------------------------------------------------- /tests/testdata/.zsh_plugins_empty.txt: -------------------------------------------------------------------------------- 1 | # comments 2 | # nothing here 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/docker/_docker: -------------------------------------------------------------------------------- 1 | #compdef 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/git-AT-github.com-COLON-foo-SLASH-qux/.mockgit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/baz/functions/_baz: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | echo _baz completion 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/bar/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://github.com/foo/bar 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/baz/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://github.com/foo/baz 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/qux/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | git@github.com:foo/qux 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar/.mockgit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-baz/.mockgit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/.mockgit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://github.com/ohmy/ohmy 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/lib/lib1.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing custom lib1.zsh..." 2 | libs=($libs custom:lib1) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/lib/lib2.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing custom lib2.zsh..." 2 | libs=($libs custom:lib2) 3 | -------------------------------------------------------------------------------- /tests/_setup.zsh: -------------------------------------------------------------------------------- 1 | # autoload test functions 2 | 0=${(%):-%N} 3 | autoload -U ${0:A:h}/functions/t_setup 4 | t_setup 5 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/bar/bar.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/bar..." 2 | plugins=($plugins foo/bar) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/baz/baz.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/baz..." 2 | plugins=($plugins foo/baz) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/qux/qux.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/qux..." 2 | plugins=($plugins foo/qux) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/oh-my.sh: -------------------------------------------------------------------------------- 1 | echo "sourcing oh-my.sh..." 2 | plugins=($plugins ohmy/ohmy) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/functions/myfunc: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function myfunc { 3 | echo myfunc "$@" 4 | } 5 | myfunc "$@" 6 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/.mockgit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/lib/lib1.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing ohmy/lib/lib1.zsh..." 2 | libs=($libs ohmy:lib1) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/lib/lib2.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing ohmy/lib/lib2.zsh..." 2 | libs=($libs ohmy:lib2) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/lib/lib3.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing ohmy/lib/lib3.zsh..." 2 | libs=($libs ohmy:lib2) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/plugins/mytheme/mytheme.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing mytheme..." 2 | plugins+=(custom:mytheme) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/docker/_docker: -------------------------------------------------------------------------------- 1 | #compdef 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/baz/functions/baz: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function baz { 3 | echo baz function 4 | } 5 | baz "$@" 6 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/getantidote/zsh-defer/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://github.com/getantidote/zsh-defer 2 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/custom/themes/ugly.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing ugly.zsh-theme..." 2 | themes=($themes ohmy:ugly) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/macos/macos.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing macos.plugin.zsh..." 2 | plugins+=(ohmy:macos) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/themes/pretty.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing pretty.zsh-theme..." 2 | themes=($themes ohmy:pretty) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-baz/functions/_baz: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | echo _baz completion 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/docker/docker.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing docker.plugin.zsh..." 2 | plugins+=(ohmy:docker) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/git-AT-github.com-COLON-foo-SLASH-qux/qux.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/qux..." 2 | plugins=($plugins foo/qux) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/custom/themes/pretty.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing pretty.zsh-theme..." 2 | themes=($themes ohmy:pretty) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/extract/extract.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing extract.plugin.zsh..." 2 | plugins+=(ohmy:extract) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/plugins/myplugin/myplugin.plugin.zsh: -------------------------------------------------------------------------------- 1 | # fake foo/bar 2 | echo "sourcing myplugin..." 3 | plugins+=(custom:myplugin) 4 | -------------------------------------------------------------------------------- /tests/functions/t_reset: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function t_reset { 3 | 0=${(%):-%x} 4 | t_teardown 5 | t_setup 6 | source ${0:A:h:h:h}/antidote.zsh 7 | #} 8 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/oh-my.sh: -------------------------------------------------------------------------------- 1 | echo "sourcing oh-my.sh..." 2 | plugins=($plugins ohmy/ohmy) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing magic-enter.plugin.zsh..." 2 | plugins+=(ohmy:magic-enter) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar/bar.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/bar..." 2 | plugins=($plugins foo/bar) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-baz/baz.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/baz..." 2 | plugins=($plugins foo/baz) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/lib/lib1.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing ohmy/lib/lib1.zsh..." 2 | libs=($libs ohmy:lib1) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/lib/lib2.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing ohmy/lib/lib2.zsh..." 2 | libs=($libs ohmy:lib2) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/lib/lib3.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing ohmy/lib/lib3.zsh..." 2 | libs=($libs ohmy:lib2) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/macos/functions/macos_func: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function macos_func { 3 | echo macos_func "$@" 4 | } 5 | macos_func "$@" 6 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-baz/functions/baz: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function baz { 3 | echo baz function 4 | } 5 | baz "$@" 6 | -------------------------------------------------------------------------------- /tests/testdata/script-fooqux.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $ANTIDOTE_HOME/git-AT-github.com-COLON-foo-SLASH-qux ) 2 | source $ANTIDOTE_HOME/git-AT-github.com-COLON-foo-SLASH-qux/qux.plugin.zsh 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/custom/themes/ugly.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing ugly.zsh-theme..." 2 | themes=($themes ohmy:ugly) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/macos.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing macos.plugin.zsh..." 2 | plugins+=(ohmy:macos) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/themes/pretty.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing pretty.zsh-theme..." 2 | themes=($themes ohmy:pretty) 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ~* 2 | *.zwc 3 | *.zwc.old 4 | .cache/ 5 | !/tests/**/.cache/ 6 | .tmp/ 7 | .plugins/ 8 | .todo/ 9 | sandbox/ 10 | *.old 11 | **/realzdotdir/zsh_plugins.zsh 12 | foo*.* 13 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/custom/themes/pretty.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing pretty.zsh-theme..." 2 | themes=($themes ohmy:pretty) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/docker/docker.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing docker.plugin.zsh..." 2 | plugins+=(ohmy:docker) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/extract/extract.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing extract.plugin.zsh..." 2 | plugins+=(ohmy:extract) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/magic-enter/magic-enter.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing magic-enter.plugin.zsh..." 2 | plugins+=(ohmy:magic-enter) 3 | -------------------------------------------------------------------------------- /tests/testdata/script-foobar.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar ) 2 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar/bar.plugin.zsh 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/functions/macos_func: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function macos_func { 3 | echo macos_func "$@" 4 | } 5 | macos_func "$@" 6 | -------------------------------------------------------------------------------- /functions/__antidote_print_path: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | ### Pretty print a path 3 | 4 | if zstyle -t ':antidote:compatibility-mode' 'antibody'; then 5 | echo "$1" 6 | else 7 | echo "$1" | sed -e "s|^$HOME/|\$HOME/|" 8 | fi 9 | -------------------------------------------------------------------------------- /tests/testdata/real/.zsh_plugins.crlf.txt: -------------------------------------------------------------------------------- 1 | # CRLF file 2 | rupa/z 3 | zsh-users/zsh-syntax-highlighting 4 | zsh-users/zsh-completions 5 | zsh-users/zsh-autosuggestions 6 | zsh-users/zsh-history-substring-search 7 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/getantidote/zsh-defer/zsh-defer.plugin.zsh: -------------------------------------------------------------------------------- 1 | # fake foo/bar 2 | echo "sourcing getantidote/zsh-defer..." 3 | plugins=($plugins getantidote/zsh-defer) 4 | function zsh-defer { 5 | $@ 6 | } 7 | -------------------------------------------------------------------------------- /functions/__antidote_indent: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Indent strings 4 | #function __antidote_indent { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | local -a lines=("${(@f)$(__antidote_collect_input "$@")}") 7 | printf ' %s\n' $lines 8 | #} 9 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh: -------------------------------------------------------------------------------- 1 | # fake foo/bar 2 | echo "sourcing getantidote/zsh-defer..." 3 | plugins=($plugins getantidote/zsh-defer) 4 | function zsh-defer { 5 | $@ 6 | } 7 | -------------------------------------------------------------------------------- /man/footer.md: -------------------------------------------------------------------------------- 1 | # BUGS 2 | 3 | See GitHub Issues: 4 | 5 | # AUTHORS 6 | 7 | - Copyright (c) 2021-2024 Matt McElheny 8 | - antidote contributors: 9 | 10 | # LICENSE 11 | 12 | MIT 13 | -------------------------------------------------------------------------------- /tools/bumpver: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 0=${(%):-%x} 3 | bumpversion --allow-dirty ${1:-revision} 4 | newver=$(grep 'current_version' ${0:h:h}/.bumpversion.cfg | sed -E 's/^[^0-9]+(.*)$/\1/') 5 | print "Version bumped to $newver." 6 | print "Now run:" 7 | print " git commit -am 'Bump version to $newver'" | tee >(pbcopy) 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | indent_style = space 9 | indent_size = 2 10 | 11 | [*.crlf.*] 12 | end_of_line = crlf 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | 17 | [makefile] 18 | indent_style = tab 19 | indent_size = 4 20 | -------------------------------------------------------------------------------- /functions/__antidote_tourl: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Get the url from a repo bundle. 4 | #function __antidote_tourl { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | 7 | local bundle=$1 8 | local url=$bundle 9 | if [[ $bundle != *://* && $bundle != git@*:*/* ]]; then 10 | url=https://github.com/$bundle 11 | fi 12 | print $url 13 | #} 14 | -------------------------------------------------------------------------------- /tests/functions/t_unload_antidote: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | emulate -L zsh 4 | setopt local_options 5 | 6 | # unfunction all antidote 7 | for fn in ${(k)functions}; do 8 | [[ $fn == *antidote* ]] && [[ $fn != t_* ]] && unfunction -- $fn 9 | done 10 | (( $+functions[git] )) && unfunction git 11 | 12 | # unfunction zsh-defer 13 | (( $+functions[zsh-defer] )) && unfunction zsh-defer 14 | -------------------------------------------------------------------------------- /functions/__antidote_version: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Get the antidote version. 4 | #function __antidote_version { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | 0=${(%):-%x} 7 | local ver='1.9.7' 8 | local gitsha=$(git -C "${0:A:h:h}" rev-parse --short HEAD 2>/dev/null) 9 | [[ -z "$gitsha" ]] || ver="$ver ($gitsha)" 10 | print "antidote version $ver" 11 | #} 12 | -------------------------------------------------------------------------------- /tests/functions/subenv: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function subenv { 3 | emulate -L zsh; setopt local_options 4 | 5 | if (( $# == 0 )); then 6 | set -- HOME 7 | fi 8 | 9 | local -a sedargs=(-e "s|\$HOME|$HOME|g") 10 | while (( $# )); do 11 | if [[ -v "$1" ]]; then 12 | sedargs+=(-e "s|${(P)1}|\$$1|g") 13 | fi 14 | shift 15 | done 16 | sed "$sedargs[@]" 17 | #} 18 | -------------------------------------------------------------------------------- /tools/sloc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 0=${(%):-%x} 3 | BASEDIR=${0:h:h} 4 | cd $BASEDIR 5 | print "loc:" 6 | wc -l antidote.zsh ./functions/*(.) 7 | print "sloc:" 8 | for file in antidote.zsh ./functions/*(.); do 9 | lines=$(awk '/^ *[^#]+$/{print}' $file | wc -l) 10 | print $lines $file 11 | done 12 | print "sloc total:" 13 | awk '/^ *[^#]+$/{print}' antidote.zsh ./functions/*(.) | wc -l 14 | -------------------------------------------------------------------------------- /functions/antidote: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### antidote - the cure to slow zsh plugin management 4 | # 5 | # https://antidote.sh 6 | # run `antidote -h` for usage 7 | # 8 | # Note: this gets overridden if using `antidote init`. 9 | # 10 | #function antidote { 11 | 0=${(%):-%x} 12 | if ! typeset -f antidote-main > /dev/null; then 13 | source ${0:A:h:h}/antidote.zsh 14 | fi 15 | antidote-main "$@" 16 | #} 17 | -------------------------------------------------------------------------------- /antidote: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### antidote - the cure to slow zsh plugin management 4 | # 5 | # https://antidote.sh 6 | # run `antidote -h` for usage 7 | # 8 | # Note: this gets overridden if using `antidote init`. 9 | # 10 | function antidote { 11 | 0=${(%):-%x} 12 | if ! typeset -f antidote-main > /dev/null; then 13 | source ${0:A:h}/antidote.zsh 14 | fi 15 | antidote-main "$@" 16 | } 17 | antidote "$@" 18 | -------------------------------------------------------------------------------- /functions/__antidote_collect_input: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Collect 0 )); then 7 | input=("${(s.\n.)${@}}") 8 | elif [[ ! -t 0 ]]; then 9 | local data 10 | while IFS= read -r data || [[ -n "$data" ]]; do 11 | input+=("$data") 12 | done 13 | fi 14 | printf '%s\n' "${input[@]}" 15 | #} 16 | -------------------------------------------------------------------------------- /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.9.7 3 | parse = v?(?P\d+)\.(?P\d+)\.(?P\d+) 4 | serialize = {major}.{minor}.{revision} 5 | 6 | [bumpversion:file:functions/__antidote_version] 7 | 8 | [bumpversion:file:tests/README.md] 9 | 10 | [bumpversion:file:tests/test_antidote.md] 11 | 12 | [bumpversion:file:tests/test_antidote_core.md] 13 | 14 | [bumpversion:file:tests/test_cmd_update.md] 15 | 16 | [bumpversion:file:README.md] 17 | -------------------------------------------------------------------------------- /functions/__antidote_filter_defers: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Filter all but the first defer block. 4 | #function __antidote_filter_defers { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | $__adote_awkcmd ' 7 | # filter all but the first time we source zsh-defer (a 4 line if statement) 8 | BEGIN { skip=0; found=0 } 9 | skip>0 { skip-- } 10 | /^if.+functions\[zsh\-defer\]/ { if(!found) found=1; else skip=4 } 11 | skip==0 { print } 12 | ' "$@" 13 | #} 14 | -------------------------------------------------------------------------------- /man/antidote-path.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-path 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote path** - print the path of a cloned bundle 10 | 11 | # SYNOPSIS 12 | 13 | | antidote path \ 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-path** prints the path of a cloned bundle. 18 | 19 | # OPTIONS 20 | 21 | -h, \--help 22 | : Show the help documentation. 23 | 24 | [\] 25 | : The bundle whose cloned path will be printed. 26 | -------------------------------------------------------------------------------- /man/antidote-help.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-help 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote help** - show antidote documentation 10 | 11 | # SYNOPSIS 12 | 13 | | antidote help [\] 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-help** is used to show context-sensitive help for antidote and its commands. 18 | 19 | # OPTIONS 20 | 21 | -h, \--help 22 | : Inception-style meta-help recursively. 23 | 24 | [*\*] 25 | : Show help for a specific command. 26 | -------------------------------------------------------------------------------- /man/antidote-purge.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-purge 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote purge** - remove a bundle 10 | 11 | # SYNOPSIS 12 | 13 | | antidote purge \ 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-purge** removes a cloned bundle. 18 | 19 | # OPTIONS 20 | 21 | -h, \--help 22 | : Show the help documentation. 23 | 24 | -a, \--all 25 | : Purge all cloned bundles. 26 | 27 | \ 28 | : Bundle to be purged. 29 | 30 | # EXAMPLES 31 | 32 | | antidote purge zsh-users/zsh-history-substring-search 33 | -------------------------------------------------------------------------------- /man/antidote-update.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-update 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote update** - update bundles 10 | 11 | # SYNOPSIS 12 | 13 | | antidote update [-h|\--help] [-s|\--self] [-b|\--bundles] 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-update** updates antidote and its cloned bundles. 18 | 19 | # OPTIONS 20 | 21 | -h, \--help 22 | : Show the help documentation. 23 | 24 | -s, \--self 25 | : Update antidote. 26 | 27 | -b, \--bundles 28 | : Update bundles. 29 | 30 | # EXAMPLES 31 | 32 | | antidote update 33 | -------------------------------------------------------------------------------- /antidote.zsh: -------------------------------------------------------------------------------- 1 | # shell prereq 2 | if test -z "$ZSH_VERSION"; then 3 | shellname=$(ps -p $$ -oargs= | awk 'NR=1{print $1}') 4 | echo >&2 "antidote: Expecting zsh. Found '$shellname'." 5 | return 1 6 | else 7 | builtin autoload -Uz is-at-least 8 | if ! is-at-least 5.4.2; then 9 | echo >&2 "antidote: Unsupported Zsh version '$ZSH_VERSION'. Expecting Zsh >5.4.2." 10 | return 1 11 | fi 12 | 13 | typeset -f __antidote_setup &>/dev/null && unfunction __antidote_setup 14 | 0=${(%):-%N} 15 | builtin autoload -Uz ${0:A:h}/functions/__antidote_setup 16 | __antidote_setup 17 | fi 18 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | test: 10 | strategy: 11 | matrix: 12 | os: [macos-latest, ubuntu-latest] 13 | runs-on: ${{ matrix.os }} 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/checkout@v3 17 | with: 18 | repository: "aureliojargas/clitest" 19 | path: bin/clitest 20 | - run: sudo apt install zsh 21 | if: ${{ runner.os == 'Linux' }} 22 | - run: PATH=$GITHUB_WORKSPACE/bin/clitest:$PATH make test 23 | shell: zsh {0} 24 | -------------------------------------------------------------------------------- /man/antidote-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-list 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote list** - list cloned bundles 10 | 11 | # SYNOPSIS 12 | 13 | | antidote list [-h|\--help] [-s|\--short] [-d|\--dirs] [-u|\--url] 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-list** lists the cloned bundles in **antidote home**. 18 | 19 | # OPTIONS 20 | 21 | -h, \--help 22 | : Show the help documentation. 23 | 24 | -s, \--short 25 | : Show shortened repos where possible. 26 | 27 | -d, \--dirs 28 | : Show only bundle directories. 29 | 30 | -u, \--url 31 | : Show bundle URLs. 32 | -------------------------------------------------------------------------------- /tests/testdata/.zsh_plugins_repos.txt: -------------------------------------------------------------------------------- 1 | # comments 2 | user/repo 3 | 4 | # blank lines 5 | 6 | # regular repos 7 | https://github.com/user/repo 8 | http://github.com/user/repo.git 9 | https://github.com/user/repo 10 | git@github.com:user/repo 11 | 12 | # annotations 13 | bar/baz path:plugins/qux 14 | bar/baz path:themes/qux.zsh-theme 15 | 16 | # branch 17 | foobar/foobar branch:baz 18 | 19 | # defer 20 | https://github.com/foo/qux kind:defer 21 | https://github.com/foo/baz kind:defer 22 | 23 | # non repos 24 | foo 25 | ~/.zplugins/bar 26 | $ZDOTDIR/plugins/bar 27 | 28 | # dupes 29 | user/repo 30 | https://github.com/user/repo 31 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/.zsh_plugins.txt: -------------------------------------------------------------------------------- 1 | # local plugins 2 | ~/foo/bar 3 | $ZSH_CUSTOM path:plugins/myplugin 4 | 5 | # repo plugins 6 | foo/bar 7 | git@github.com:foo/qux.git # trailing comments 8 | 9 | # kind:clone 10 | getantidote/zsh-defer kind:clone # more trailing comments 11 | 12 | # kind:zsh 13 | foo/bar kind:zsh 14 | 15 | # kind:fpath 16 | foo/bar kind:fpath 17 | 18 | # kind:path 19 | foo/bar kind:path 20 | 21 | # subpath plugins 22 | ohmy/ohmy path:lib 23 | ohmy/ohmy path:plugins/extract 24 | 25 | # deferred 26 | ohmy/ohmy path:plugins/magic-enter kind:defer 27 | 28 | # theme 29 | ohmy/ohmy path:custom/themes/pretty.zsh-theme 30 | -------------------------------------------------------------------------------- /tests/testdata/.zsh_plugins_purged.txt: -------------------------------------------------------------------------------- 1 | # local plugins 2 | ~/foo/bar 3 | $ZSH_CUSTOM path:plugins/myplugin 4 | 5 | # repo plugins 6 | # foo/bar 7 | git@github.com:foo/qux.git # trailing comments 8 | 9 | # kind:clone 10 | getantidote/zsh-defer kind:clone # more trailing comments 11 | 12 | # kind:zsh 13 | # foo/bar kind:zsh 14 | 15 | # kind:fpath 16 | # foo/bar kind:fpath 17 | 18 | # kind:path 19 | # foo/bar kind:path 20 | 21 | # subpath plugins 22 | ohmy/ohmy path:lib 23 | ohmy/ohmy path:plugins/extract 24 | 25 | # deferred 26 | ohmy/ohmy path:plugins/magic-enter kind:defer 27 | 28 | # theme 29 | ohmy/ohmy path:custom/themes/pretty.zsh-theme 30 | -------------------------------------------------------------------------------- /functions/__antidote_bundle_name: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Get the short name of the bundle. 4 | #function __antidote_bundle_name { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 7 | local bundle=$1 8 | local bundle_type="$(__antidote_bundle_type $bundle)" 9 | if [[ "$bundle_type" == (url|sshurl) ]] ; then 10 | bundle=${bundle%.git} 11 | bundle=${bundle:gs/\:/\/} 12 | local parts=(${(ps./.)bundle}) 13 | print ${parts[-2]}/${parts[-1]} 14 | else 15 | print $bundle | sed -e "s|^\~/|$HOME/|" -e "s|^$HOME|\$HOME|" 16 | fi 17 | #} 18 | -------------------------------------------------------------------------------- /functions/__antidote_initfiles: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Get the path to a plugin's init file. 4 | #function __antidote_initfiles { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | typeset -ga reply=() 7 | local dir=${1:A} 8 | local initfiles=($dir/${dir:A:t}.plugin.zsh(N)) 9 | [[ $#initfiles -gt 0 ]] || initfiles=($dir/*.plugin.zsh(N)) 10 | [[ $#initfiles -gt 0 ]] || initfiles=($dir/*.zsh(N)) 11 | [[ $#initfiles -gt 0 ]] || initfiles=($dir/*.sh(N)) 12 | [[ $#initfiles -gt 0 ]] || initfiles=($dir/*.zsh-theme(N)) 13 | 14 | typeset -ga reply=($initfiles) 15 | printf "%s\n" ${(u)initfiles[@]} 16 | (( $#initfiles )) || return 1 17 | #} 18 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/.zplugins_fake_load: -------------------------------------------------------------------------------- 1 | # repo plugins 2 | foo/bar 3 | git@github.com:foo/qux.git # trailing comments 4 | 5 | # kind:clone 6 | getantidote/zsh-defer kind:clone # more trailing comments 7 | 8 | # kind:zsh 9 | foo/bar kind:zsh 10 | 11 | # kind:fpath 12 | foo/bar kind:fpath 13 | 14 | # kind:path 15 | foo/bar kind:path 16 | 17 | # subpath plugins 18 | ohmy/ohmy path:lib 19 | ohmy/ohmy path:plugins/extract 20 | 21 | # fpath-rule 22 | ohmy/ohmy path:plugins/docker fpath-rule:prepend 23 | ohmy/ohmy path:plugins/docker fpath-rule:append 24 | 25 | # deferred 26 | ohmy/ohmy path:plugins/magic-enter kind:defer 27 | 28 | # theme 29 | ohmy/ohmy path:custom/themes/pretty.zsh-theme 30 | -------------------------------------------------------------------------------- /functions/antidote-home: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Print where antidote is cloning bundles. 4 | # 5 | # usage: antidote home [-h|--help] 6 | # 7 | # Can be overridden by setting `$ANTIDOTE_HOME`. 8 | # 9 | #function antidote-home { 10 | emulate -L zsh; setopt local_options $_adote_funcopts 11 | 12 | typeset -g REPLY= 13 | local o_help 14 | zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1 15 | 16 | if (( $#o_help )); then 17 | antidote-help home 18 | return 19 | fi 20 | 21 | local result 22 | if [[ -n "$ANTIDOTE_HOME" ]]; then 23 | result=$ANTIDOTE_HOME 24 | else 25 | result=$(__antidote_get_cachedir "antidote") 26 | fi 27 | print $result 28 | typeset -g REPLY=$result 29 | #} 30 | -------------------------------------------------------------------------------- /man/antidote-home.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-home 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote home** - print where antidote is cloning bundles 10 | 11 | # SYNOPSIS 12 | 13 | | antidote home 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-home** shows you where antidote stores its cloned repos. It is not the home of the antidote utility itself. 18 | 19 | | antidote home 20 | 21 | You can override antidote's default home directory by setting the _\$ANTIDOTE_HOME_ variable in your **.zshrc**. 22 | 23 | # OPTIONS 24 | 25 | -h, \--help 26 | : Show the help documentation. 27 | 28 | # EXAMPLES 29 | 30 | You can clear out all your cloned repos like so: 31 | 32 | | rm -rfi $(antidote home) 33 | -------------------------------------------------------------------------------- /functions/__antidote_bundle_zcompile: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Compile bundles 4 | #function __antidote_bundle_zcompile { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | builtin autoload -Uz zrecompile 7 | 8 | local -a bundles 9 | if [[ -z "$1" ]]; then 10 | bundles=($(antidote-list --dirs)) 11 | elif [[ -f "$1" ]]; then 12 | zrecompile -pq "$1" 13 | return 14 | elif [[ -d "$1" ]]; then 15 | bundles=($1) 16 | else 17 | bundles=($(antidote-path "$1")) 18 | fi 19 | 20 | local bundle zfile 21 | for bundle in $bundles; do 22 | for zfile in ${bundle}/**/*.zsh{,-theme}(N); do 23 | [[ $zfile != */test-data/* ]] || continue 24 | zrecompile -pq "$zfile" 25 | done 26 | done 27 | # } 28 | -------------------------------------------------------------------------------- /functions/antidote-help: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Show antidote documentation. 4 | # 5 | # usage: antidote [-h|--help] [] 6 | # antidote help [] 7 | # 8 | 9 | #function antidote-help { 10 | emulate -L zsh; setopt local_options $_adote_funcopts 11 | 12 | local o_help 13 | zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1 14 | 15 | local manpage 16 | 17 | if (( $#o_help )); then 18 | manpage=antidote-help 19 | elif [[ "$1" == antidote ]]; then 20 | manpage=antidote 21 | elif [[ -n "$1" ]]; then 22 | manpage="antidote-${1}" 23 | fi 24 | 25 | if (( $+commands[man] )) && [[ -n "$manpage" ]]; then 26 | man "$manpage" || { 27 | __antidote_usage && return 1 28 | } 29 | else 30 | __antidote_usage 31 | fi 32 | #} 33 | -------------------------------------------------------------------------------- /man/man1/antidote-path.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-path" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote path\f[R] \- print the path of a cloned bundle 6 | .SH SYNOPSIS 7 | .PP 8 | antidote path 9 | .SH DESCRIPTION 10 | \f[B]antidote\-path\f[R] prints the path of a cloned bundle. 11 | .SH OPTIONS 12 | .TP 13 | \-h, \-\-help 14 | Show the help documentation. 15 | .TP 16 | [] 17 | The bundle whose cloned path will be printed. 18 | .SH BUGS 19 | See GitHub Issues: \c 20 | .UR https://github.com/mattmc3/antidote/issues 21 | .UE \c 22 | .SH AUTHORS 23 | .IP \[bu] 2 24 | Copyright (c) 2021\-2024 Matt McElheny 25 | .IP \[bu] 2 26 | antidote contributors: \c 27 | .UR https://github.com/mattmc3/antidote/graphs/contributors 28 | .UE \c 29 | .SH LICENSE 30 | MIT 31 | -------------------------------------------------------------------------------- /functions/__antidote_get_cachedir: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Get the default cache directory per OS 4 | #function __antidote_get_cachedir { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | 7 | local result 8 | if [[ "${OSTYPE}" == darwin* ]]; then 9 | result=$HOME/Library/Caches 10 | elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then 11 | result=${LOCALAPPDATA:-$LocalAppData} 12 | if type cygpath > /dev/null; then 13 | result=$(cygpath "$result") 14 | fi 15 | elif [[ -n "$XDG_CACHE_HOME" ]]; then 16 | result=$XDG_CACHE_HOME 17 | else 18 | result=$HOME/.cache 19 | fi 20 | 21 | if [[ -n "$1" ]]; then 22 | if [[ $result == *\\* ]] && [[ $result != */* ]]; then 23 | result+="\\$1" 24 | else 25 | result+="/$1" 26 | fi 27 | fi 28 | print -r -- $result 29 | #} 30 | -------------------------------------------------------------------------------- /tests/test_cmd_update.md: -------------------------------------------------------------------------------- 1 | # antidote update tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Update 12 | 13 | ```zsh 14 | % antidote update 15 | Updating bundles... 16 | antidote: checking for updates: https://github.com/foo/bar 17 | antidote: checking for updates: https://github.com/foo/baz 18 | antidote: checking for updates: git@github.com:foo/qux 19 | antidote: checking for updates: https://github.com/getantidote/zsh-defer 20 | antidote: checking for updates: https://github.com/ohmy/ohmy 21 | Waiting for bundle updates to complete... 22 | 23 | Bundle updates complete. 24 | 25 | Updating antidote... 26 | antidote self-update complete. 27 | 28 | antidote version 1.9.7 29 | % 30 | ``` 31 | 32 | ## Teardown 33 | 34 | ```zsh 35 | % t_teardown 36 | % 37 | ``` 38 | -------------------------------------------------------------------------------- /man/man1/antidote-help.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-help" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote help\f[R] \- show antidote documentation 6 | .SH SYNOPSIS 7 | .PP 8 | antidote help [] 9 | .SH DESCRIPTION 10 | \f[B]antidote\-help\f[R] is used to show context\-sensitive help for 11 | antidote and its commands. 12 | .SH OPTIONS 13 | .TP 14 | \-h, \-\-help 15 | Inception\-style meta\-help recursively. 16 | .TP 17 | [\f[I]\f[R]] 18 | Show help for a specific command. 19 | .SH BUGS 20 | See GitHub Issues: \c 21 | .UR https://github.com/mattmc3/antidote/issues 22 | .UE \c 23 | .SH AUTHORS 24 | .IP \[bu] 2 25 | Copyright (c) 2021\-2024 Matt McElheny 26 | .IP \[bu] 2 27 | antidote contributors: \c 28 | .UR https://github.com/mattmc3/antidote/graphs/contributors 29 | .UE \c 30 | .SH LICENSE 31 | MIT 32 | -------------------------------------------------------------------------------- /functions/antidote-init: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Initialize the shell for dynamic bundles. 4 | # 5 | # usage: antidote init [-h|--help] 6 | # source <(antidote init) 7 | # 8 | # This function changes how the `antidote` command works by sourcing the results of 9 | # `antidote bundle` instead of just generating the Zsh script. 10 | #function antidote-init { 11 | local o_help 12 | zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1 13 | 14 | if (( $#o_help )); then 15 | antidote-help init 16 | return 17 | fi 18 | 19 | local script=( 20 | '#!/usr/bin/env zsh' 21 | 'function antidote {' 22 | ' case "$1" in' 23 | ' bundle)' 24 | ' source <( antidote-main $@ ) || antidote-main $@' 25 | ' ;;' 26 | ' *)' 27 | ' antidote-main $@' 28 | ' ;;' 29 | ' esac' 30 | '}' 31 | ) 32 | printf "%s\n" "${script[@]}" 33 | #} 34 | -------------------------------------------------------------------------------- /man/man1/antidote-purge.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-purge" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote purge\f[R] \- remove a bundle 6 | .SH SYNOPSIS 7 | .PP 8 | antidote purge 9 | .SH DESCRIPTION 10 | \f[B]antidote\-purge\f[R] removes a cloned bundle. 11 | .SH OPTIONS 12 | .TP 13 | \-h, \-\-help 14 | Show the help documentation. 15 | .TP 16 | \-a, \-\-all 17 | Purge all cloned bundles. 18 | .TP 19 | 20 | Bundle to be purged. 21 | .SH EXAMPLES 22 | .PP 23 | \ \ antidote purge zsh\-users/zsh\-history\-substring\-search 24 | .SH BUGS 25 | See GitHub Issues: \c 26 | .UR https://github.com/mattmc3/antidote/issues 27 | .UE \c 28 | .SH AUTHORS 29 | .IP \[bu] 2 30 | Copyright (c) 2021\-2024 Matt McElheny 31 | .IP \[bu] 2 32 | antidote contributors: \c 33 | .UR https://github.com/mattmc3/antidote/graphs/contributors 34 | .UE \c 35 | .SH LICENSE 36 | MIT 37 | -------------------------------------------------------------------------------- /man/man1/antidote-update.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-update" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote update\f[R] \- update bundles 6 | .SH SYNOPSIS 7 | .PP 8 | antidote update [\-h|\-\-help] [\-s|\-\-self] [\-b|\-\-bundles] 9 | .SH DESCRIPTION 10 | \f[B]antidote\-update\f[R] updates antidote and its cloned bundles. 11 | .SH OPTIONS 12 | .TP 13 | \-h, \-\-help 14 | Show the help documentation. 15 | .TP 16 | \-s, \-\-self 17 | Update antidote. 18 | .TP 19 | \-b, \-\-bundles 20 | Update bundles. 21 | .SH EXAMPLES 22 | .PP 23 | antidote update 24 | .SH BUGS 25 | See GitHub Issues: \c 26 | .UR https://github.com/mattmc3/antidote/issues 27 | .UE \c 28 | .SH AUTHORS 29 | .IP \[bu] 2 30 | Copyright (c) 2021\-2024 Matt McElheny 31 | .IP \[bu] 2 32 | antidote contributors: \c 33 | .UR https://github.com/mattmc3/antidote/graphs/contributors 34 | .UE \c 35 | .SH LICENSE 36 | MIT 37 | -------------------------------------------------------------------------------- /tests/test_setopts_special.md: -------------------------------------------------------------------------------- 1 | # antidote handles special Zsh options 2 | 3 | ## Setup 4 | 5 | Tests to handle special Zsh options. [#154](https://github.com/mattmc3/antidote/issues/154). 6 | 7 | ```zsh 8 | % source ./tests/_setup.zsh 9 | % setopt KSH_ARRAYS SH_GLOB 10 | % source ./antidote.zsh 11 | % 12 | ``` 13 | 14 | # Ensure bundle works 15 | 16 | ```zsh 17 | % antidote bundle <$ZDOTDIR/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh 18 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv #=> --file testdata/.zsh_plugins.zsh 19 | % 20 | ``` 21 | 22 | # Ensure options remained 23 | 24 | ```zsh 25 | % [[ -o KSH_ARRAYS ]] && echo KSH_ARRAYS 26 | KSH_ARRAYS 27 | % [[ -o SH_GLOB ]] && echo SH_GLOB 28 | SH_GLOB 29 | % # unset 30 | % unsetopt KSH_ARRAYS SH_GLOB 31 | % [[ -o KSH_ARRAYS ]] && echo KSH_ARRAYS 32 | % [[ -o SH_GLOB ]] && echo SH_GLOB 33 | % 34 | ``` 35 | 36 | ## Teardown 37 | 38 | ```zsh 39 | % t_teardown 40 | % 41 | ``` 42 | -------------------------------------------------------------------------------- /functions/__antidote_del: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # Call me paranoid, but I want to be really certain antidote will never rm something it 3 | # shouldn't. This function wraps rm to double check that any paths being removed are 4 | # valid. If it's not in your $HOME or $TMPDIR, we need to block it. 5 | 6 | #function __antidote_del { 7 | emulate -L zsh; setopt local_options 8 | 9 | local -a rmflags rmpaths 10 | local p 11 | 12 | while (( $# )); do 13 | case "$1" in 14 | --) shift; break ;; 15 | -*) rmflags+=($1) ;; 16 | *) break ;; 17 | esac 18 | shift 19 | done 20 | 21 | (( $# > 0 )) || return 1 22 | 23 | for p in $@; do 24 | p="${p:a}" 25 | if [[ "$p" != $HOME/* ]] && [[ "$p" != ${TMPDIR:-/tmp}/* ]]; then 26 | print -ru2 -- "antidote: Blocked attempt to rm path: '$p'." 27 | return 1 28 | fi 29 | done 30 | 31 | command rm ${rmflags[@]} -- "$@" 32 | #} 33 | -------------------------------------------------------------------------------- /tests/functions/t_setup_real: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function t_setup_real { 3 | 0=${(%):-%x} 4 | local testdir="${0:A:h:h}" 5 | local prjdir="${0:A:h:h:h}" 6 | 7 | # undo setup so we clone for real 8 | zstyle ':antidote:tests' cloning 'on' 9 | (( $+functions[git] )) && unfunction git 10 | 11 | # unset other testing zstyles 12 | zstyle -d ':antidote:defer' bundle 13 | 14 | # unset rupa/z 15 | (( $+aliases[z] )) && unalias z 16 | 17 | # replace .zsh_plugins.txt with real versions 18 | local file 19 | for file in .zsh_plugins.txt .zsh_plugins.zsh; do 20 | [[ -f $ZDOTDIR/$file ]] && command rm -f -- "$ZDOTDIR/$file" 21 | [[ -f $testdir/real/$file ]] && command rm -f -- "$testdir/real/$file" 22 | done 23 | 24 | # clean out antidote home 25 | [[ -d $ANTIDOTE_HOME ]] && command rm -rf -- "$ANTIDOTE_HOME" 26 | mkdir -p "$ANTIDOTE_HOME" 27 | 28 | # source antidote 29 | source $prjdir/antidote.zsh 30 | #} 31 | -------------------------------------------------------------------------------- /tests/test_cmd_init.md: -------------------------------------------------------------------------------- 1 | # antidote init tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Init 12 | 13 | ```zsh 14 | % antidote init 15 | #!/usr/bin/env zsh 16 | function antidote { 17 | case "$1" in 18 | bundle) 19 | source <( antidote-main $@ ) || antidote-main $@ 20 | ;; 21 | *) 22 | antidote-main $@ 23 | ;; 24 | esac 25 | } 26 | % 27 | ``` 28 | 29 | Load plugins dynamically 30 | 31 | ```zsh 32 | % source <(antidote init) 33 | % antidote bundle foo/bar 34 | sourcing foo/bar... 35 | % antidote bundle foo/baz autoload:functions 36 | sourcing foo/baz... 37 | % antidote bundle $ZDOTDIR/custom/lib 38 | sourcing custom lib1.zsh... 39 | sourcing custom lib2.zsh... 40 | % echo $#plugins 41 | 2 42 | % echo $#libs 43 | 2 44 | % echo $+functions[baz] 45 | 1 46 | % 47 | ``` 48 | 49 | ## Teardown 50 | 51 | ```zsh 52 | % t_teardown 53 | % 54 | ``` 55 | -------------------------------------------------------------------------------- /functions/antidote-load: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Statically source all bundles from the plugins file. 4 | # 5 | # usage: antidote load [-h|--help] [ []] 6 | # 7 | #function antidote-load { 8 | if [[ "$1" == (-h|--help) ]]; then 9 | antidote-help load 10 | return 11 | fi 12 | 13 | # We can't use LOCAL_OPTIONS because sourcing plugins means we'd lose any Zsh options 14 | # set in those plugins, so we delegate all the work to __antidote_load_prep where 15 | # we can safely use LOCAL_OPTIONS. For this function, we should do the bare minimum 16 | # so the user can set whatever crazy Zsh options they want, and antidote doesn't need 17 | # to concern itself with that. 18 | # 19 | # "Is your house on fire, Clark? No, Aunt Bethany, those are the user's Zsh options." 20 | # 21 | typeset -g REPLY= 22 | __antidote_load_prep "$@" || return 1 23 | [[ -f "$REPLY" ]] || return 2 24 | source "$REPLY" 25 | unset REPLY 26 | #} 27 | -------------------------------------------------------------------------------- /functions/__antidote_usage: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Print usage. 4 | #function __antidote_usage { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | cat<] [ ...] 10 | 11 | flags: 12 | -h, --help Show context-sensitive help 13 | -v, --version Show application version 14 | 15 | commands: 16 | help Show documentation 17 | load Statically source all bundles from the plugins file 18 | bundle Clone bundle(s) and generate the static load script 19 | install Clone a new bundle and add it to your plugins file 20 | update Update antidote and its cloned bundles 21 | purge Remove a cloned bundle 22 | home Print where antidote is cloning bundles 23 | list List cloned bundles 24 | path Print the path of a cloned bundle 25 | init Initialize the shell for dynamic bundles 26 | EOS 27 | #} 28 | -------------------------------------------------------------------------------- /tests/test_alt_zsh_defer_bundle.md: -------------------------------------------------------------------------------- 1 | # antidote test alternative zsh-defer repo 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Customize zsh-defer 12 | 13 | If the user forks zsh-defer, support setting a zstyle for an alternative repo location. 14 | 15 | ### General 16 | 17 | ```zsh 18 | % zstyle ':antidote:bundle' use-friendly-names on 19 | % zstyle ':antidote:defer' bundle 'custom/zsh-defer' 20 | % antidote bundle 'zsh-users/zsh-autosuggestions kind:defer' 2>/dev/null 21 | if ! (( $+functions[zsh-defer] )); then 22 | fpath+=( $HOME/.cache/antidote/custom/zsh-defer ) 23 | source $HOME/.cache/antidote/custom/zsh-defer/zsh-defer.plugin.zsh 24 | fi 25 | fpath+=( $HOME/.cache/antidote/zsh-users/zsh-autosuggestions ) 26 | zsh-defer source $HOME/.cache/antidote/zsh-users/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh 27 | % 28 | ``` 29 | 30 | ## Teardown 31 | 32 | ```zsh 33 | % t_teardown 34 | % 35 | ``` 36 | -------------------------------------------------------------------------------- /man/man1/antidote-list.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-list" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote list\f[R] \- list cloned bundles 6 | .SH SYNOPSIS 7 | .PP 8 | antidote list [\-h|\-\-help] [\-s|\-\-short] [\-d|\-\-dirs] 9 | [\-u|\-\-url] 10 | .SH DESCRIPTION 11 | \f[B]antidote\-list\f[R] lists the cloned bundles in \f[B]antidote 12 | home\f[R]. 13 | .SH OPTIONS 14 | .TP 15 | \-h, \-\-help 16 | Show the help documentation. 17 | .TP 18 | \-s, \-\-short 19 | Show shortened repos where possible. 20 | .TP 21 | \-d, \-\-dirs 22 | Show only bundle directories. 23 | .TP 24 | \-u, \-\-url 25 | Show bundle URLs. 26 | .SH BUGS 27 | See GitHub Issues: \c 28 | .UR https://github.com/mattmc3/antidote/issues 29 | .UE \c 30 | .SH AUTHORS 31 | .IP \[bu] 2 32 | Copyright (c) 2021\-2024 Matt McElheny 33 | .IP \[bu] 2 34 | antidote contributors: \c 35 | .UR https://github.com/mattmc3/antidote/graphs/contributors 36 | .UE \c 37 | .SH LICENSE 38 | MIT 39 | -------------------------------------------------------------------------------- /man/antidote-init.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-init 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote init** - initialize the shell for dynamic bundles 10 | 11 | # SYNOPSIS 12 | 13 | | source <(antidote init) 14 | 15 | # DESCRIPTION 16 | 17 | **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. 18 | 19 | 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. 20 | 21 | Typical usage involves adding this snippet to your **.zshrc** before using **antidote bundle** commands: 22 | 23 | | source <(antidote init) 24 | 25 | # OPTIONS 26 | 27 | -h, \--help 28 | : Show the help documentation. 29 | -------------------------------------------------------------------------------- /tools/run-clitests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 0=${(%):-%x} 3 | setopt extended_glob 4 | 5 | cd ${0:A:h:h} 6 | 7 | local o_unit o_rev 8 | zparseopts -D -M -- -unit=o_unit -rev=o_rev || return 1 9 | 10 | testfiles=() 11 | if (( $# > 0 )); then 12 | testfiles=($@) 13 | elif (( $#o_unit )); then 14 | testfiles=($PWD/tests/*.md~*test_real*~*foo*) 15 | else 16 | testfiles=($PWD/tests/*.md) 17 | fi 18 | 19 | # if tests are run in reverse order, I can catch places where I didn't teardown properly 20 | if (( $#o_rev )); then 21 | testfiles=(${(O)testfiles}) 22 | fi 23 | 24 | # foo example test command 25 | # env -i PATH=$PATH FPATH=$FPATH \ 26 | # zsh -f -- =clitest --list-run --progress dot --prompt '%' --color always $PWD/tests/foo.md 27 | 28 | env -i PATH=$PATH FPATH=$FPATH PAGER=cat \ 29 | zsh -f -- \ 30 | =clitest \ 31 | --list-run --progress dot --prompt '%' \ 32 | --color always \ 33 | --pre-flight 'git --version; print $PWD $VENDOR $OSTYPE =zsh $ZSH_VERSION $ZSH_PATCHLEVEL' \ 34 | -- $testfiles 35 | -------------------------------------------------------------------------------- /functions/__antidote_parse_bundles: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Parse antidote's bundle DSL. 4 | #function __antidote_parse_bundles { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | $__adote_awkcmd ' 7 | BEGIN { RS="[\r\n]" } 8 | 9 | # skip comments and empty lines 10 | /^ *$/ || /^ *#/ {next} 11 | 12 | # strip trailing comments 13 | { sub(/[ \t]#.*$/,"",$0) } 14 | 15 | # escape leading $ variables 16 | { sub(/^\$/,"\\$",$0) } 17 | 18 | # handle extension functionality (eg :use ohmyzsh) 19 | $1~/^:/ { 20 | sub(/^:/,"",$1) 21 | printf "antidote-script-" $1 22 | for (i=2; i<=NF; i++) { 23 | printf " %s",$i 24 | } 25 | printf "\n" 26 | next 27 | } 28 | 29 | # move flags to front and call antidote-script 30 | { 31 | sub(/ #.*$/,"",$0) 32 | printf "antidote-script" 33 | for (i=2; i<=NF; i++) { 34 | sub(/^/,"--",$i) 35 | sub(/:/," ",$i) 36 | printf " %s",$i 37 | } 38 | printf " %s\n",$1 39 | } 40 | ' "$@" 41 | #} 42 | -------------------------------------------------------------------------------- /man/man1/antidote-home.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-home" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote home\f[R] \- print where antidote is cloning bundles 6 | .SH SYNOPSIS 7 | .PP 8 | antidote home 9 | .SH DESCRIPTION 10 | \f[B]antidote\-home\f[R] shows you where antidote stores its cloned 11 | repos. 12 | It is not the home of the antidote utility itself. 13 | .PP 14 | \ \ antidote home 15 | .PP 16 | You can override antidote\[cq]s default home directory by setting the 17 | \f[I]$ANTIDOTE_HOME\f[R] variable in your \f[B].zshrc\f[R]. 18 | .SH OPTIONS 19 | .TP 20 | \-h, \-\-help 21 | Show the help documentation. 22 | .SH EXAMPLES 23 | You can clear out all your cloned repos like so: 24 | .PP 25 | \ \ rm \-rfi $(antidote home) 26 | .SH BUGS 27 | See GitHub Issues: \c 28 | .UR https://github.com/mattmc3/antidote/issues 29 | .UE \c 30 | .SH AUTHORS 31 | .IP \[bu] 2 32 | Copyright (c) 2021\-2024 Matt McElheny 33 | .IP \[bu] 2 34 | antidote contributors: \c 35 | .UR https://github.com/mattmc3/antidote/graphs/contributors 36 | .UE \c 37 | .SH LICENSE 38 | MIT 39 | -------------------------------------------------------------------------------- /tests/functions/t_teardown: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | #function t_teardown { 4 | emulate -L zsh 5 | setopt local_options 6 | 7 | # reset current session 8 | HOME=$T_PREV_HOME 9 | ZDOTDIR=$T_PREV_ZDOTDIR 10 | 11 | # unfunction all antidote 12 | for fn in ${(k)functions}; do 13 | [[ $fn == *antidote* ]] && unfunction -- $fn 14 | done 15 | (( $+functions[git] )) && unfunction git 16 | 17 | # unfunction zsh-defer 18 | (( $+functions[zsh-defer] )) && unfunction zsh-defer 19 | 20 | # restore original path/fpath 21 | path=( $T_PREV_PATH ) 22 | fpath=( $T_PREV_FPATH ) 23 | 24 | # restore original zstyles 25 | source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}') 26 | source <(printf '%s\n' $T_PREV_ZSTYLES) 27 | 28 | # remove tempdir 29 | [[ -d "$T_TEMPDIR" ]] && command rm -rf -- "$T_TEMPDIR" 30 | 31 | # remove vars 32 | for var in \ 33 | ANTIDOTE_HOME \ 34 | T_TEMPDIR \ 35 | T_PREV_HOME \ 36 | T_PREV_ZDOTDIR \ 37 | T_PREV_PATH \ 38 | T_PREV_FPATH \ 39 | plugins \ 40 | libs 41 | do 42 | [[ -v $var ]] && unset $var 43 | done 44 | #} 45 | -------------------------------------------------------------------------------- /functions/antidote-path: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Print the path of a cloned bundle. 4 | # 5 | # usage: antidote path [-h|--help] 6 | # 7 | #function antidote-path { 8 | emulate -L zsh; setopt local_options $_adote_funcopts 9 | 10 | local o_help 11 | zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1 12 | 13 | if (( $#o_help )); then 14 | antidote-help path 15 | return 16 | fi 17 | 18 | local -a bundles=("${(@f)$(__antidote_collect_input "$@")}") 19 | if (( $#bundles == 0 )); then 20 | print -ru2 "antidote: error: required argument 'bundle' not provided, try --help" 21 | return 1 22 | fi 23 | 24 | local bundle bundledir 25 | local -a results=() 26 | for bundle in $bundles; do 27 | if [[ $bundle == '$'* ]] && [[ $bundle != *'('* ]] && [[ $bundle != *';'* ]]; then 28 | bundle=$(eval print $bundle) 29 | fi 30 | bundledir=$(__antidote_bundle_dir $bundle) 31 | if [[ ! -d $bundledir ]]; then 32 | print -ru2 "antidote: error: $bundle does not exist in cloned paths" 33 | return 1 34 | else 35 | results+=("$bundledir") 36 | fi 37 | done 38 | print -l -- $results 39 | #} 40 | -------------------------------------------------------------------------------- /tests/test_cmd_main.md: -------------------------------------------------------------------------------- 1 | # antidote main tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Test main 12 | 13 | Main is core to everything, so we don't need to test much here. 14 | 15 | ```zsh 16 | % antidote-main --version &>/dev/null #=> --exit 0 17 | % 18 | ``` 19 | 20 | ## Lazy config 21 | 22 | Tests for lazy-loading antidote. 23 | 24 | - Fix [#54](https://github.com/mattmc3/antidote/issues/54) 25 | 26 | ```zsh 27 | % # Unload antidote 28 | % echo $+functions[antidote-main] 29 | 1 30 | % t_unload_antidote 31 | % echo $+functions[antidote-main] 32 | 0 33 | % # Now, lazy load it and make sure it works 34 | % autoload -Uz $PWD/antidote 35 | % antidote -v &>/dev/null; echo $? 36 | 0 37 | % # Now, tear down again 38 | % echo $+functions[antidote-main] 39 | 1 40 | % t_unload_antidote 41 | % echo $+functions[antidote-main] 42 | 0 43 | % # Now, lazy load from the functions dir 44 | % autoload -Uz $PWD/functions/antidote 45 | % antidote -v &>/dev/null; echo $? 46 | 0 47 | % echo $+functions[antidote-main] 48 | 1 49 | % 50 | ``` 51 | 52 | ## Teardown 53 | 54 | ```zsh 55 | % t_teardown 56 | % 57 | ``` 58 | -------------------------------------------------------------------------------- /man/antidote-load.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-load 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote load** - statically source bundles 10 | 11 | # SYNOPSIS 12 | 13 | | antidote load [\ [\]] 14 | 15 | # DESCRIPTION 16 | 17 | **antidote-load** will turn the bundle file into a static load file and then source it. 18 | 19 | The default bundle file is **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt**. This can be overridden with the following **zstyle**: 20 | 21 | | zstyle \':antidote:bundle\' file /path/to/my/bundle_file.txt 22 | 23 | The default static file is **${ZDOTDIR:-\$HOME}/.zsh_plugins.zsh**. This can be overridden with the following **zstyle**: 24 | 25 | | zstyle \':antidote:static\' file /path/to/my/static_file.zsh 26 | 27 | # OPTIONS 28 | 29 | -h, \--help 30 | : Show the help documentation. 31 | 32 | [\] 33 | : The plugins file to source if not using the default. Defaults to **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt** or zstyle setting. 34 | 35 | [\] 36 | : The static plugins file to generate if not using the default. Defaults to **${ZDOTDIR:-\$HOME}/.zsh_plugins.zsh** or zstyle setting. 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2015-2017 Carlos Alexandro Becker 4 | Copyright (c) 2021-2024 Matt McElheny 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /tests/test_cmd_path.md: -------------------------------------------------------------------------------- 1 | # antidote path tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Path Command 12 | 13 | `antidote-path` prints path to bundle. 14 | 15 | ```zsh 16 | % antidote path foo/bar &>/dev/null #=> --exit 0 17 | % antidote path foo/bar | subenv ANTIDOTE_HOME 18 | $ANTIDOTE_HOME/foo/bar 19 | % 20 | ``` 21 | 22 | `antidote-path` fails on missing bundles 23 | 24 | ```zsh 25 | % antidote path bar/foo &>/dev/null #=> --exit 1 26 | % antidote path bar/foo; err=$? 27 | antidote: error: bar/foo does not exist in cloned paths 28 | % echo $err 29 | 1 30 | % 31 | ``` 32 | 33 | `antidote-path` accepts piped input 34 | 35 | ```zsh 36 | % antidote list -s | antidote path | sort | subenv ANTIDOTE_HOME 37 | $ANTIDOTE_HOME/foo/bar 38 | $ANTIDOTE_HOME/foo/baz 39 | $ANTIDOTE_HOME/foo/qux 40 | $ANTIDOTE_HOME/getantidote/zsh-defer 41 | $ANTIDOTE_HOME/ohmy/ohmy 42 | % 43 | ``` 44 | 45 | `antidote-path` expands vars 46 | 47 | ```zsh 48 | % ZSH_CUSTOM=$ZDOTDIR/custom 49 | % antidote path '$ZSH_CUSTOM/plugins/myplugin' | subenv 50 | $HOME/.zsh/custom/plugins/myplugin 51 | % 52 | ``` 53 | 54 | ## Teardown 55 | 56 | ```zsh 57 | % t_teardown 58 | % 59 | ``` 60 | -------------------------------------------------------------------------------- /tools/buildman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | # https://pandoc.org/demo/pandoc.1.md 4 | # https://eddieantonio.ca/blog/2015/12/18/authoring-manpages-in-markdown-with-pandoc/ 5 | # https://jeromebelleman.gitlab.io/posts/publishing/manpages/ 6 | 7 | 0=${(%):-%x} 8 | BASEDIR=${0:a:h:h} 9 | TMPDIR=$BASEDIR/.tmp/buildman 10 | [[ -d $TMPDIR ]] && command rm -rf $TMPDIR 11 | mkdir -p $TMPDIR 12 | 13 | sedi() { 14 | sed --version &> /dev/null && sed -i -- "$@" || sed -i "" "$@" 15 | } 16 | 17 | for manpage in $BASEDIR/man/*.md; do 18 | case ${manpage:t:r} in 19 | footer|example) continue ;; 20 | esac 21 | print "Building ${manpage:t:r} manpage..." 22 | [[ -d $BASEDIR/man/man1 ]] || mkdir -p $BASEDIR/man/man1 23 | 24 | mdfile=$TMPDIR/${manpage:t}.md 25 | cat ${manpage} > $mdfile 26 | print "" >> $mdfile 27 | cat $BASEDIR/man/footer.md >> $mdfile 28 | 29 | manfile=$BASEDIR/man/man1/${manpage:t:r}.1 30 | pandoc --standalone --to man ${mdfile} -o $manfile 31 | 32 | # strip pandoc version so that every manpage build doesn't need to 33 | # result in a new commit just b/c pandoc has a minor point release. 34 | pandoc_ver=$(pandoc -v | awk 'NR==1{print $2}') 35 | sedi "s/Pandoc $pandoc_ver/Pandoc/g" $manfile 36 | done 37 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # Do not remove ##? comments. They are used by 'help' to construct the help docs. 2 | ##? antidote - the cure to slow zsh plugin management 3 | ##? 4 | ##? Usage: make " 5 | ##? 6 | ##? Commands: 7 | 8 | .DEFAULT_GOAL := help 9 | all : build buildman test unittest bump-maj bump-min bump-rev help 10 | .PHONY : all 11 | 12 | ##? help display this makefile's help information 13 | help: 14 | @grep "^##?" makefile | cut -c 5- 15 | 16 | ##? build run build tasks like generating man pages 17 | build: 18 | ./tools/buildman 19 | ./tools/run-clitests 20 | ./tools/bumpver revision 21 | 22 | ##? buildman rebuild man pages 23 | buildman: 24 | ./tools/buildman 25 | 26 | ##? test run tests 27 | test: 28 | ./tools/run-clitests 29 | 30 | ##? unittest run only unittests 31 | unittest: 32 | ./tools/run-clitests --unit 33 | 34 | ##? bump-maj bump the major version (X.0.0) 35 | bump-maj: 36 | ./tools/bumpver major 37 | 38 | ##? bump-min bump the minor version (0.X.0) 39 | bump-min: 40 | ./tools/bumpver minor 41 | 42 | ##? bump-rev bump the revision version (0.0.X) 43 | bump-rev: 44 | ./tools/bumpver revision 45 | 46 | ##? bumpver bump the revision version (0.0.X) 47 | bumpver: 48 | ./tools/bumpver revision 49 | -------------------------------------------------------------------------------- /functions/__antidote_setup: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Setup antidote. 4 | #function __antidote_setup { 5 | 0=${(%):-%x} 6 | fpath=( "${0:A:h}" $fpath ) 7 | local fn 8 | for fn in ${0:A:h}/*; do 9 | [[ ${fn:t} != '__antidote_setup' ]] || continue 10 | if typeset -f ${fn:t} > /dev/null; then 11 | unfunction -- ${fn:t} 12 | fi 13 | 14 | # autoload extensionless function files 15 | [[ -z "${fn:e}" ]] && autoload -Uz "${fn}" 16 | done 17 | 18 | # man pages 19 | if [[ "$MANPATH" != *"${0:A:h:h}/man"* ]]; then 20 | export MANPATH="${0:A:h:h}/man:$MANPATH" 21 | fi 22 | 23 | builtin autoload -Uz is-at-least 24 | if is-at-least 5.8; then 25 | # the -F option was added in 5.8 26 | typeset -gHa _adote_zparopt_flags=( -D -M -F ) 27 | else 28 | typeset -gHa _adote_zparopt_flags=( -D -M ) 29 | fi 30 | 31 | typeset -gHa _adote_funcopts=( extended_glob no_monitor pipefail ) 32 | if zstyle -t ':antidote:tests' set-warn-options; then 33 | typeset -gHa _adote_funcopts=( $_adote_funcopts warn_create_global warn_nested_var ) 34 | fi 35 | 36 | gawk --version &>/dev/null && typeset -gH __adote_awkcmd=gawk || typeset -gH __adote_awkcmd=awk 37 | typeset -gHi __adote_ksh_arrays 38 | typeset -gHi __adote_sh_glob 39 | #} 40 | -------------------------------------------------------------------------------- /functions/__antidote_bulk_clone: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Generate background clone commands 4 | #function __antidote_bulk_clone { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | 7 | # Allow the user to define zsh-defer repo in case they want to fork it. 8 | local zsh_defer_bundle 9 | zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \ 10 | || zsh_defer_bundle='romkatv/zsh-defer' 11 | 12 | # get a list of clonable repos from a bundle file 13 | $__adote_awkcmd -v ZSH_DEFER_BUNDLE=$zsh_defer_bundle ' 14 | BEGIN { RS="[\r\n]" } 15 | 16 | # initialize vars 17 | { bundle=""; opts="--kind clone" } 18 | 19 | # skip blank or commented lines 20 | /^ *(#.+)?$/ { next } 21 | 22 | # clone zsh-defer 23 | /kind:defer/ { print "antidote-script --kind clone " ZSH_DEFER_BUNDLE " &" } 24 | 25 | # handle user/repo and URL forms 26 | $1~/^[^\/]+\/[^\/]+$/ { bundle=$1 } 27 | $1~/^(https?:|(ssh|git)@)/ { bundle=$1 } 28 | 29 | # find branch annotation if it exists 30 | match($0, /branch:[^\t ]+/) { opts=opts " --branch " substr($0, RSTART+7, RLENGTH-7) } 31 | 32 | # print result 33 | bundle!=""{ print "antidote-script", opts, bundle, "&" } 34 | 35 | END { print "wait" } 36 | 37 | ' "$@" | sort | uniq 38 | #} 39 | -------------------------------------------------------------------------------- /tests/test_zcompile_static.md: -------------------------------------------------------------------------------- 1 | # antidote load tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ### General 12 | 13 | Ensure a compiled file exists: 14 | 15 | ```zsh 16 | % zstyle ':antidote:static' zcompile 'yes' 17 | % zstyle ':antidote:static' file $ZDOTDIR/.zplugins_fake_zcompile_static.zsh 18 | % ! test -e $ZDOTDIR/.zplugins_fake_zcompile_static.zsh.zwc #=> --exit 0 19 | % antidote load $ZDOTDIR/.zplugins_fake_load >/dev/null 20 | % cat $ZDOTDIR/.zplugins_fake_zcompile_static.zsh | subenv #=> --file testdata/.zplugins_fake_zcompile_static.zsh 21 | % test -e $ZDOTDIR/.zplugins_fake_zcompile_static.zsh.zwc #=> --exit 0 22 | % t_reset 23 | % 24 | ``` 25 | 26 | Ensure a compiled file does not exist: 27 | 28 | ```zsh 29 | % zstyle ':antidote:static' zcompile 'no' 30 | % zstyle ':antidote:static' file $ZDOTDIR/.zplugins_fake_load.zsh 31 | % ! test -e $ZDOTDIR/.zplugins_fake_load.zsh.zwc #=> --exit 0 32 | % antidote load $ZDOTDIR/.zplugins_fake_load >/dev/null 33 | % cat $ZDOTDIR/.zplugins_fake_load.zsh | subenv #=> --file testdata/.zplugins_fake_load.zsh 34 | % ! test -e $ZDOTDIR/.zplugins_fake_load.zsh.zwc #=> --exit 0 35 | % t_reset 36 | % 37 | ``` 38 | 39 | ## Teardown 40 | 41 | ```zsh 42 | % t_teardown 43 | % 44 | ``` 45 | -------------------------------------------------------------------------------- /tests/testdata/real/.zsh_plugins.txt: -------------------------------------------------------------------------------- 1 | # paths 2 | #$ZDOTDIR/aliases.zsh 3 | $ZSH_CUSTOM/plugins/myplugin 4 | 5 | # plugins 6 | zsh-users/zsh-history-substring-search 7 | https://github.com/zsh-users/zsh-autosuggestions 8 | 9 | # git@ repo URLs aren't good for CI... revisit 10 | # git@github.com:zsh-users/zsh-completions.git 11 | 12 | # kind:zsh 13 | zsh-users/zsh-syntax-highlighting kind:zsh 14 | 15 | # kind:clone 16 | zsh-users/antigen kind:clone 17 | 18 | # kind:fpath 19 | sindresorhus/pure kind:fpath 20 | 21 | # kind:path 22 | romkatv/zsh-bench kind:path 23 | 24 | # kind:autoload 25 | mattmc3/zman path:functions kind:autoload 26 | 27 | # fpath-rule 28 | ohmyzsh/ohmyzsh path:plugins/gradle fpath-rule:prepend 29 | ohmyzsh/ohmyzsh path:plugins/docker fpath-rule:append 30 | 31 | # conditional 32 | ohmyzsh/ohmyzsh path:plugins/macos conditional:is-macos 33 | 34 | # branches 35 | mattmc3/antidote branch:pz 36 | 37 | # subpath plugins 38 | ohmyzsh/ohmyzsh path:lib/clipboard.zsh 39 | ohmyzsh/ohmyzsh path:plugins/extract 40 | ohmyzsh/ohmyzsh path:plugins/magic-enter 41 | ohmyzsh/ohmyzsh path:plugins/fancy-ctrl-z 42 | 43 | # deferred 44 | zdharma-continuum/fast-syntax-highlighting kind:defer 45 | 46 | # theme 47 | dracula/zsh 48 | 49 | # non-conforming plugins 50 | peterhurford/up.zsh 51 | rummik/zsh-tailf 52 | rupa/z 53 | -------------------------------------------------------------------------------- /functions/antidote-list: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### List cloned bundles. 4 | # 5 | # usage: antidote list [-h|--help] [-s|--short] [-d|--dirs] [-u|--url] 6 | # 7 | #function antidote-list { 8 | emulate -L zsh; setopt local_options $_adote_funcopts 9 | 10 | local o_help o_short o_url o_dirs 11 | zparseopts $_adote_zparopt_flags -- \ 12 | h=o_help -help=h \ 13 | s=o_short -short=s \ 14 | u=o_url -url=u \ 15 | d=o_dirs -dirs=d || 16 | return 1 17 | 18 | if (( $#o_help )); then 19 | antidote-help list 20 | return 21 | fi 22 | 23 | if [[ $# -ne 0 ]]; then 24 | print -ru2 "antidote: error: unexpected $1, try --help" 25 | return 1 26 | fi 27 | 28 | local bundledir 29 | local output=() 30 | local bundles=($(antidote-home)/**/.git(/N)) 31 | 32 | for bundledir in $bundles; do 33 | bundledir=${bundledir:h} 34 | local url=$(git -C "$bundledir" config remote.origin.url) 35 | if (( $#o_dirs )); then 36 | output+=($bundledir) 37 | elif (( $#o_url )); then 38 | output+=($url) 39 | elif (( $#o_short )); then 40 | url=${url%.git} 41 | url=${url#https://github.com/} 42 | output+=($url) 43 | else 44 | output+=("$(printf '%-64s %s\n' $url $bundledir)") 45 | fi 46 | done 47 | (( $#output )) && printf '%s\n' ${(o)output} 48 | #} 49 | -------------------------------------------------------------------------------- /tests/testdata/.zsh_plugins.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $HOME/foo/bar ) 2 | source $HOME/foo/bar/bar.plugin.zsh 3 | fpath+=( $ZSH_CUSTOM/plugins/myplugin ) 4 | source $ZSH_CUSTOM/plugins/myplugin/myplugin.plugin.zsh 5 | fpath+=( $HOME/.cache/antidote/foo/bar ) 6 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 7 | fpath+=( $HOME/.cache/antidote/foo/qux ) 8 | source $HOME/.cache/antidote/foo/qux/qux.plugin.zsh 9 | fpath+=( $HOME/.cache/antidote/foo/bar ) 10 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 11 | fpath+=( $HOME/.cache/antidote/foo/bar ) 12 | export PATH="$HOME/.cache/antidote/foo/bar:$PATH" 13 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/lib ) 14 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib1.zsh 15 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib2.zsh 16 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib3.zsh 17 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/extract ) 18 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/extract/extract.plugin.zsh 19 | if ! (( $+functions[zsh-defer] )); then 20 | fpath+=( $HOME/.cache/antidote/getantidote/zsh-defer ) 21 | source $HOME/.cache/antidote/getantidote/zsh-defer/zsh-defer.plugin.zsh 22 | fi 23 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/magic-enter ) 24 | zsh-defer source $HOME/.cache/antidote/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh 25 | source $HOME/.cache/antidote/ohmy/ohmy/custom/themes/pretty.zsh-theme 26 | -------------------------------------------------------------------------------- /tests/test_cmd_install.md: -------------------------------------------------------------------------------- 1 | # antidote installs tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Install Command 12 | 13 | `antidote install` requires a `` argument. 14 | 15 | ```zsh 16 | % antidote install #=> --exit 1 17 | antidote: error: required argument 'bundle' not provided, try --help 18 | % 19 | ``` 20 | 21 | Trying to install an existing bundle fails. 22 | 23 | ```zsh 24 | % antidote install foo/bar &>/dev/null #=> --exit 1 25 | % antidote install foo/bar 2>&1 | subenv ANTIDOTE_HOME >&2 26 | antidote: error: foo/bar already installed: $ANTIDOTE_HOME/foo/bar 27 | % 28 | ``` 29 | 30 | Install a bundle 31 | 32 | ```zsh 33 | % antidote install rupa/z | subenv ZDOTDIR 34 | # antidote cloning rupa/z... 35 | Adding bundle to '$ZDOTDIR/.zsh_plugins.txt': 36 | rupa/z 37 | % tail -n 1 $ZDOTDIR/.zsh_plugins.txt 38 | rupa/z 39 | % 40 | ``` 41 | 42 | Install a complicated bundle 43 | 44 | ```zsh 45 | % antidote install --path plugins/macos --conditional is-macos ohmyzsh/ohmyzsh | subenv ZDOTDIR 46 | # antidote cloning ohmyzsh/ohmyzsh... 47 | Adding bundle to '$ZDOTDIR/.zsh_plugins.txt': 48 | ohmyzsh/ohmyzsh path:plugins/macos conditional:is-macos 49 | % tail -n 1 $ZDOTDIR/.zsh_plugins.txt 50 | ohmyzsh/ohmyzsh path:plugins/macos conditional:is-macos 51 | % 52 | ``` 53 | 54 | ## Teardown 55 | 56 | ```zsh 57 | % t_teardown 58 | % 59 | ``` 60 | -------------------------------------------------------------------------------- /man/man1/antidote-init.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-init" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote init\f[R] \- initialize the shell for dynamic bundles 6 | .SH SYNOPSIS 7 | .PP 8 | source <(antidote init) 9 | .SH DESCRIPTION 10 | \f[B]antidote\-init\f[R] changes how the \f[B]antidote\f[R] command 11 | works by causing \f[B]antidote bundle\f[R] to automatically source its 12 | own output instead of just generating the Zsh script for a static file. 13 | .PP 14 | This behavior exists mainly to support legacy antigen/antibody usage. 15 | Static bundling is highly recommended for the best performance. 16 | However, dynamic bundling may be preferable for some scenarios, so you 17 | can rely on this functionality remaining a key feature in 18 | \f[B]antidote\f[R] to support users preferring dynamic bundles. 19 | .PP 20 | Typical usage involves adding this snippet to your \f[B].zshrc\f[R] 21 | before using \f[B]antidote bundle\f[R] commands: 22 | .PP 23 | \ source <(antidote init) 24 | .SH OPTIONS 25 | .TP 26 | \-h, \-\-help 27 | Show the help documentation. 28 | .SH BUGS 29 | See GitHub Issues: \c 30 | .UR https://github.com/mattmc3/antidote/issues 31 | .UE \c 32 | .SH AUTHORS 33 | .IP \[bu] 2 34 | Copyright (c) 2021\-2024 Matt McElheny 35 | .IP \[bu] 2 36 | antidote contributors: \c 37 | .UR https://github.com/mattmc3/antidote/graphs/contributors 38 | .UE \c 39 | .SH LICENSE 40 | MIT 41 | -------------------------------------------------------------------------------- /functions/antidote-main: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### The main controller for antidote. 4 | # The reason we use `antidote-main` instead putting all of this in `antidote` 5 | # is that this allows the `antidote` function to be overridden via `antidote init`. 6 | # The init command switches antidote from static mode to dynamic mode, but this 7 | # core functionality remains. 8 | #function antidote-main { 9 | 0=${(%):-%x} 10 | 11 | [[ -o KSH_ARRAYS ]] && __adote_ksh_arrays=1 && unsetopt KSH_ARRAYS 12 | [[ -o SH_GLOB ]] && __adote_sh_glob=1 && unsetopt SH_GLOB 13 | 14 | local o_help o_version 15 | zparseopts ${_adote_zparopt_flags} -- \ 16 | h=o_help -help=h \ 17 | v=o_version -version=v || 18 | return 1 19 | 20 | local ret=0 21 | 22 | if (( ${#o_version} )); then 23 | __antidote_version 24 | 25 | elif (( ${#o_help} )); then 26 | antidote-help "$@" 27 | 28 | elif [[ ${#} -eq 0 ]]; then 29 | antidote-help 30 | ret=2 31 | 32 | elif [[ "${1}" = help ]]; then 33 | local manpage=${2:-antidote} 34 | antidote-help $manpage 35 | 36 | elif (( $+functions[antidote-${1}] )); then 37 | local cmd=${1}; shift 38 | antidote-${cmd} "$@" 39 | ret=$? 40 | 41 | else 42 | print -ru2 "antidote: command not found '${1}'" 43 | ret=1 44 | fi 45 | 46 | (( __adote_ksh_arrays )) && __adote_ksh_arrays=0 && setopt KSH_ARRAYS 47 | (( __adote_sh_glob )) && __adote_sh_glob=0 && setopt SH_GLOB 48 | return $ret 49 | #} 50 | -------------------------------------------------------------------------------- /tests/testdata/.zplugins_fake_load.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $HOME/.cache/antidote/foo/bar ) 2 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 3 | fpath+=( $HOME/.cache/antidote/foo/qux ) 4 | source $HOME/.cache/antidote/foo/qux/qux.plugin.zsh 5 | fpath+=( $HOME/.cache/antidote/foo/bar ) 6 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 7 | fpath+=( $HOME/.cache/antidote/foo/bar ) 8 | export PATH="$HOME/.cache/antidote/foo/bar:$PATH" 9 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/lib ) 10 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib1.zsh 11 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib2.zsh 12 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib3.zsh 13 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/extract ) 14 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/extract/extract.plugin.zsh 15 | fpath=( $HOME/.cache/antidote/ohmy/ohmy/plugins/docker $fpath ) 16 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/docker/docker.plugin.zsh 17 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/docker ) 18 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/docker/docker.plugin.zsh 19 | if ! (( $+functions[zsh-defer] )); then 20 | fpath+=( $HOME/.cache/antidote/getantidote/zsh-defer ) 21 | source $HOME/.cache/antidote/getantidote/zsh-defer/zsh-defer.plugin.zsh 22 | fi 23 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/magic-enter ) 24 | zsh-defer source $HOME/.cache/antidote/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh 25 | source $HOME/.cache/antidote/ohmy/ohmy/custom/themes/pretty.zsh-theme 26 | -------------------------------------------------------------------------------- /tests/testdata/real/repo-list.txt: -------------------------------------------------------------------------------- 1 | https://github.com/dracula/zsh $ANTIDOTE_HOME/dracula/zsh 2 | https://github.com/mattmc3/antidote $ANTIDOTE_HOME/mattmc3/antidote 3 | https://github.com/mattmc3/zman $ANTIDOTE_HOME/mattmc3/zman 4 | https://github.com/ohmyzsh/ohmyzsh $ANTIDOTE_HOME/ohmyzsh/ohmyzsh 5 | https://github.com/peterhurford/up.zsh $ANTIDOTE_HOME/peterhurford/up.zsh 6 | https://github.com/romkatv/zsh-bench $ANTIDOTE_HOME/romkatv/zsh-bench 7 | https://github.com/romkatv/zsh-defer $ANTIDOTE_HOME/romkatv/zsh-defer 8 | https://github.com/rummik/zsh-tailf $ANTIDOTE_HOME/rummik/zsh-tailf 9 | https://github.com/rupa/z $ANTIDOTE_HOME/rupa/z 10 | https://github.com/sindresorhus/pure $ANTIDOTE_HOME/sindresorhus/pure 11 | https://github.com/zdharma-continuum/fast-syntax-highlighting $ANTIDOTE_HOME/zdharma-continuum/fast-syntax-highlighting 12 | https://github.com/zsh-users/antigen $ANTIDOTE_HOME/zsh-users/antigen 13 | https://github.com/zsh-users/zsh-autosuggestions $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions 14 | https://github.com/zsh-users/zsh-history-substring-search $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search 15 | https://github.com/zsh-users/zsh-syntax-highlighting $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting 16 | -------------------------------------------------------------------------------- /functions/__antidote_bundle_type: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Determine bundle type: 4 | ### - ? - unknown 5 | ### - empty - empty string 6 | ### - file - an existing file 7 | ### - dir - an existing directory 8 | ### - path - an non-existant path 9 | ### - relpath - a relative path 10 | ### - repo - a git repo (user/repo format) 11 | ### - sshurl - a git repo (SSH format) 12 | ### - url - a git repo (URL format) 13 | ### - word - a word 14 | #function __antidote_bundle_type { 15 | emulate -L zsh; setopt local_options $_adote_funcopts 16 | local bundle=$1 17 | 18 | # Try to expand path bundles with '$' and '~' prefixes so that we get a more 19 | # granular result than 'path'. 20 | if [[ $bundle == '~/'* ]]; then 21 | bundle="${HOME}/${bundle#\~/*}" 22 | elif [[ $bundle == '$'* ]] && [[ $bundle != *'('* ]] && [[ $bundle != *';'* ]]; then 23 | bundle=$(eval print $bundle) 24 | fi 25 | 26 | # Determine the bundle type. 27 | local result 28 | if [[ -e "$bundle" ]]; then 29 | [[ -f $bundle ]] && result=file || result=dir 30 | elif [[ -z "${bundle// }" ]]; then 31 | result=empty 32 | else 33 | case "$bundle" in 34 | (/|~|'$')*) result=path ;; 35 | *://*) result=url ;; 36 | *@*:*/*) result=sshurl ;; 37 | *(:|@)*) result='?' ;; 38 | */*/*) result=relpath ;; 39 | */) result=relpath ;; 40 | */*) result=repo ;; 41 | *) result=word ;; 42 | esac 43 | fi 44 | 45 | typeset -g REPLY=$result 46 | print $result 47 | #} 48 | -------------------------------------------------------------------------------- /man/man1/antidote-load.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-load" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote load\f[R] \- statically source bundles 6 | .SH SYNOPSIS 7 | .PP 8 | antidote load [ []] 9 | .SH DESCRIPTION 10 | \f[B]antidote\-load\f[R] will turn the bundle file into a static load 11 | file and then source it. 12 | .PP 13 | The default bundle file is 14 | \f[B]${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\f[R]. 15 | This can be overridden with the following \f[B]zstyle\f[R]: 16 | .PP 17 | \ \ zstyle \[aq]:antidote:bundle\[aq] file /path/to/my/bundle_file.txt 18 | .PP 19 | The default static file is 20 | \f[B]${ZDOTDIR:\-$HOME}/.zsh_plugins.zsh\f[R]. 21 | This can be overridden with the following \f[B]zstyle\f[R]: 22 | .PP 23 | \ \ zstyle \[aq]:antidote:static\[aq] file /path/to/my/static_file.zsh 24 | .SH OPTIONS 25 | .TP 26 | \-h, \-\-help 27 | Show the help documentation. 28 | .TP 29 | [] 30 | The plugins file to source if not using the default. 31 | Defaults to \f[B]${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\f[R] or zstyle 32 | setting. 33 | .TP 34 | [] 35 | The static plugins file to generate if not using the default. 36 | Defaults to \f[B]${ZDOTDIR:\-$HOME}/.zsh_plugins.zsh\f[R] or zstyle 37 | setting. 38 | .SH BUGS 39 | See GitHub Issues: \c 40 | .UR https://github.com/mattmc3/antidote/issues 41 | .UE \c 42 | .SH AUTHORS 43 | .IP \[bu] 2 44 | Copyright (c) 2021\-2024 Matt McElheny 45 | .IP \[bu] 2 46 | antidote contributors: \c 47 | .UR https://github.com/mattmc3/antidote/graphs/contributors 48 | .UE \c 49 | .SH LICENSE 50 | MIT 51 | -------------------------------------------------------------------------------- /functions/antidote-bundle: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Clone bundle(s) and generate the static load script. 4 | # 5 | # usage: antidote bundle [-h|--help] ... 6 | # 7 | 8 | ### Clone bundle(s) and generate the static load script. 9 | #function antidote-bundle { 10 | # Download a bundle and prints its Zsh source line. 11 | emulate -L zsh; setopt local_options $_adote_funcopts 12 | 13 | local o_help 14 | zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1 15 | 16 | if (( $#o_help )); then 17 | antidote-help bundle 18 | return 19 | fi 20 | 21 | # handle bundles as newline delimited arg strings, 22 | # or as 1 )); then 44 | source <(printf '%s\n' $bundles | __antidote_bulk_clone) 45 | fi 46 | 47 | # generate bundle script 48 | source <(printf '%s\n' $bundles | __antidote_parse_bundles) | __antidote_filter_defers 49 | #} 50 | -------------------------------------------------------------------------------- /tests/functions/t_setup: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function t_setup { 3 | emulate -L zsh 4 | setopt local_options extended_glob glob_dots 5 | 6 | 0=${(%):-%x} 7 | local prjdir="${0:A:h:h:h}" 8 | local testdir="${0:A:h:h}" 9 | 10 | # save path/fpath 11 | typeset -ga T_PREV_PATH=( $path ) 12 | typeset -ga T_PREV_FPATH=( $fpath ) 13 | 14 | # save zstyles, and clear them all for the test session 15 | typeset -ga T_PREV_ZSTYLES=( ${(@f)"$(zstyle -L ':antidote:*')"} ) 16 | source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}') 17 | 18 | # setup test functions 19 | fpath+=( $testdir/functions ) 20 | autoload -Uz $testdir/functions/* 21 | 22 | # mock git 23 | function git { mockgit "$@" } 24 | 25 | # works with BSD and GNU gmktemp 26 | T_TEMPDIR=${$(mktemp -d -t t_antidote.XXXXXXXX):A} 27 | typeset -g T_PREV_HOME=$HOME 28 | typeset -g T_PREV_ZDOTDIR=$ZDOTDIR 29 | 30 | export HOME=$T_TEMPDIR 31 | export ZDOTDIR=$HOME/.zsh 32 | typeset -g ANTIDOTE_HOME=$HOME/.cache/antidote 33 | 34 | # put tmp_home into position 35 | for p in $testdir/tmp_home/*; do 36 | cp -rf $p $T_TEMPDIR 37 | done 38 | 39 | # rename .mockgit to .git 40 | local mockdir 41 | for mockdir in $T_TEMPDIR/**/.mock*; do 42 | mv $mockdir ${mockdir:s/.mock/.} 43 | done 44 | 45 | # our mock plugins use this 46 | typeset -ga plugins=() 47 | typeset -ga libs=() 48 | 49 | # setup antidote 50 | zstyle ':antidote:tests' set-warn-options 'on' 51 | zstyle ':antidote:tests' cloning 'off' 52 | zstyle ':antidote:bundle' use-friendly-names on 53 | zstyle ':antidote:defer' bundle 'getantidote/zsh-defer' 54 | #} 55 | -------------------------------------------------------------------------------- /tests/test_cmd_list.md: -------------------------------------------------------------------------------- 1 | # antidote list tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## List Command 12 | 13 | ### Short 14 | 15 | `antidote list --short` 16 | 17 | ```zsh 18 | % antidote list --short | subenv ANTIDOTE_HOME 19 | foo/bar 20 | foo/baz 21 | getantidote/zsh-defer 22 | git@github.com:foo/qux 23 | ohmy/ohmy 24 | % 25 | ``` 26 | 27 | ### Directories 28 | 29 | `antidote list --dirs` 30 | 31 | ```zsh 32 | % antidote list --dirs | subenv ANTIDOTE_HOME 33 | $ANTIDOTE_HOME/foo/bar 34 | $ANTIDOTE_HOME/foo/baz 35 | $ANTIDOTE_HOME/foo/qux 36 | $ANTIDOTE_HOME/getantidote/zsh-defer 37 | $ANTIDOTE_HOME/ohmy/ohmy 38 | % 39 | ``` 40 | 41 | ### URLs 42 | 43 | `antidote list --url` 44 | 45 | ```zsh 46 | % antidote list --url 47 | git@github.com:foo/qux 48 | https://github.com/foo/bar 49 | https://github.com/foo/baz 50 | https://github.com/getantidote/zsh-defer 51 | https://github.com/ohmy/ohmy 52 | % 53 | ``` 54 | 55 | ### Full 56 | 57 | `antidote list` 58 | 59 | ```zsh 60 | % antidote list | subenv ANTIDOTE_HOME 61 | git@github.com:foo/qux $ANTIDOTE_HOME/foo/qux 62 | https://github.com/foo/bar $ANTIDOTE_HOME/foo/bar 63 | https://github.com/foo/baz $ANTIDOTE_HOME/foo/baz 64 | https://github.com/getantidote/zsh-defer $ANTIDOTE_HOME/getantidote/zsh-defer 65 | https://github.com/ohmy/ohmy $ANTIDOTE_HOME/ohmy/ohmy 66 | % 67 | ``` 68 | 69 | ## Teardown 70 | 71 | ```zsh 72 | % t_teardown 73 | % 74 | ``` 75 | -------------------------------------------------------------------------------- /tests/testdata/.zplugins_fake_zcompile_static.zsh: -------------------------------------------------------------------------------- 1 | function { 2 | 0=${(%):-%x} 3 | local staticfile=${0:A} 4 | [[ -e ${staticfile} ]] || return 1 5 | if [[ ! -s ${staticfile}.zwc || ${staticfile} -nt ${staticfile}.zwc ]]; then 6 | builtin autoload -Uz zrecompile 7 | zrecompile -pq ${staticfile} 8 | fi 9 | } 10 | fpath+=( $HOME/.cache/antidote/foo/bar ) 11 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 12 | fpath+=( $HOME/.cache/antidote/foo/qux ) 13 | source $HOME/.cache/antidote/foo/qux/qux.plugin.zsh 14 | fpath+=( $HOME/.cache/antidote/foo/bar ) 15 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 16 | fpath+=( $HOME/.cache/antidote/foo/bar ) 17 | export PATH="$HOME/.cache/antidote/foo/bar:$PATH" 18 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/lib ) 19 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib1.zsh 20 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib2.zsh 21 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib3.zsh 22 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/extract ) 23 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/extract/extract.plugin.zsh 24 | fpath=( $HOME/.cache/antidote/ohmy/ohmy/plugins/docker $fpath ) 25 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/docker/docker.plugin.zsh 26 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/docker ) 27 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/docker/docker.plugin.zsh 28 | if ! (( $+functions[zsh-defer] )); then 29 | fpath+=( $HOME/.cache/antidote/getantidote/zsh-defer ) 30 | source $HOME/.cache/antidote/getantidote/zsh-defer/zsh-defer.plugin.zsh 31 | fi 32 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/magic-enter ) 33 | zsh-defer source $HOME/.cache/antidote/ohmy/ohmy/plugins/magic-enter/magic-enter.plugin.zsh 34 | source $HOME/.cache/antidote/ohmy/ohmy/custom/themes/pretty.zsh-theme 35 | -------------------------------------------------------------------------------- /tests/test_zcompile_bundle.md: -------------------------------------------------------------------------------- 1 | # antidote load tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ### General 12 | 13 | Ensure a compiled file does not exist: 14 | 15 | ```zsh 16 | % zstyle ':antidote:bundle:*' zcompile 'no' 17 | % ! test -e $ZDOTDIR/custom/lib/lib1.zsh.zwc #=> --exit 0 18 | % antidote bundle $ZDOTDIR/custom/lib/lib1.zsh | subenv ZDOTDIR 19 | source $ZDOTDIR/custom/lib/lib1.zsh 20 | % ! test -e $ZDOTDIR/custom/lib/lib1.zsh.zwc #=> --exit 0 21 | % antidote bundle $ZDOTDIR/custom/plugins/mytheme | subenv ZDOTDIR 22 | fpath+=( $ZDOTDIR/custom/plugins/mytheme ) 23 | source $ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme 24 | % ! test -e $ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme.zwc #=> --exit 0 25 | % 26 | ``` 27 | 28 | Ensure a compiled file exists: 29 | 30 | ```zsh 31 | % zstyle ':antidote:bundle:*' zcompile 'yes' 32 | % ! test -e $ZDOTDIR/custom/lib/lib2.zsh.zwc #=> --exit 0 33 | % antidote bundle $ZDOTDIR/custom/lib/lib2.zsh | subenv ZDOTDIR 34 | source $ZDOTDIR/custom/lib/lib2.zsh 35 | % test -e $ZDOTDIR/custom/lib/lib2.zsh.zwc #=> --exit 0 36 | % # plugin 37 | % antidote bundle $ZDOTDIR/custom/plugins/myplugin | subenv ZDOTDIR 38 | fpath+=( $ZDOTDIR/custom/plugins/myplugin ) 39 | source $ZDOTDIR/custom/plugins/myplugin/myplugin.plugin.zsh 40 | % test -e $ZDOTDIR/custom/plugins/myplugin/myplugin.plugin.zsh.zwc #=> --exit 0 41 | % # zsh-theme 42 | % antidote bundle $ZDOTDIR/custom/plugins/mytheme | subenv ZDOTDIR 43 | fpath+=( $ZDOTDIR/custom/plugins/mytheme ) 44 | source $ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme 45 | % test -e $ZDOTDIR/custom/plugins/mytheme/mytheme.zsh-theme.zwc #=> --exit 0 46 | % 47 | ``` 48 | 49 | ## Teardown 50 | 51 | ```zsh 52 | % t_teardown 53 | % 54 | ``` 55 | -------------------------------------------------------------------------------- /tests/test_cmd_bundle.md: -------------------------------------------------------------------------------- 1 | # antidote bundle helper tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Test bundle command 12 | 13 | Many 'bundle' tests could just as well just be 'script' tests, so we rely on 14 | 'test_script.md' to find scripting issues and use this to test actual bundling, 15 | or things not handled by 'antidote script'. You can think of 'antidote script' as 16 | handling a single bundle, and 'antidote bundle' handling them in bulk. 17 | 18 | ### General 19 | 20 | ```zsh 21 | % # antidote bundle 22 | % 23 | ``` 24 | 25 | ```zsh 26 | % antidote bundle <$ZDOTDIR/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh 27 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv #=> --file testdata/.zsh_plugins.zsh 28 | % 29 | ``` 30 | 31 | ### Multiple ways to call bundle 32 | 33 | Test \|piping, \ --file testdata/script-foobar.zsh 39 | % echo 'foo/bar' | antidote bundle | subenv ANTIDOTE_HOME #=> --file testdata/script-foobar.zsh 40 | % echo 'foo/bar' >$ZDOTDIR/.zsh_plugins_simple.txt 41 | % antidote bundle <$ZDOTDIR/.zsh_plugins_simple.txt | subenv ANTIDOTE_HOME #=> --file testdata/script-foobar.zsh 42 | % zstyle ':antidote:bundle' use-friendly-names on 43 | % ANTIDOTE_HOME=$HOME/.cache/antidote 44 | % 45 | ``` 46 | 47 | ## Fails 48 | 49 | ```zsh 50 | % echo "foo/bar\nfoo/baz kind:whoops" | antidote bundle 2>&1 | subenv ANTIDOTE_HOME 51 | antidote: error: unexpected kind value: 'whoops' 52 | fpath+=( $ANTIDOTE_HOME/foo/bar ) 53 | source $ANTIDOTE_HOME/foo/bar/bar.plugin.zsh 54 | % 55 | ``` 56 | 57 | ## Teardown 58 | 59 | ```zsh 60 | % t_teardown 61 | % 62 | ``` 63 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # antidote tests 2 | 3 | Tests are using [clitest](https://github.com/aureliojargas/clitest). `clitest` utilizes markdown files in this folder to house the tests in a literate format. 4 | 5 | ## Setup 6 | 7 | A simple setup consists of: 8 | 9 | - Remove existing antidote zstyles 10 | - Don't really git things 11 | - Setup antidote 12 | 13 | ```zsh 14 | source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}') 15 | function git { echo "$@" } 16 | ANTIDOTE_HOME=$PWD/tests/zdotdir/antidote_home 17 | source ./antidote.zsh 18 | ``` 19 | 20 | But you probably just want to source setup... 21 | 22 | ```zsh 23 | % source ./tests/_setup.zsh 24 | % source ./antidote.zsh 25 | % 26 | ``` 27 | 28 | ## General 29 | 30 | `antidote` with no args displays its help: 31 | 32 | ```zsh 33 | % antidote 34 | antidote - the cure to slow zsh plugin management 35 | 36 | usage: antidote [] [ ...] 37 | 38 | flags: 39 | -h, --help Show context-sensitive help 40 | -v, --version Show application version 41 | 42 | commands: 43 | help Show documentation 44 | load Statically source all bundles from the plugins file 45 | bundle Clone bundle(s) and generate the static load script 46 | install Clone a new bundle and add it to your plugins file 47 | update Update antidote and its cloned bundles 48 | purge Remove a cloned bundle 49 | home Print where antidote is cloning bundles 50 | list List cloned bundles 51 | path Print the path of a cloned bundle 52 | init Initialize the shell for dynamic bundles 53 | % 54 | ``` 55 | 56 | ## Version 57 | 58 | The `-v/--version` flag displays the current version: 59 | 60 | ```zsh 61 | % antidote --version 62 | antidote version 1.9.7 63 | % 64 | ``` 65 | 66 | ## Teardown 67 | 68 | ```zsh 69 | % t_teardown 70 | % 71 | ``` 72 | -------------------------------------------------------------------------------- /man/antidote-install.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-install 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote install** - install a bundle 10 | 11 | # SYNOPSIS 12 | 13 | | antidote install [-h|\--help] [-k|\--kind \] [-p|\--path \] 14 | | [-a|\--autoload \] [-c|\--conditional \] 15 | | [\--pre \] [\--post \] 16 | | [-b|\--branch \] \ [\] 17 | 18 | # DESCRIPTION 19 | 20 | **antidote-install** clones a new bundle and adds it to your plugins file. 21 | 22 | The default bundle file is **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt**. This can be overridden with the following **zstyle**: 23 | 24 | | zstyle \':antidote:bundle\' file /path/to/my/bundle_file.txt 25 | 26 | # OPTIONS 27 | 28 | -h, \--help 29 | : Show the help documentation. 30 | 31 | -k, \--kind 32 | : The kind of bundle. Valid values: autoload, fpath, path, clone, defer, zsh. 33 | 34 | -p, \--path 35 | : A relative subpath within the bundle where the plugin is located. 36 | 37 | -b, \--branch 38 | : The git branch to use. 39 | 40 | -a, \--autoload 41 | : A relative subpath within the bundle where autoload function files are located. 42 | 43 | -c, \--conditional 44 | : A conditional function used to check whether to load the bundle. 45 | 46 | \--pre 47 | : A function to be called prior to loading the bundle. 48 | 49 | \--post 50 | : A function to be called after loading the bundle. 51 | 52 | \ 53 | : Bundle to be installed. 54 | 55 | [\] 56 | : Bundle file to write to if not using the default. Defaults to **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt** or zstyle setting. 57 | 58 | # EXAMPLES 59 | 60 | | antidote install zsh-users/zsh-history-substring-search 61 | -------------------------------------------------------------------------------- /tests/test_cmd_load.md: -------------------------------------------------------------------------------- 1 | # antidote load tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ### General 12 | 13 | ```zsh 14 | % antidote load $ZDOTDIR/.zplugins_fake_load 15 | sourcing foo/bar... 16 | sourcing foo/qux... 17 | sourcing foo/bar... 18 | sourcing ohmy/lib/lib1.zsh... 19 | sourcing ohmy/lib/lib2.zsh... 20 | sourcing ohmy/lib/lib3.zsh... 21 | sourcing extract.plugin.zsh... 22 | sourcing docker.plugin.zsh... 23 | sourcing docker.plugin.zsh... 24 | sourcing getantidote/zsh-defer... 25 | sourcing magic-enter.plugin.zsh... 26 | sourcing pretty.zsh-theme... 27 | % cat $ZDOTDIR/.zplugins_fake_load.zsh | subenv #=> --file testdata/.zplugins_fake_load.zsh 28 | % # cleanup 29 | % t_reset 30 | % 31 | ``` 32 | 33 | ### zstyles 34 | 35 | ```zsh 36 | % cp $ZDOTDIR/.zplugins_fake_load $ZDOTDIR/.zplugins.txt 37 | % zstyle ':antidote:bundle' file $ZDOTDIR/.zplugins.txt 38 | % zstyle ':antidote:static' file $ZDOTDIR/.zplugins.txt 39 | % # the static file should be different 40 | % antidote load 2>&1 | subenv ZDOTDIR 41 | antidote: bundle file and static file are the same '$ZDOTDIR/.zplugins.txt'. 42 | % # fixed... 43 | % zstyle ':antidote:static' file $ZDOTDIR/.zplugins.static.zsh 44 | % # the static file should be different 45 | % antidote load 46 | sourcing foo/bar... 47 | sourcing foo/qux... 48 | sourcing foo/bar... 49 | sourcing ohmy/lib/lib1.zsh... 50 | sourcing ohmy/lib/lib2.zsh... 51 | sourcing ohmy/lib/lib3.zsh... 52 | sourcing extract.plugin.zsh... 53 | sourcing docker.plugin.zsh... 54 | sourcing docker.plugin.zsh... 55 | sourcing getantidote/zsh-defer... 56 | sourcing magic-enter.plugin.zsh... 57 | sourcing pretty.zsh-theme... 58 | % cat $ZDOTDIR/.zplugins.static.zsh | subenv #=> --file testdata/.zplugins_fake_load.zsh 59 | % 60 | ``` 61 | 62 | ## Teardown 63 | 64 | ```zsh 65 | % t_teardown 66 | % 67 | ``` 68 | -------------------------------------------------------------------------------- /functions/__antidote_bundle_dir: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Get the name of the bundle dir. 4 | #function __antidote_bundle_dir { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | 7 | # If the bundle is a repo/URL, then by default we use the legacy antibody format: 8 | # `$ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions` 9 | # With `zstyle ':antidote:bundle' use-friendly-names on`, we can simplify to 10 | # `$ANTIDOTE_HOME/zsh-users/zsh-autosuggestions` 11 | # If the bundle is a file, use its parent directory. 12 | # Otherwise, just assume the bundle is a directory. 13 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 14 | 15 | local bundle="$1" 16 | local bundle_type="$(__antidote_bundle_type $bundle)" 17 | 18 | # handle repo bundle paths 19 | if [[ "$bundle_type" == (repo|url|sshurl) ]] && [[ ! -e "$bundle_path" ]]; then 20 | if zstyle -t ':antidote:bundle' use-friendly-names; then 21 | # user/repo format 22 | # ex: $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions 23 | bundle=${bundle%.git} 24 | bundle=${bundle:gs/\:/\/} 25 | local parts=( ${(ps./.)bundle} ) 26 | if [[ $#parts -gt 1 ]]; then 27 | print $(antidote-home)/${parts[-2]}/${parts[-1]} 28 | else 29 | print $(antidote-home)/$bundle 30 | fi 31 | else 32 | # sanitize URL for safe use as a dir name 33 | # ex: $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions 34 | local url=$(__antidote_tourl $bundle) 35 | url=${url%.git} 36 | url=${url:gs/\@/-AT-} 37 | url=${url:gs/\:/-COLON-} 38 | url=${url:gs/\//-SLASH-} 39 | print $(antidote-home)/$url 40 | fi 41 | elif [[ -f "$bundle" ]]; then 42 | print ${bundle:A:h} 43 | else 44 | print ${bundle} 45 | fi 46 | #} 47 | -------------------------------------------------------------------------------- /tests/test_cmd_home.md: -------------------------------------------------------------------------------- 1 | # antidote home tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## General 12 | 13 | `antidote home` command exists 14 | 15 | ```zsh 16 | % antidote home &>/dev/null; echo $? 17 | 0 18 | % 19 | ``` 20 | 21 | `antidote home --h/--help` works 22 | 23 | ```zsh 24 | % antidote home -h &>/dev/null; echo $? 25 | 0 26 | % antidote home --help &>/dev/null; echo $? 27 | 0 28 | % 29 | ``` 30 | 31 | `$ANTIDOTE_HOME` is used if set... 32 | 33 | ```zsh 34 | % ANTIDOTE_HOME=$HOME/.cache/antidote 35 | % antidote home | subenv HOME 36 | $HOME/.cache/antidote 37 | % unset ANTIDOTE_HOME 38 | % 39 | ``` 40 | 41 | `antidote home` is `~/Library/Caches/antidote` on macOS 42 | 43 | ```zsh 44 | % OLD_OSTYPE=$OSTYPE; OSTYPE=darwin21.3.0 45 | % antidote home | subenv HOME 46 | $HOME/Library/Caches/antidote 47 | % OSTYPE=$OLD_OSTYPE 48 | % 49 | ``` 50 | 51 | `antidote home` is `$LOCALAPPDATA/antidote` on msys 52 | 53 | ```zsh 54 | % OLD_OSTYPE=$OSTYPE; OSTYPE=msys 55 | % LOCALAPPDATA=$HOME/AppData 56 | % antidote home | subenv HOME 57 | $HOME/AppData/antidote 58 | % OSTYPE=$OLD_OSTYPE 59 | % 60 | ``` 61 | 62 | `antidote home` uses `$XDG_CACHE_HOME` on an OS that defines it. 63 | 64 | ```zsh 65 | % # Setup 66 | % OLD_OSTYPE=$OSTYPE; OSTYPE=foobar 67 | % OLD_XDG_CACHE_HOME=$XDG_CACHE_HOME; XDG_CACHE_HOME=$HOME/.xdg-cache 68 | % # Run test 69 | % antidote home | subenv XDG_CACHE_HOME 70 | $XDG_CACHE_HOME/antidote 71 | % # Teardown 72 | % OSTYPE=$OLD_OSTYPE; XDG_CACHE_HOME=$OLD_XDG_CACHE_HOME 73 | % 74 | ``` 75 | 76 | `antidote home` uses `$HOME/.cache` otherwise. 77 | 78 | ```zsh 79 | % # Setup 80 | % OLD_OSTYPE=$OSTYPE; OSTYPE=foobar 81 | % OLD_XDG_CACHE_HOME=$XDG_CACHE_HOME; XDG_CACHE_HOME= 82 | % # Run test 83 | % antidote home | subenv HOME 84 | $HOME/.cache/antidote 85 | % # Teardown 86 | % OSTYPE=$OLD_OSTYPE; XDG_CACHE_HOME=$OLD_XDG_CACHE_HOME 87 | % 88 | ``` 89 | 90 | ## Teardown 91 | 92 | ```zsh 93 | % t_teardown 94 | % 95 | ``` 96 | -------------------------------------------------------------------------------- /functions/antidote-install: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Clone a new bundle and add it to your plugins file. 4 | 5 | # usage: antidote install [-h|--help] [-k|--kind ] [-p|--path ] 6 | # [-c|--conditional ] [-b|--branch ] 7 | # [--pre ] [--post ] 8 | # [-a|--autoload ] [] 9 | #function antidote-install { 10 | emulate -L zsh; setopt local_options $_adote_funcopts 11 | 12 | local -A flag_to_annotation=( 13 | '-a' autoload 14 | '-b' branch 15 | '-c' conditional 16 | '-h' help 17 | '-k' kind 18 | '-p' path 19 | ) 20 | local -a annotations=() 21 | local arg 22 | while (( $# )); do 23 | arg="$1" 24 | case "$arg" in 25 | -h|--help) 26 | antidote-help install 27 | return 28 | ;; 29 | --) shift; break ;; 30 | --*) annotations+=( "${arg#*--}:$2" ); shift ;; 31 | -*) annotations+=( $flag_to_annotation[$arg]:$2 ); shift ;; 32 | *) break ;; 33 | esac 34 | shift 35 | done 36 | 37 | if [[ $# -eq 0 ]]; then 38 | print -ru2 "antidote: error: required argument 'bundle' not provided, try --help" 39 | return 1 40 | fi 41 | 42 | local bundle=$1 43 | local bundlefile=$2 44 | if [[ -z "$bundlefile" ]]; then 45 | zstyle -s ':antidote:bundle' file 'bundlefile' || 46 | bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt 47 | fi 48 | 49 | local bundledir=$(__antidote_bundle_dir $bundle) 50 | if [[ -d "$bundledir" ]]; then 51 | print -ru2 "antidote: error: $bundle already installed: $bundledir" 52 | return 1 53 | fi 54 | 55 | # use antidote bundle to clone our bundle 56 | local bundlestr=$bundle 57 | (( $#annotations )) && bundlestr+=" $annotations" 58 | antidote-bundle "$bundlestr" >/dev/null 59 | if [[ $? -ne 0 ]]; then 60 | print -ru2 "antidote: unable to install bundle '$bundle'." 61 | else 62 | print "Adding bundle to '$bundlefile':" 63 | print $bundlestr | tee -a $bundlefile 64 | fi 65 | #} 66 | -------------------------------------------------------------------------------- /tests/testdata/.zsh_plugins_no_defer.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search ) 2 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh 3 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting ) 4 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh 5 | if is-macos; then 6 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos ) 7 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/macos.plugin.zsh 8 | fi 9 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions ) 10 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh 11 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting ) 12 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 13 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh ) 14 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh/dracula.zsh-theme 15 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh ) 16 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh/up.plugin.zsh 17 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf ) 18 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf/tailf.plugin.zsh 19 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z ) 20 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z/z.sh 21 | -------------------------------------------------------------------------------- /functions/__antidote_load_prep: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Prep to load 4 | #function __antidote_load_prep { 5 | emulate -L zsh; setopt local_options $_adote_funcopts 6 | 7 | # pass in bundle file, read from zstyle, or use default .zsh_plugins.txt 8 | local bundlefile="$1" 9 | if [[ -z "$bundlefile" ]]; then 10 | zstyle -s ':antidote:bundle' file 'bundlefile' || 11 | bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt 12 | fi 13 | 14 | # pass in static file, read from zstyle, change extension, or use default .zsh_plugins.zsh 15 | local staticfile="$2" 16 | if [[ -z "$staticfile" ]]; then 17 | zstyle -s ':antidote:static' file 'staticfile' 18 | if [[ -z "$staticfile" ]]; then 19 | if [[ -z "$bundlefile:t:r" ]]; then 20 | staticfile=${bundlefile}.zsh 21 | else 22 | staticfile=${bundlefile:r}.zsh 23 | fi 24 | fi 25 | fi 26 | 27 | if [[ ! -e "$bundlefile" ]]; then 28 | # the files can't have the same name 29 | print -ru2 -- "antidote: bundle file not found '$bundlefile'." 30 | return 1 31 | elif [[ "$bundlefile" == "$staticfile" ]]; then 32 | # the files can't have the same name 33 | print -ru2 -- "antidote: bundle file and static file are the same '$bundlefile'." 34 | return 1 35 | fi 36 | 37 | # regenerate the static file based on whether the bundle file is newer and whether 38 | # antidote home exists and is ready to be loaded 39 | local force_bundle=0 40 | if ! zstyle -t ':antidote:load:checkfile' disabled; then 41 | local loadable_check_path="$(antidote-home)/.antidote.load" 42 | if [[ ! -e $loadable_check_path ]]; then 43 | force_bundle=1 44 | [[ -d $loadable_check_path:h ]] || mkdir -p $loadable_check_path:h 45 | touch $loadable_check_path 46 | fi 47 | fi 48 | 49 | if [[ ! $staticfile -nt $bundlefile ]] || [[ $force_bundle -eq 1 ]]; then 50 | mkdir -p "${staticfile:A:h}" 51 | antidote bundle <"$bundlefile" >|"$staticfile" 52 | if [[ -r "${staticfile}.zwc" ]] && ! zstyle -t ':antidote:static' zcompile; then 53 | __antidote_del -f -- "${staticfile}.zwc" 54 | fi 55 | fi 56 | 57 | # tell antidote-load what to source 58 | typeset -g REPLY=$staticfile 59 | #print $REPLY 60 | #} 61 | -------------------------------------------------------------------------------- /tests/test_cmd_purge.md: -------------------------------------------------------------------------------- 1 | # antidote purge tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Purge Command 12 | 13 | `antidote purge` requires a `` argument. 14 | 15 | ```zsh 16 | % antidote purge &>/dev/null #=> --exit 1 17 | % antidote purge 18 | antidote: error: required argument 'bundle' not provided, try --help 19 | % 20 | ``` 21 | 22 | Trying to purge a missing bundle fails. 23 | 24 | ```zsh 25 | % antidote purge bar/foo &>/dev/null #=> --exit 1 26 | % antidote purge bar/foo 2>&1 | subenv ANTIDOTE_HOME >&2 27 | antidote: error: bar/foo does not exist at the expected location: $ANTIDOTE_HOME/bar/foo 28 | % 29 | ``` 30 | 31 | Purging a bundle deletes the directory and comments out instances of the bundle in `.zsh_plugins.txt`. 32 | 33 | ```zsh 34 | % # bundle dir exists 35 | % bundledir=$ANTIDOTE_HOME/foo/bar 36 | % test -d $bundledir #=> --exit 0 37 | % # purge works 38 | % antidote purge foo/bar | subenv ZDOTDIR 39 | Removed 'foo/bar'. 40 | Bundle 'foo/bar' was commented out in '$ZDOTDIR/.zsh_plugins.txt'. 41 | % # bundle dir was removed 42 | % test -d $bundledir #=> --exit 1 43 | % cat $ZDOTDIR/.zsh_plugins.txt #=> --file ./testdata/.zsh_plugins_purged.txt 44 | % 45 | ``` 46 | 47 | Test that `antidote purge --all` aborts when told "no". 48 | 49 | ```zsh 50 | % function test_exists { [[ -e "$1" ]] } 51 | % zstyle ':antidote:purge:all' answer 'n' 52 | % antidote purge --all #=> --exit 1 53 | % antidote list | subenv ANTIDOTE_HOME 54 | git@github.com:foo/qux $ANTIDOTE_HOME/foo/qux 55 | https://github.com/foo/baz $ANTIDOTE_HOME/foo/baz 56 | https://github.com/getantidote/zsh-defer $ANTIDOTE_HOME/getantidote/zsh-defer 57 | https://github.com/ohmy/ohmy $ANTIDOTE_HOME/ohmy/ohmy 58 | % 59 | ``` 60 | 61 | Test that `antidote purge --all` does the work when told "yes". 62 | 63 | ```zsh 64 | % function test_exists { [[ -e "$1" ]] } 65 | % zstyle ':antidote:purge:all' answer 'y' 66 | % antidote purge --all | tail -n 1 67 | Antidote purge complete. Be sure to start a new Zsh session. 68 | % antidote list | wc -l | awk '{print $1}' 69 | 0 70 | % 71 | ``` 72 | 73 | ## Teardown 74 | 75 | ```zsh 76 | % t_teardown 77 | % 78 | ``` 79 | -------------------------------------------------------------------------------- /tests/test_zsetopts.md: -------------------------------------------------------------------------------- 1 | # antidote respects setopts 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | Set up a plugin that changes Zsh options 12 | ```zsh 13 | % plugin_file=$ANTIDOTE_HOME/lampoon/xmas/xmas.plugin.zsh 14 | % mkdir -p $plugin_file:h && touch $plugin_file 15 | % echo "unsetopt noaliases" >>$plugin_file 16 | % echo "setopt autocd" >>$plugin_file 17 | % echo "lampoon/xmas" >$ZDOTDIR/.zsh_plugins.txt 18 | % 19 | ``` 20 | 21 | ## Test that plugins that run setopts work 22 | 23 | Verify initial state 24 | ```zsh 25 | % setopt noaliases 26 | % set -o | grep noaliases 27 | noaliases on 28 | % set -o | grep autocd 29 | autocd off 30 | % 31 | ``` 32 | 33 | Load the plugins and see if the option took 34 | ```zsh 35 | % antidote load &>/dev/null #=> --exit 0 36 | % set -o | grep noaliases 37 | noaliases off 38 | % set -o | grep autocd 39 | autocd on 40 | % # cleanup 41 | % setopt noaliases no_autocd 42 | % 43 | ``` 44 | 45 | Tests to ensure [#86](https://github.com/mattmc3/antidote/issues/86) stays fixed. 46 | Check that stderr is empty. 47 | ```zsh 48 | % setopt posix_identifiers 49 | % antidote -v 3>&1 2>&3 >/dev/null #=> --exit 0 50 | 51 | % antidote -h 3>&1 2>&3 >/dev/null #=> --exit 0 52 | 53 | % antidote help 3>&1 2>&3 >/dev/null #=> --exit 0 54 | 55 | % # cleanup 56 | % unsetopt posix_identifiers 57 | % 58 | ``` 59 | 60 | ## Clark Grizwold lighting ceremony! 61 | 62 |

via GIPHY

63 | 64 | ```zsh 65 | % optcnt=$(setopt | wc -l | tr -d ' ') 66 | % echo $optcnt #=> --regex ^\d+$ 67 | % test $optcnt -lt 10 && echo "less than 10 enabled zsh opts" 68 | less than 10 enabled zsh opts 69 | % # now lets turn on all the lights 70 | % echo '$ZDOTDIR/custom/plugins/grizwold' >$ZDOTDIR/.zsh_plugins.txt 71 | % antidote load 72 | % optcnt=$(setopt | wc -l | tr -d ' ') 73 | % test $optcnt -gt 150 && echo "zillions of enabled zsh options (>150)" 74 | zillions of enabled zsh options (>150) 75 | % 76 | ``` 77 | 78 | ## Teardown 79 | 80 | ```zsh 81 | % unsetopt $grizwold_zopts 82 | % t_teardown 83 | % 84 | ``` 85 | -------------------------------------------------------------------------------- /man/man1/antidote-install.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-install" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote install\f[R] \- install a bundle 6 | .SH SYNOPSIS 7 | .PP 8 | antidote install [\-h|\-\-help] [\-k|\-\-kind ] [\-p|\-\-path 9 | ] 10 | .PD 0 11 | .P 12 | .PD 13 | \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [\-a|\-\-autoload ] 14 | [\-c|\-\-conditional ] 15 | .PD 0 16 | .P 17 | .PD 18 | \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [\-\-pre ] [\-\-post ] 19 | .PD 0 20 | .P 21 | .PD 22 | \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [\-b|\-\-branch ] 23 | [] 24 | .SH DESCRIPTION 25 | \f[B]antidote\-install\f[R] clones a new bundle and adds it to your 26 | plugins file. 27 | .PP 28 | The default bundle file is 29 | \f[B]${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\f[R]. 30 | This can be overridden with the following \f[B]zstyle\f[R]: 31 | .PP 32 | \ \ zstyle \[aq]:antidote:bundle\[aq] file /path/to/my/bundle_file.txt 33 | .SH OPTIONS 34 | .TP 35 | \-h, \-\-help 36 | Show the help documentation. 37 | .TP 38 | \-k, \-\-kind 39 | The kind of bundle. 40 | Valid values: autoload, fpath, path, clone, defer, zsh. 41 | .TP 42 | \-p, \-\-path 43 | A relative subpath within the bundle where the plugin is located. 44 | .TP 45 | \-b, \-\-branch 46 | The git branch to use. 47 | .TP 48 | \-a, \-\-autoload 49 | A relative subpath within the bundle where autoload function files are 50 | located. 51 | .TP 52 | \-c, \-\-conditional 53 | A conditional function used to check whether to load the bundle. 54 | .TP 55 | \-\-pre 56 | A function to be called prior to loading the bundle. 57 | .TP 58 | \-\-post 59 | A function to be called after loading the bundle. 60 | .TP 61 | 62 | Bundle to be installed. 63 | .TP 64 | [] 65 | Bundle file to write to if not using the default. 66 | Defaults to \f[B]${ZDOTDIR:\-$HOME}/.zsh_plugins.txt\f[R] or zstyle 67 | setting. 68 | .SH EXAMPLES 69 | .PP 70 | \ \ antidote install zsh\-users/zsh\-history\-substring\-search 71 | .SH BUGS 72 | See GitHub Issues: \c 73 | .UR https://github.com/mattmc3/antidote/issues 74 | .UE \c 75 | .SH AUTHORS 76 | .IP \[bu] 2 77 | Copyright (c) 2021\-2024 Matt McElheny 78 | .IP \[bu] 2 79 | antidote contributors: \c 80 | .UR https://github.com/mattmc3/antidote/graphs/contributors 81 | .UE \c 82 | .SH LICENSE 83 | MIT 84 | -------------------------------------------------------------------------------- /tests/testdata/real/.zsh_plugins.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $ZSH_CUSTOM/plugins/myplugin ) 2 | source $ZSH_CUSTOM/plugins/myplugin/myplugin.plugin.zsh 3 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search ) 4 | source $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh 5 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions ) 6 | source $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh 7 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting ) 8 | source $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh 9 | fpath+=( $ANTIDOTE_HOME/sindresorhus/pure ) 10 | export PATH="$ANTIDOTE_HOME/romkatv/zsh-bench:$PATH" 11 | fpath+=( $ANTIDOTE_HOME/mattmc3/zman/functions ) 12 | builtin autoload -Uz $fpath[-1]/*(N.:t) 13 | fpath=( $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/gradle $fpath ) 14 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/gradle/gradle.plugin.zsh 15 | fpath+=( $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/docker ) 16 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/docker/docker.plugin.zsh 17 | if is-macos; then 18 | fpath+=( $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/macos ) 19 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/macos/macos.plugin.zsh 20 | fi 21 | fpath+=( $ANTIDOTE_HOME/mattmc3/antidote ) 22 | source $ANTIDOTE_HOME/mattmc3/antidote/pz.plugin.zsh 23 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/lib/clipboard.zsh 24 | fpath+=( $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/extract ) 25 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/extract/extract.plugin.zsh 26 | fpath+=( $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/magic-enter ) 27 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/magic-enter/magic-enter.plugin.zsh 28 | fpath+=( $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/fancy-ctrl-z ) 29 | source $ANTIDOTE_HOME/ohmyzsh/ohmyzsh/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh 30 | if ! (( $+functions[zsh-defer] )); then 31 | fpath+=( $ANTIDOTE_HOME/romkatv/zsh-defer ) 32 | source $ANTIDOTE_HOME/romkatv/zsh-defer/zsh-defer.plugin.zsh 33 | fi 34 | fpath+=( $ANTIDOTE_HOME/zdharma-continuum/fast-syntax-highlighting ) 35 | zsh-defer source $ANTIDOTE_HOME/zdharma-continuum/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 36 | fpath+=( $ANTIDOTE_HOME/dracula/zsh ) 37 | source $ANTIDOTE_HOME/dracula/zsh/dracula.zsh-theme 38 | fpath+=( $ANTIDOTE_HOME/peterhurford/up.zsh ) 39 | source $ANTIDOTE_HOME/peterhurford/up.zsh/up.plugin.zsh 40 | fpath+=( $ANTIDOTE_HOME/rummik/zsh-tailf ) 41 | source $ANTIDOTE_HOME/rummik/zsh-tailf/tailf.plugin.zsh 42 | fpath+=( $ANTIDOTE_HOME/rupa/z ) 43 | source $ANTIDOTE_HOME/rupa/z/z.sh 44 | -------------------------------------------------------------------------------- /tests/functions/mockgit: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function mockgit { 3 | # handle these commands: 4 | # - `git -C "$dir" config remote.origin.url` 5 | # - `git -C "$dir" pull --quiet --ff --rebase --autostash` 6 | # - `git -C "$dir" rev-parse --short HEAD` 7 | # - `git clone --quiet --depth 1 --recurse-submodules --shallow-submodules --branch branch $url $dir` 8 | # - `git --version` 9 | emulate -L zsh; setopt local_options extended_glob 10 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 11 | 0=${(%):-%x} 12 | 13 | local args=("$@[@]") 14 | local o_path o_quiet o_ff o_rebase o_autostash o_short 15 | local o_depth o_recurse_submodules o_shallow_submodules o_branch 16 | local o_init o_recursive 17 | zparseopts -D -E -- \ 18 | C:=o_path \ 19 | -short=o_short \ 20 | -quiet=o_quiet \ 21 | -ff=o_ff \ 22 | -rebase=o_rebase \ 23 | -autostash=o_autostash \ 24 | -recurse-submodules=o_recurse_submodules \ 25 | -shallow-submodules=o_shallow_submodules \ 26 | -depth:=o_depth \ 27 | -branch:=o_branch \ 28 | -init=o_init \ 29 | -recursive=o_recursive || 30 | return 1 31 | 32 | if [[ "$@" = "--version" ]]; then 33 | echo "0.0.0" 34 | elif [[ "$1" = "clone" ]]; then 35 | local giturl="$2" 36 | local bundledir="$3" 37 | local src="$ANTIDOTE_HOME/${bundledir:t}" 38 | if [[ -d $src ]]; then 39 | cp -r $src ${bundledir:h} 40 | elif ! (( $#o_quiet )); then 41 | echo "MOCKGIT: Cloning into '${url:t}'..." 42 | echo "MOCKGIT: Repository not found." 43 | echo "MOCKGIT: repository '$url' not found" 44 | fi 45 | elif [[ "$@" = "config remote.origin.url" ]]; then 46 | if [[ -e $bundledir/.git/config/remote.origin.url ]]; then 47 | cat $bundledir/.git/config/remote.origin.url 48 | else 49 | # un-sanitize dir into URL 50 | local url=$o_path[-1] 51 | url=${url:t} 52 | url=${url:gs/-AT-/\@} 53 | url=${url:gs/-COLON-/\:} 54 | url=${url:gs/-SLASH-/\/} 55 | echo "$url" 56 | fi 57 | elif [[ "$@" = "pull" ]]; then 58 | (( $#o_quiet )) || echo "MOCKGIT: Already up to date." 59 | elif [[ "$@" = "rev-parse HEAD" ]]; then 60 | #echo "a123456" 61 | echo "" 62 | elif [[ "$@" = "submodule sync" ]]; then 63 | # nothing to do 64 | elif [[ "$@" = "submodule update" ]]; then 65 | # nothing to do 66 | else 67 | echo >&2 "mocking not implemented for git command: git $@" 68 | return 1 69 | fi 70 | #} 71 | -------------------------------------------------------------------------------- /tests/test_antidote_core.md: -------------------------------------------------------------------------------- 1 | # antidote core tests 2 | 3 | fails gracefully when someone tries bash 4 | 5 | ```zsh 6 | % bash -c "source $PWD/antidote.zsh" 7 | antidote: Expecting zsh. Found 'bash'. 8 | % 9 | ``` 10 | 11 | ## Setup 12 | 13 | ```zsh 14 | % echo $+functions[antidote] 15 | 0 16 | % source ./tests/_setup.zsh 17 | % source ./antidote.zsh 18 | % echo $+functions[antidote] 19 | 1 20 | % git --version 21 | 0.0.0 22 | % 23 | ``` 24 | 25 | ## General 26 | 27 | No args displays help: 28 | 29 | ```zsh 30 | % antidote 31 | antidote - the cure to slow zsh plugin management 32 | 33 | usage: antidote [] [ ...] 34 | 35 | flags: 36 | -h, --help Show context-sensitive help 37 | -v, --version Show application version 38 | 39 | commands: 40 | help Show documentation 41 | load Statically source all bundles from the plugins file 42 | bundle Clone bundle(s) and generate the static load script 43 | install Clone a new bundle and add it to your plugins file 44 | update Update antidote and its cloned bundles 45 | purge Remove a cloned bundle 46 | home Print where antidote is cloning bundles 47 | list List cloned bundles 48 | path Print the path of a cloned bundle 49 | init Initialize the shell for dynamic bundles 50 | % 51 | ``` 52 | 53 | No arg exit status is 2: 54 | 55 | ```zsh 56 | % antidote >/dev/null; err=$? 57 | % echo $err 58 | 2 59 | % 60 | ``` 61 | 62 | ## Help 63 | 64 | `-h` and `--help` work: 65 | 66 | ```zsh 67 | % antidote -h >/dev/null; err=$? 68 | % echo $err 69 | 0 70 | % antidote --help >/dev/null; err=$? 71 | % echo $err 72 | 0 73 | % 74 | ``` 75 | 76 | ## Version 77 | 78 | `-v` and `--version` work: 79 | 80 | ```zsh 81 | % antidote --version 82 | antidote version 1.9.7 83 | % antidote -v >/dev/null; echo $? 84 | 0 85 | % antidote --version >/dev/null; echo $? 86 | 0 87 | % 88 | ``` 89 | 90 | ## Unrecognized options 91 | 92 | ```zsh 93 | % antidote --foo >/dev/null; err=$? #=> --regex (bad option|command not found) 94 | % echo $err 95 | 1 96 | % 97 | ``` 98 | 99 | ## Unrecognized commands 100 | 101 | ```zsh 102 | % antidote foo; err=$? 103 | antidote: command not found 'foo' 104 | % echo $err 105 | 1 106 | % 107 | ``` 108 | 109 | ## All commands 110 | 111 | ```zsh 112 | % cmds=( bundle help home init install list load path purge update script main null ) 113 | % for cmd in $cmds; echo $+functions[antidote-$cmd] 114 | 1 115 | 1 116 | 1 117 | 1 118 | 1 119 | 1 120 | 1 121 | 1 122 | 1 123 | 1 124 | 1 125 | 1 126 | 0 127 | % 128 | ``` 129 | 130 | ## Teardown 131 | 132 | ```zsh 133 | % t_teardown 134 | % 135 | ``` 136 | -------------------------------------------------------------------------------- /tests/testdata/.zsh_plugins_multi_defer.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search ) 2 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh 3 | if ! (( $+functions[zsh-defer] )); then 4 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer ) 5 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh 6 | fi 7 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting ) 8 | zsh-defer source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh 9 | if is-macos; then 10 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos ) 11 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/macos.plugin.zsh 12 | fi 13 | if ! (( $+functions[zsh-defer] )); then 14 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer ) 15 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh 16 | fi 17 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions ) 18 | zsh-defer source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh 19 | if ! (( $+functions[zsh-defer] )); then 20 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer ) 21 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh 22 | fi 23 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting ) 24 | zsh-defer source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 25 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh ) 26 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh/dracula.zsh-theme 27 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh ) 28 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh/up.plugin.zsh 29 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf ) 30 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf/tailf.plugin.zsh 31 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z ) 32 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z/z.sh 33 | -------------------------------------------------------------------------------- /functions/antidote-purge: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Remove a cloned bundle. 4 | # 5 | # usage: antidote purge [-h|--help] 6 | # antidote purge [-a|--all] 7 | # 8 | #function antidote-purge { 9 | emulate -L zsh; setopt local_options $_adote_funcopts 10 | 11 | local o_help o_all 12 | zparseopts $_adote_zparopt_flags -- \ 13 | h=o_help -help=h \ 14 | a=o_all -all=a || 15 | return 1 16 | 17 | if (( $#o_help )); then 18 | antidote-help purge 19 | return 20 | fi 21 | 22 | if [[ $# -eq 0 ]] && ! (( $#o_all )); then 23 | print -ru2 "antidote: error: required argument 'bundle' not provided, try --help" 24 | return 1 25 | fi 26 | 27 | local bundlefile 28 | zstyle -s ':antidote:bundle' file 'bundlefile' || 29 | bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt 30 | 31 | if (( $#o_all )); then 32 | # last chance to save the user from themselves 33 | local antidote_home="$(antidote-home)" 34 | local REPLY 35 | zstyle -s ':antidote:purge:all' answer 'REPLY' || { 36 | read -q "REPLY?You are about to permanently remove '$antidote_home' and all its contents!"$'\n'"Are you sure [Y/n]? " 37 | print 38 | } 39 | [[ ${REPLY:u} == "Y" ]] || return 1 40 | # remove antidote home and static cache file 41 | __antidote_del -rf -- "$antidote_home" 42 | 43 | if [[ -e "${bundlefile:r}.zsh" ]]; then 44 | zstyle -s ':antidote:purge:all' answer 'REPLY' || { 45 | read -q "REPLY?You are about to remove '${bundlefile:t:r}.zsh'"$'\n'"Are you sure [Y/n]? " 46 | print 47 | } 48 | if [[ ${REPLY:u} == "Y" ]]; then 49 | local dtstmp=$(date -u '+%Y%m%d_%H%M%S') 50 | command mv -f "${bundlefile:r}.zsh" "${bundlefile:r}.${dtstmp}.bak" 51 | print "'"${bundlefile:r}.zsh"' backed up to '${bundlefile:t:r}.${dtstmp}.bak'" 52 | fi 53 | fi 54 | print "Antidote purge complete. Be sure to start a new Zsh session." 55 | 56 | else 57 | local bundle=$1 58 | # make sure the user isn't trying to do something out-of-bounds 59 | if [[ -e "$bundle" ]]; then 60 | print -ru2 "antidote: error: '$bundle' is not a repo and cannot be removed by antidote." 61 | return 2 62 | fi 63 | 64 | local bundledir=$(__antidote_bundle_dir $bundle) 65 | if [[ ! -d "$bundledir" ]]; then 66 | print -ru2 "antidote: error: $bundle does not exist at the expected location: $bundledir" 67 | return 1 68 | fi 69 | 70 | # remove 71 | __antidote_del -rf "$bundledir" 72 | print "Removed '$bundle'." 73 | 74 | # attempt to comment out the bundle from .zsh_plugins.txt 75 | if [[ -e "$bundlefile" ]]; then 76 | local tmpfile="${bundlefile}.antidote.tmp" 77 | $__adote_awkcmd -v pat="$bundle" '$0~"^[[:blank:]]*"pat{print "# " $0;next}1' <$bundlefile >|$tmpfile 78 | command cat "$tmpfile" > "$bundlefile" 79 | __antidote_del -f "$tmpfile" 80 | print "Bundle '$bundle' was commented out in '$bundlefile'." 81 | fi 82 | fi 83 | #} 84 | -------------------------------------------------------------------------------- /functions/antidote-update: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Update antidote and its cloned bundles. 4 | # 5 | # usage: antidote update [-h|--help] 6 | # 7 | #function antidote-update { 8 | 0=${(%):-%x} 9 | emulate -L zsh; setopt local_options $_adote_funcopts 10 | 11 | local o_help o_self o_bundles 12 | zparseopts $_adote_zparopt_flags -- \ 13 | h=o_help -help=h \ 14 | s=o_self -self=s \ 15 | b=o_bundles -bundles=b || 16 | return 1 17 | 18 | if (( $#o_help )); then 19 | antidote-help update 20 | return 21 | fi 22 | 23 | # colors 24 | local green normal 25 | if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then 26 | if (( $+commands[tput] )); then 27 | green=$(tput setaf 2) 28 | normal=$(tput sgr0) 29 | else 30 | green=$'\E[32m' 31 | normal=$'\E[0m' 32 | fi 33 | fi 34 | 35 | if (( $#o_bundles )) || ! (( $#o_self )); then 36 | print "Updating bundles..." 37 | local bundledir url repo 38 | 39 | # remove zcompiled files 40 | __antidote_del -rf -- $(antidote-home)/**/*.zwc(N) 41 | 42 | # remove check file 43 | local loadable_check_path="$(antidote-home)/.antidote.load" 44 | [[ -r "$loadable_check_path" ]] && __antidote_del -- "$loadable_check_path" 45 | 46 | # update all bundles 47 | for bundledir in $(antidote-list --dirs); do 48 | url=$(git -C "$bundledir" config remote.origin.url) 49 | repo="${url:h:t}/${${url:t}%.git}" 50 | print "antidote: checking for updates: $url" 51 | () { 52 | local oldsha=$(git -C "$1" rev-parse --short HEAD) 53 | git -C "$1" pull --quiet --ff --rebase --autostash 54 | git -C "$1" submodule --quiet sync --recursive 55 | git -C "$1" submodule --quiet update --init --recursive --depth 1 56 | local newsha=$(git -C "$1" rev-parse --short HEAD) 57 | if [[ $oldsha != $newsha ]]; then 58 | print "${green}antidote: updated: $2 ${oldsha} -> ${newsha}${normal}" 59 | git -C "$1" --no-pager log --oneline --ancestry-path ${oldsha}..${newsha} 2>/dev/null 60 | fi 61 | 62 | # recompile bundles 63 | if zstyle -t ":antidote:bundle:$repo" zcompile; then 64 | __antidote_bundle_zcompile $bundledir 65 | fi 66 | } "$bundledir" "$url" & 67 | done 68 | print "Waiting for bundle updates to complete..." 69 | print "" 70 | wait 71 | print "${green}Bundle updates complete.${normal}" 72 | print "" 73 | fi 74 | 75 | # update antidote 76 | if (( $#o_self )) || ! (( $#o_bundles )); then 77 | print "Updating antidote..." 78 | if [[ -d "${0:A:h:h}/.git" ]]; then 79 | git -C "${0:A:h:h}" pull --quiet --ff --rebase --autostash 80 | print "antidote self-update complete.\n" 81 | 82 | # setup antidote again 83 | (( $+functions[__antidote_setup] )) && unfunction __antidote_setup 84 | builtin autoload -Uz ${0:A:h}/__antidote_setup 85 | __antidote_setup 86 | 87 | # show antidote version 88 | antidote -v 89 | else 90 | print "Self updating is disabled in this build." 91 | print "Use your OS package manager to update antidote itself." 92 | fi 93 | fi 94 | #} 95 | -------------------------------------------------------------------------------- /tests/test_fpath_rules.md: -------------------------------------------------------------------------------- 1 | # antidote bundle fpath-rule: 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | By default, fpath is appended to: 12 | 13 | ```zsh 14 | % antidote bundle foo/bar kind:fpath 15 | fpath+=( $HOME/.cache/antidote/foo/bar ) 16 | % 17 | ``` 18 | 19 | fpath can be told to explicitly append, but it's unnecessary 20 | 21 | ```zsh 22 | % antidote bundle foo/bar kind:zsh fpath-rule:append 23 | fpath+=( $HOME/.cache/antidote/foo/bar ) 24 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 25 | % 26 | 27 | fpath can be prepended with fpath-rule:prepend 28 | 29 | ```zsh 30 | % antidote bundle foo/bar kind:fpath fpath-rule:prepend 31 | fpath=( $HOME/.cache/antidote/foo/bar $fpath ) 32 | % 33 | 34 | fpath rules can only be append/prepend 35 | 36 | ```zsh 37 | % antidote bundle foo/bar kind:fpath fpath-rule:append #=> --exit 0 38 | % antidote bundle foo/bar kind:fpath fpath-rule:prepend #=> --exit 0 39 | % antidote bundle foo/bar kind:fpath fpath-rule:foo 2>&1 40 | antidote: error: unexpected fpath rule: 'foo' 41 | % 42 | 43 | fpath rules are also used for `kind:autoload` 44 | 45 | ```zsh 46 | % antidote bundle foo/baz path:baz kind:autoload fpath-rule:append 47 | fpath+=( $HOME/.cache/antidote/foo/baz/baz ) 48 | builtin autoload -Uz $fpath[-1]/*(N.:t) 49 | % antidote bundle foo/baz path:baz kind:autoload fpath-rule:prepend 50 | fpath=( $HOME/.cache/antidote/foo/baz/baz $fpath ) 51 | builtin autoload -Uz $fpath[1]/*(N.:t) 52 | % 53 | ``` 54 | 55 | fpath rules are also used for `autoload:funcdir` 56 | 57 | ```zsh 58 | % # Append 59 | % antidote bundle foo/baz autoload:baz fpath-rule:append 60 | fpath+=( $HOME/.cache/antidote/foo/baz/baz ) 61 | builtin autoload -Uz $fpath[-1]/*(N.:t) 62 | fpath+=( $HOME/.cache/antidote/foo/baz ) 63 | source $HOME/.cache/antidote/foo/baz/baz.plugin.zsh 64 | % # Prepend 65 | % antidote bundle foo/baz autoload:baz fpath-rule:prepend 66 | fpath=( $HOME/.cache/antidote/foo/baz/baz $fpath ) 67 | builtin autoload -Uz $fpath[1]/*(N.:t) 68 | fpath=( $HOME/.cache/antidote/foo/baz $fpath ) 69 | source $HOME/.cache/antidote/foo/baz/baz.plugin.zsh 70 | % 71 | ``` 72 | 73 | fpath rules can be set globally with a zstyle: 74 | 75 | `zstyle ':antidote:fpath' rule 'prepend'` 76 | 77 | ```zsh 78 | % zstyle ':antidote:fpath' rule 'prepend' 79 | % antidote bundle foo/bar 80 | fpath=( $HOME/.cache/antidote/foo/bar $fpath ) 81 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 82 | % antidote bundle foo/bar kind:fpath 83 | fpath=( $HOME/.cache/antidote/foo/bar $fpath ) 84 | % antidote bundle foo/baz path:baz kind:autoload 85 | fpath=( $HOME/.cache/antidote/foo/baz/baz $fpath ) 86 | builtin autoload -Uz $fpath[1]/*(N.:t) 87 | % 88 | ``` 89 | 90 | It is NOT recommended to do this, but if you choose to then explicit fpath-rules are 91 | still respected: 92 | 93 | ```zsh 94 | % zstyle ':antidote:fpath' rule 'prepend' 95 | % antidote bundle foo/bar fpath-rule:append 96 | fpath+=( $HOME/.cache/antidote/foo/bar ) 97 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 98 | % antidote bundle foo/bar kind:fpath fpath-rule:append 99 | fpath+=( $HOME/.cache/antidote/foo/bar ) 100 | % antidote bundle foo/baz path:baz kind:autoload fpath-rule:append 101 | fpath+=( $HOME/.cache/antidote/foo/baz/baz ) 102 | builtin autoload -Uz $fpath[-1]/*(N.:t) 103 | % 104 | ``` 105 | 106 | ## Teardown 107 | 108 | ```zsh 109 | % t_teardown 110 | % 111 | ``` 112 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | In the interest of fostering an open and welcoming environment, we as 7 | contributors and maintainers pledge to make participation in our project and 8 | our community a harassment-free experience for everyone, regardless of age, body 9 | size, disability, ethnicity, sex characteristics, gender identity and expression, 10 | level of experience, education, socio-economic status, nationality, personal 11 | appearance, race, religion, or sexual identity and orientation. 12 | 13 | ## Our Standards 14 | 15 | Examples of behavior that contributes to creating a positive environment 16 | include: 17 | 18 | * Using welcoming and inclusive language 19 | * Being respectful of differing viewpoints and experiences 20 | * Gracefully accepting constructive criticism 21 | * Focusing on what is best for the community 22 | * Showing empathy towards other community members 23 | 24 | Examples of unacceptable behavior by participants include: 25 | 26 | * The use of sexualized language or imagery and unwelcome sexual attention or 27 | advances 28 | * Trolling, insulting/derogatory comments, and personal or political attacks 29 | * Public or private harassment 30 | * Publishing others' private information, such as a physical or electronic 31 | address, without explicit permission 32 | * Other conduct which could reasonably be considered inappropriate in a 33 | professional setting 34 | 35 | ## Our Responsibilities 36 | 37 | Project maintainers are responsible for clarifying the standards of acceptable 38 | behavior and are expected to take appropriate and fair corrective action in 39 | response to any instances of unacceptable behavior. 40 | 41 | Project maintainers have the right and responsibility to remove, edit, or 42 | reject comments, commits, code, wiki edits, issues, and other contributions 43 | that are not aligned to this Code of Conduct, or to ban temporarily or 44 | permanently any contributor for other behaviors that they deem inappropriate, 45 | threatening, offensive, or harmful. 46 | 47 | ## Scope 48 | 49 | This Code of Conduct applies within all project spaces, and it also applies when 50 | an individual is representing the project or its community in public spaces. 51 | Examples of representing a project or community include using an official 52 | project e-mail address, posting via an official social media account, or acting 53 | as an appointed representative at an online or offline event. Representation of 54 | a project may be further defined and clarified by project maintainers. 55 | 56 | ## Enforcement 57 | 58 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 59 | reported by contacting the project team at getantidote@gmail.com. All 60 | complaints will be reviewed and investigated and will result in a response that 61 | is deemed necessary and appropriate to the circumstances. The project team is 62 | obligated to maintain confidentiality with regard to the reporter of an incident. 63 | Further details of specific enforcement policies may be posted separately. 64 | 65 | Project maintainers who do not follow or enforce the Code of Conduct in good 66 | faith may face temporary or permanent repercussions as determined by other 67 | members of the project's leadership. 68 | 69 | ## Attribution 70 | 71 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 72 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 73 | 74 | [homepage]: https://www.contributor-covenant.org 75 | 76 | For answers to common questions about this code of conduct, see 77 | https://www.contributor-covenant.org/faq 78 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/plugins/grizwold/grizwold.plugin.zsh: -------------------------------------------------------------------------------- 1 | () { 2 | setopt interactivecomments 3 | typeset -ga grizwold_zopts=( 4 | noaliases 5 | aliasfuncdef 6 | allexport 7 | noalwayslastprompt 8 | alwaystoend 9 | appendcreate 10 | noappendhistory 11 | autocd 12 | autocontinue 13 | noautolist 14 | noautomenu 15 | autonamedirs 16 | noautoparamkeys 17 | noautoparamslash 18 | autopushd 19 | noautoremoveslash 20 | autoresume 21 | nobadpattern 22 | nobanghist 23 | nobareglobqual 24 | bashautolist 25 | bashrematch 26 | nobeep 27 | nobgnice 28 | braceccl 29 | bsdecho 30 | nocaseglob 31 | nocasematch 32 | cbases 33 | cdablevars 34 | cdsilent 35 | chasedots 36 | chaselinks 37 | nocheckjobs 38 | nocheckrunningjobs 39 | # noclobber 40 | combiningchars 41 | completealiases 42 | completeinword 43 | continueonerror 44 | correct 45 | correctall 46 | cprecedences 47 | cshjunkiehistory 48 | cshjunkieloops 49 | cshjunkiequotes 50 | cshnullcmd 51 | cshnullglob 52 | nodebugbeforecmd 53 | dvorak 54 | emacs 55 | noequals 56 | # errexit 57 | # errreturn 58 | noevallineno 59 | # noexec 60 | extendedglob 61 | extendedhistory 62 | noflowcontrol 63 | # forcefloat 64 | nofunctionargzero 65 | noglob 66 | noglobalexport 67 | # noglobalrcs 68 | globassign 69 | globcomplete 70 | globdots 71 | globstarshort 72 | globsubst 73 | nohashcmds 74 | nohashdirs 75 | hashexecutablesonly 76 | nohashlistall 77 | histallowclobber 78 | nohistbeep 79 | histexpiredupsfirst 80 | histfcntllock 81 | histfindnodups 82 | histignorealldups 83 | histignoredups 84 | histignorespace 85 | histlexwords 86 | histnofunctions 87 | histnostore 88 | histreduceblanks 89 | nohistsavebycopy 90 | histsavenodups 91 | histsubstpattern 92 | histverify 93 | nohup 94 | ignorebraces 95 | ignoreclosebraces 96 | ignoreeof 97 | incappendhistory 98 | incappendhistorytime 99 | # interactive 100 | interactivecomments 101 | # ksharrays 102 | kshautoload 103 | kshglob 104 | # kshoptionprint 105 | kshtypeset 106 | kshzerosubscript 107 | nolistambiguous 108 | nolistbeep 109 | listpacked 110 | listrowsfirst 111 | nolisttypes 112 | localloops 113 | # localoptions 114 | localpatterns 115 | localtraps 116 | # login 117 | longlistjobs 118 | magicequalsubst 119 | mailwarning 120 | markdirs 121 | menucomplete 122 | # monitor 123 | nomultibyte 124 | nomultifuncdef 125 | nomultios 126 | nonomatch 127 | nonotify 128 | nullglob 129 | numericglobsort 130 | octalzeroes 131 | overstrike 132 | pathdirs 133 | pathscript 134 | pipefail 135 | posixaliases 136 | posixargzero 137 | posixbuiltins 138 | posixcd 139 | posixidentifiers 140 | posixjobs 141 | # posixstrings 142 | posixtraps 143 | printeightbit 144 | printexitvalue 145 | # privileged 146 | promptbang 147 | nopromptcr 148 | # nopromptpercent 149 | nopromptsp 150 | promptsubst 151 | pushdignoredups 152 | pushdminus 153 | pushdsilent 154 | pushdtohome 155 | rcexpandparam 156 | rcquotes 157 | # norcs 158 | recexact 159 | rematchpcre 160 | # restricted 161 | rmstarsilent 162 | rmstarwait 163 | sharehistory 164 | shfileexpansion 165 | shglob 166 | # shinstdin 167 | shnullcmd 168 | shoptionletters 169 | noshortloops 170 | shwordsplit 171 | # singlecommand 172 | singlelinezle 173 | # sourcetrace 174 | sunkeyboardhack 175 | transientrprompt 176 | trapsasync 177 | typesetsilent 178 | nounset 179 | # verbose 180 | # vi 181 | warncreateglobal 182 | warnnestedvar 183 | # xtrace 184 | # zle 185 | ) 186 | setopt $grizwold_zopts 187 | } 188 | -------------------------------------------------------------------------------- /man/antidote-bundle.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote-bundle 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote bundle** - download a bundle and print its source line 10 | 11 | # SYNOPSIS 12 | 13 | | antidote bundle [\...] 14 | 15 | # DESCRIPTION 16 | 17 | **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. 18 | 19 | | antidote bundle gituser/gitrepo 20 | | antidote bundle $ZSH_CUSTOM/plugins/myplugin 21 | | antidote bundle ${ZDOTDIR:-\$HOME}/.zlibs/myfile.zsh 22 | 23 | Bundles also support annotations. Annotations allow you have finer grained control over your plugins. Annotations are used in the form \'keyword:value\'. 24 | 25 | `kind` 26 | : - **zsh**: A zsh plugin. This is the default kind of bundle. 27 | : - **fpath**: Only add the plugin to your _\$fpath_. 28 | : - **path**: Add the plugin to your _\$PATH_. 29 | : - **clone**: Only clone a plugin, but don't do anything else with it. 30 | : - **defer**: Defers loading of a plugin using \'romkatv/zsh-defer\'. 31 | : - **autoload**: Autoload all the files in the plugin directory as zsh functions. 32 | 33 | `branch` 34 | : The branch annotation allows you to change the default branch of a plugin's repo from **main** to a branch of your choosing. 35 | 36 | `path` 37 | : 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\'). 38 | 39 | `conditional` 40 | : The conditonal 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\'). 41 | 42 | `pre` / `post` 43 | : 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. 44 | 45 | `autoload` 46 | : 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\'). 47 | 48 | Cloned repo directory names can be overridden with the following **zstyle**: 49 | 50 | | zstyle \':antidote:bundle\' use-friendly-names \'yes\' 51 | 52 | # OPTIONS 53 | 54 | -h, \--help 55 | : Show the help documentation. 56 | 57 | [*\...*] 58 | : Zsh plugin bundles 59 | 60 | # EXAMPLES 61 | 62 | Using the **kind:** annotation... 63 | 64 | | # a regular plugin (kind:zsh is implied, so it's unnecessary) 65 | | antidote bundle zsh-users/zsh-history-substring-search kind:zsh 66 | 67 | | # add prompt plugins to $fpath 68 | | antidote bundle sindresorhus/pure kind:fpath 69 | 70 | | # add utility plugins to $PATH 71 | | antidote bundle romkatv/zsh-bench kind:path 72 | 73 | | # clone a repo for use in other ways 74 | | antidote bundle mbadolato/iTerm2-Color-Schemes kind:clone 75 | 76 | | # autoload a functions directory 77 | | antidote bundle sorin-ionescu/prezto path:modules/utility/functions kind:autoload 78 | 79 | | # defer a plugin to speed up load times 80 | | antidote bundle olets/zsh-abbr kind:defer 81 | 82 | Using the **branch:** annotation... 83 | 84 | | # don't use the main branch, use develop instead 85 | | antidote bundle zsh-users/zsh-autosuggestions branch:develop 86 | 87 | Using the **path:** annotation... 88 | 89 | | # load oh-my-zsh 90 | | antidote bundle ohmyzsh/ohmyzsh path:lib 91 | | antidote bundle ohmyzsh/ohmyzsh path:plugins/git 92 | 93 | Using the **conditional:** annotation... 94 | 95 | | # define a conditional function prior to loading antidote 96 | | function is_macos { 97 | | [[ $OSTYPE == darwin* ]] || return 1 98 | | } 99 | | 100 | | # conditionally load a plugin using the function you made 101 | | antidote bundle ohmyzsh/ohmyzsh path:plugins/macos conditional:is_macos 102 | 103 | -------------------------------------------------------------------------------- /functions/_antidote: -------------------------------------------------------------------------------- 1 | #compdef antidote 2 | 3 | function _antidote_subcommands { 4 | local usage=$( 5 | antidote --help | 6 | ${__adote_awkcmd:-awk} ' 7 | BEGIN{OFS=":"; p=0} 8 | /^commands:$/ {p=1; next} 9 | !p{next} 10 | { for(i=3; i<=NF; i++) { $2=$2" "$i } } 11 | { print $1,$2 } 12 | ' 13 | ) 14 | local -a subcommands=("${(@f)usage}") 15 | _describe -t subcommands 'subcommand' subcommands "$@" 16 | } 17 | 18 | function _antidote_installed_bundles { 19 | local -a bundles=("${(@f)$(antidote list -s)}") 20 | _describe 'installed bundles' bundles 21 | } 22 | 23 | function _antidote_bundle_kinds { 24 | local -a kinds=( 25 | 'autoload' 'clone' 'defer' 'fpath' 'path' 'zsh' 26 | ) 27 | _describe 'bundle kinds' kinds 28 | } 29 | 30 | function _antidote { 31 | typeset -A opt_args 32 | local context state line 33 | local curcontext="$curcontext" 34 | local ret=1 35 | 36 | _arguments -C \ 37 | '(- *)'{-v,--version}'[Show version]' \ 38 | '(- *)'{-h,--help}'[Show usage information]' \ 39 | '1: :_antidote_subcommands' \ 40 | '*:: :->subcmds' && return 0 41 | 42 | case "$state" in 43 | (subcmds) 44 | case $words[1] in 45 | (bundle) 46 | _arguments \ 47 | '(- *)'{-h,--help}'[Show usage information]' \ 48 | && ret=0 49 | ;; 50 | (help) 51 | _arguments \ 52 | '(- *)'{-h,--help}'[Show usage information]' \ 53 | && ret=0 54 | ;; 55 | (home) 56 | _arguments \ 57 | '(- *)'{-h,--help}'[Show usage information]' \ 58 | && ret=0 59 | ;; 60 | (init) 61 | _arguments \ 62 | '(- *)'{-h,--help}'[Show usage information]' \ 63 | && ret=0 64 | ;; 65 | (install|script) 66 | _arguments \ 67 | '(- *)'{-h,--help}'[Show usage information]' \ 68 | '(-k --kind)'{-k,--kind}'[The kind of bundle]:kinds:_antidote_bundle_kinds' \ 69 | '(-p --path)'{-p,--path}'[A relative subpath within the bundle where the plugin is located]' \ 70 | '(-a --autoload)'{-a,--autoload}'[A relative subpath within the bundle where autoload function files are located]' \ 71 | '(-c --conditional)'{-c,--conditional}'[A conditional function used to check whether to load the bundle]' \ 72 | '(-b --branch)'{-b,--branch}'[The git branch to use]' \ 73 | '(--pre)--pre[A function to be called prior to loading the bundle]' \ 74 | '(--post)--post[A function to be called after loading the bundle]' \ 75 | && ret=0 76 | ;; 77 | (list) 78 | _arguments \ 79 | '(- *)'{-h,--help}'[Show usage information]' \ 80 | '(-s --short)'{-s,--short}'[Show shortened repos where possible]' \ 81 | '(-d --dirs)'{-d,--dirs}'[Show only bundle directories]' \ 82 | '(-u --url)'{-u,--url}'[Show bundle URLs]' \ 83 | && ret=0 84 | ;; 85 | (load) 86 | _arguments \ 87 | '(- *)'{-h,--help}'[Show usage information]' \ 88 | && ret=0 89 | ;; 90 | (path) 91 | _arguments \ 92 | '(- *)'{-h,--help}'[Show usage information]' \ 93 | && ret=0 94 | ;; 95 | (purge) 96 | _arguments \ 97 | '(- *)'{-h,--help}'[Show usage information]' \ 98 | '(-a --all)'{-a,--all}'[Purge all cloned bundles]' \ 99 | "*::antidote bundles:_antidote_installed_bundles" \ 100 | && ret=0 101 | ;; 102 | (update) 103 | _arguments \ 104 | '(- *)'{-h,--help}'[Show usage information]' \ 105 | '(-s --selp)'{-s,--self}'[Update antidote]' \ 106 | '(-b --bundles)'{-b,--bundles}'[Update bundles]' \ 107 | && ret=0 108 | ;; 109 | (*) 110 | _arguments \ 111 | '(- *)'{-h,--help}'[Show usage information]' \ 112 | '*: :_files' \ 113 | && ret=0 114 | ;; 115 | esac 116 | ;; 117 | esac 118 | 119 | return ret 120 | } 121 | _antidote "$@" 122 | 123 | # vim: ft=zsh sw=2 ts=2 et 124 | -------------------------------------------------------------------------------- /tests/test_cmd_help.md: -------------------------------------------------------------------------------- 1 | # antidote help tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## General 12 | 13 | `antidote help` command exists 14 | 15 | ```zsh 16 | % antidote help &>/dev/null; echo $? 17 | 0 18 | % 19 | ``` 20 | 21 | `antidote --h/--help` works 22 | 23 | ```zsh 24 | % antidote -h &>/dev/null; echo $? 25 | 0 26 | % antidote --help &>/dev/null; echo $? 27 | 0 28 | % 29 | ``` 30 | 31 | `antidote` man pages work 32 | 33 | ```zsh 34 | % PAGER=cat man antidote | head -n 1 | sed 's/ */ /g' 35 | antidote(1) Antidote Manual antidote(1) 36 | % 37 | ``` 38 | 39 | `antidote` man pages are in `$MANPATH` 40 | ```zsh 41 | % [[ "$MANPATH" == *"$PWD/man:"* ]] || echo 'MANPATH not set properly' 42 | % 43 | ``` 44 | 45 | ## antidote-bundle 46 | 47 | ```zsh 48 | % antidote help bundle | head -n 1 | sed 's/ */ /g' 49 | antidote-bundle(1) Antidote Manual antidote-bundle(1) 50 | % antidote bundle --help | head -n 1 | sed 's/ */ /g' 51 | antidote-bundle(1) Antidote Manual antidote-bundle(1) 52 | % antidote bundle -h | head -n 1 | sed 's/ */ /g' 53 | antidote-bundle(1) Antidote Manual antidote-bundle(1) 54 | % 55 | ``` 56 | 57 | ## antidote-help 58 | 59 | ```zsh 60 | % antidote help help | head -n 1 | sed 's/ */ /g' 61 | antidote-help(1) Antidote Manual antidote-help(1) 62 | % antidote help --help | head -n 1 | sed 's/ */ /g' 63 | antidote-help(1) Antidote Manual antidote-help(1) 64 | % antidote help -h | head -n 1 | sed 's/ */ /g' 65 | antidote-help(1) Antidote Manual antidote-help(1) 66 | % 67 | ``` 68 | 69 | ## antidote-home 70 | 71 | ```zsh 72 | % antidote help home | head -n 1 | sed 's/ */ /g' 73 | antidote-home(1) Antidote Manual antidote-home(1) 74 | % antidote home --help | head -n 1 | sed 's/ */ /g' 75 | antidote-home(1) Antidote Manual antidote-home(1) 76 | % antidote home -h | head -n 1 | sed 's/ */ /g' 77 | antidote-home(1) Antidote Manual antidote-home(1) 78 | % 79 | ``` 80 | 81 | ## antidote-init 82 | 83 | ```zsh 84 | % antidote help init | head -n 1 | sed 's/ */ /g' 85 | antidote-init(1) Antidote Manual antidote-init(1) 86 | % antidote init --help | head -n 1 | sed 's/ */ /g' 87 | antidote-init(1) Antidote Manual antidote-init(1) 88 | % antidote init -h | head -n 1 | sed 's/ */ /g' 89 | antidote-init(1) Antidote Manual antidote-init(1) 90 | % 91 | ``` 92 | 93 | ## antidote-install 94 | 95 | ```zsh 96 | % antidote help install | head -n 1 | sed 's/ */ /g' 97 | antidote-install(1) Antidote Manual antidote-install(1) 98 | % antidote install --help | head -n 1 | sed 's/ */ /g' 99 | antidote-install(1) Antidote Manual antidote-install(1) 100 | % antidote install -h | head -n 1 | sed 's/ */ /g' 101 | antidote-install(1) Antidote Manual antidote-install(1) 102 | % 103 | ``` 104 | 105 | ## antidote-list 106 | 107 | ```zsh 108 | % antidote help list | head -n 1 | sed 's/ */ /g' 109 | antidote-list(1) Antidote Manual antidote-list(1) 110 | % antidote list --help | head -n 1 | sed 's/ */ /g' 111 | antidote-list(1) Antidote Manual antidote-list(1) 112 | % antidote list -h | head -n 1 | sed 's/ */ /g' 113 | antidote-list(1) Antidote Manual antidote-list(1) 114 | % 115 | ``` 116 | 117 | ## antidote-load 118 | 119 | ```zsh 120 | % antidote help load | head -n 1 | sed 's/ */ /g' 121 | antidote-load(1) Antidote Manual antidote-load(1) 122 | % antidote load --help | head -n 1 | sed 's/ */ /g' 123 | antidote-load(1) Antidote Manual antidote-load(1) 124 | % antidote load -h | head -n 1 | sed 's/ */ /g' 125 | antidote-load(1) Antidote Manual antidote-load(1) 126 | % 127 | ``` 128 | 129 | ## antidote-path 130 | 131 | ```zsh 132 | % antidote help path | head -n 1 | sed 's/ */ /g' 133 | antidote-path(1) Antidote Manual antidote-path(1) 134 | % antidote path --help | head -n 1 | sed 's/ */ /g' 135 | antidote-path(1) Antidote Manual antidote-path(1) 136 | % antidote path -h | head -n 1 | sed 's/ */ /g' 137 | antidote-path(1) Antidote Manual antidote-path(1) 138 | % 139 | ``` 140 | 141 | ## antidote-update 142 | 143 | ```zsh 144 | % antidote help update | head -n 1 | sed 's/ */ /g' 145 | antidote-update(1) Antidote Manual antidote-update(1) 146 | % antidote update --help | head -n 1 | sed 's/ */ /g' 147 | antidote-update(1) Antidote Manual antidote-update(1) 148 | % antidote update -h | head -n 1 | sed 's/ */ /g' 149 | antidote-update(1) Antidote Manual antidote-update(1) 150 | % 151 | ``` 152 | 153 | ## antidote-script 154 | 155 | ```zsh 156 | % antidote help script 157 | No manual entry for antidote-script 158 | antidote - the cure to slow zsh plugin management 159 | 160 | usage: antidote [] [ ...] 161 | 162 | flags: 163 | -h, --help Show context-sensitive help 164 | -v, --version Show application version 165 | 166 | commands: 167 | help Show documentation 168 | load Statically source all bundles from the plugins file 169 | bundle Clone bundle(s) and generate the static load script 170 | install Clone a new bundle and add it to your plugins file 171 | update Update antidote and its cloned bundles 172 | purge Remove a cloned bundle 173 | home Print where antidote is cloning bundles 174 | list List cloned bundles 175 | path Print the path of a cloned bundle 176 | init Initialize the shell for dynamic bundles 177 | % 178 | ``` 179 | 180 | ## Teardown 181 | 182 | ```zsh 183 | % t_teardown 184 | % 185 | ``` 186 | -------------------------------------------------------------------------------- /man/man1/antidote-bundle.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote\-bundle" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote bundle\f[R] \- download a bundle and print its source line 6 | .SH SYNOPSIS 7 | .PP 8 | antidote bundle [\&...] 9 | .SH DESCRIPTION 10 | \f[B]antidote\-bundle\f[R] assembles your Zsh plugins. 11 | Bundles can be git repos, or local files or directories. 12 | If a plugin is a repo, it will be cloned if necessary. 13 | The zsh code necessary to load (source) the plugin is then printed. 14 | .PP 15 | \ \ antidote bundle gituser/gitrepo 16 | .PD 0 17 | .P 18 | .PD 19 | \ \ antidote bundle $ZSH_CUSTOM/plugins/myplugin 20 | .PD 0 21 | .P 22 | .PD 23 | \ \ antidote bundle ${ZDOTDIR:\-$HOME}/.zlibs/myfile.zsh 24 | .PP 25 | Bundles also support annotations. 26 | Annotations allow you have finer grained control over your plugins. 27 | Annotations are used in the form \[aq]keyword:value\[aq]. 28 | .TP 29 | \f[CR]kind\f[R] 30 | .IP \[bu] 2 31 | \f[B]zsh\f[R]: A zsh plugin. 32 | This is the default kind of bundle. 33 | .IP \[bu] 2 34 | \f[B]fpath\f[R]: Only add the plugin to your \f[I]$fpath\f[R]. 35 | .IP \[bu] 2 36 | \f[B]path\f[R]: Add the plugin to your \f[I]$PATH\f[R]. 37 | .IP \[bu] 2 38 | \f[B]clone\f[R]: Only clone a plugin, but don\[cq]t do anything else 39 | with it. 40 | .IP \[bu] 2 41 | \f[B]defer\f[R]: Defers loading of a plugin using 42 | \[aq]romkatv/zsh\-defer\[aq]. 43 | .IP \[bu] 2 44 | \f[B]autoload\f[R]: Autoload all the files in the plugin directory as 45 | zsh functions. 46 | .TP 47 | \f[CR]branch\f[R] 48 | The branch annotation allows you to change the default branch of a 49 | plugin\[cq]s repo from \f[B]main\f[R] to a branch of your choosing. 50 | .TP 51 | \f[CR]path\f[R] 52 | The path annotation allows you to use a subdirectory or file within a 53 | plugin\[cq]s structure instead of the root plugin (eg: 54 | \[aq]path:plugins/subplugin\[aq]). 55 | .TP 56 | \f[CR]conditional\f[R] 57 | The conditonal annotation allows you to wrap an \f[B]if\f[R] statement 58 | around a plugin\[cq]s load script. 59 | Supply the name of a zero argument zsh function to conditional to 60 | perform the test (eg: \[aq]conditional:is\-macos\[aq]). 61 | .TP 62 | \f[CR]pre\f[R] / \f[CR]post\f[R] 63 | The pre and post annotations allow you to call a function before or 64 | after a plugin\[cq]s load script. 65 | This is helpful when configuring plugins, since the configuration 66 | functions will only run for active plugins. 67 | Supply the name of a zero argument zsh function to pre or post. 68 | .TP 69 | \f[CR]autoload\f[R] 70 | The autoload annotation allows you to autoload a zsh functions directory 71 | in addition to however the plugin was loaded as specified by 72 | \[aq]kind\[aq]. 73 | Supply a relative path to autoload (eg: \[aq]autoload:functions\[aq]). 74 | .PP 75 | Cloned repo directory names can be overridden with the following 76 | \f[B]zstyle\f[R]: 77 | .PP 78 | \ \ zstyle \[aq]:antidote:bundle\[aq] use\-friendly\-names \[aq]yes\[aq] 79 | .SH OPTIONS 80 | .TP 81 | \-h, \-\-help 82 | Show the help documentation. 83 | .TP 84 | [\f[I]\&...\f[R]] 85 | Zsh plugin bundles 86 | .SH EXAMPLES 87 | Using the \f[B]kind:\f[R] annotation\&... 88 | .PP 89 | \ \ # a regular plugin (kind:zsh is implied, so it\[cq]s unnecessary) 90 | .PD 0 91 | .P 92 | .PD 93 | \ \ antidote bundle zsh\-users/zsh\-history\-substring\-search kind:zsh 94 | .PP 95 | \ \ # add prompt plugins to $fpath 96 | .PD 0 97 | .P 98 | .PD 99 | \ \ antidote bundle sindresorhus/pure kind:fpath 100 | .PP 101 | \ \ # add utility plugins to $PATH 102 | .PD 0 103 | .P 104 | .PD 105 | \ \ antidote bundle romkatv/zsh\-bench kind:path 106 | .PP 107 | \ \ # clone a repo for use in other ways 108 | .PD 0 109 | .P 110 | .PD 111 | \ \ antidote bundle mbadolato/iTerm2\-Color\-Schemes kind:clone 112 | .PP 113 | \ \ # autoload a functions directory 114 | .PD 0 115 | .P 116 | .PD 117 | \ \ antidote bundle sorin\-ionescu/prezto path:modules/utility/functions 118 | kind:autoload 119 | .PP 120 | \ \ # defer a plugin to speed up load times 121 | .PD 0 122 | .P 123 | .PD 124 | \ \ antidote bundle olets/zsh\-abbr kind:defer 125 | .PP 126 | Using the \f[B]branch:\f[R] annotation\&... 127 | .PP 128 | \ \ # don\[cq]t use the main branch, use develop instead 129 | .PD 0 130 | .P 131 | .PD 132 | \ \ antidote bundle zsh\-users/zsh\-autosuggestions branch:develop 133 | .PP 134 | Using the \f[B]path:\f[R] annotation\&... 135 | .PP 136 | \ \ # load oh\-my\-zsh 137 | .PD 0 138 | .P 139 | .PD 140 | \ \ antidote bundle ohmyzsh/ohmyzsh path:lib 141 | .PD 0 142 | .P 143 | .PD 144 | \ \ antidote bundle ohmyzsh/ohmyzsh path:plugins/git 145 | .PP 146 | Using the \f[B]conditional:\f[R] annotation\&... 147 | .PP 148 | \ \ # define a conditional function prior to loading antidote 149 | .PD 0 150 | .P 151 | .PD 152 | \ \ function is_macos { 153 | .PD 0 154 | .P 155 | .PD 156 | \ \ \ \ [[ $OSTYPE == darwin* ]] || return 1 157 | .PD 0 158 | .P 159 | .PD 160 | \ \ } 161 | .PD 0 162 | .P 163 | .PD 164 | .PD 0 165 | .P 166 | .PD 167 | \ \ # conditionally load a plugin using the function you made 168 | .PD 0 169 | .P 170 | .PD 171 | \ \ antidote bundle ohmyzsh/ohmyzsh path:plugins/macos 172 | conditional:is_macos 173 | .SH BUGS 174 | See GitHub Issues: \c 175 | .UR https://github.com/mattmc3/antidote/issues 176 | .UE \c 177 | .SH AUTHORS 178 | .IP \[bu] 2 179 | Copyright (c) 2021\-2024 Matt McElheny 180 | .IP \[bu] 2 181 | antidote contributors: \c 182 | .UR https://github.com/mattmc3/antidote/graphs/contributors 183 | .UE \c 184 | .SH LICENSE 185 | MIT 186 | -------------------------------------------------------------------------------- /tests/test_bundle_helpers.md: -------------------------------------------------------------------------------- 1 | # antidote bundle helper tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % TESTDATA=$PWD/tests/testdata 7 | % source ./tests/_setup.zsh 8 | % source ./antidote.zsh 9 | % antidote-bundle -h &>/dev/null 10 | % 11 | ``` 12 | 13 | ## Awk filter repos 14 | 15 | The repo parser pulls a list of all git URLs in a bundle file so that we can clone missing ones in parallel. 16 | 17 | ```zsh 18 | % __antidote_bulk_clone $TESTDATA/.zsh_plugins_repos.txt 19 | antidote-script --kind clone --branch baz foobar/foobar & 20 | antidote-script --kind clone bar/baz & 21 | antidote-script --kind clone getantidote/zsh-defer & 22 | antidote-script --kind clone git@github.com:user/repo & 23 | antidote-script --kind clone http://github.com/user/repo.git & 24 | antidote-script --kind clone https://github.com/foo/baz & 25 | antidote-script --kind clone https://github.com/foo/qux & 26 | antidote-script --kind clone https://github.com/user/repo & 27 | antidote-script --kind clone user/repo & 28 | wait 29 | % 30 | ``` 31 | 32 | Test empty 33 | 34 | ```zsh 35 | % __antidote_bulk_clone $TESTDATA/.zsh_plugins_empty.txt 36 | wait 37 | % 38 | ``` 39 | 40 | ## Awk Filter defers 41 | 42 | Test that only the first defer block is kept... 43 | 44 | ```zsh 45 | % __antidote_filter_defers $PWD/tests/testdata/.zsh_plugins_multi_defer.zsh | subenv ANTIDOTE_HOME 46 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search ) 47 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh 48 | if ! (( $+functions[zsh-defer] )); then 49 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer ) 50 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/zsh-defer.plugin.zsh 51 | fi 52 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting ) 53 | zsh-defer source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh 54 | if is-macos; then 55 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos ) 56 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/macos/macos.plugin.zsh 57 | fi 58 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions ) 59 | zsh-defer source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh 60 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting ) 61 | zsh-defer source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 62 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh ) 63 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-dracula-SLASH-zsh/dracula.zsh-theme 64 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh ) 65 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-peterhurford-SLASH-up.zsh/up.plugin.zsh 66 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf ) 67 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rummik-SLASH-zsh-tailf/tailf.plugin.zsh 68 | fpath+=( $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z ) 69 | source $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-rupa-SLASH-z/z.sh 70 | % 71 | ``` 72 | 73 | Test that with no defers, nothing is altered... 74 | 75 | ```zsh 76 | % __antidote_filter_defers $PWD/tests/testdata/.zsh_plugins_no_defer.zsh #=> --file testdata/.zsh_plugins_no_defer.zsh 77 | % 78 | ``` 79 | 80 | ## Awk Bundle parser 81 | 82 | Parse a simple repo: 83 | 84 | ```zsh 85 | % echo foo/bar | __antidote_parse_bundles 86 | antidote-script foo/bar 87 | % 88 | ``` 89 | 90 | ```zsh 91 | % echo 'https://github.com/foo/bar path:lib branch:dev' | __antidote_parse_bundles 92 | antidote-script --path lib --branch dev https://github.com/foo/bar 93 | % echo 'git@github.com:foo/bar.git kind:clone branch:main' | __antidote_parse_bundles 94 | antidote-script --kind clone --branch main git@github.com:foo/bar.git 95 | % echo 'foo/bar kind:fpath abc:xyz' | __antidote_parse_bundles 96 | antidote-script --kind fpath --abc xyz foo/bar 97 | % echo 'foo/bar path:plugins/myplugin kind:path # trailing comment' | __antidote_parse_bundles 98 | antidote-script --path plugins/myplugin --kind path foo/bar 99 | % 100 | ``` 101 | 102 | Handle funky whitespace 103 | 104 | ```zsh 105 | % cr=$'\r'; lf=$'\n'; tab=$'\t' 106 | % echo "foo/bar${tab}kind:path${cr}${lf}" | __antidote_parse_bundles 107 | antidote-script --kind path foo/bar 108 | % 109 | ``` 110 | 111 | The bundle parser is an awk script that turns the bundle DSL into antidote-script statements. 112 | 113 | ```zsh 114 | % __antidote_parse_bundles $ZDOTDIR/.zsh_plugins.txt 115 | antidote-script ~/foo/bar 116 | antidote-script --path plugins/myplugin \$ZSH_CUSTOM 117 | antidote-script foo/bar 118 | antidote-script git@github.com:foo/qux.git 119 | antidote-script --kind clone getantidote/zsh-defer 120 | antidote-script --kind zsh foo/bar 121 | antidote-script --kind fpath foo/bar 122 | antidote-script --kind path foo/bar 123 | antidote-script --path lib ohmy/ohmy 124 | antidote-script --path plugins/extract ohmy/ohmy 125 | antidote-script --path plugins/magic-enter --kind defer ohmy/ohmy 126 | antidote-script --path custom/themes/pretty.zsh-theme ohmy/ohmy 127 | % 128 | ``` 129 | 130 | ## Teardown 131 | 132 | ```zsh 133 | % t_teardown 134 | % 135 | ``` 136 | -------------------------------------------------------------------------------- /man/antidote.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: antidote 3 | section: 1 4 | header: Antidote Manual 5 | --- 6 | 7 | # NAME 8 | 9 | **antidote** - the cure to slow zsh plugin management 10 | 11 | # SYNOPSIS 12 | 13 | | antidote [-v | --version] [-h | --help] \ [\ ...] 14 | 15 | # DESCRIPTION 16 | 17 | **antidote** is a Zsh plugin manager made from the ground up thinking about performance. 18 | 19 | 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. 20 | 21 | It is written natively in Zsh, is well tested, and picks up where Antigen and Antibody left off. 22 | 23 | # OPTIONS 24 | 25 | -h, \--help 26 | : Show context-sensitive help for antidote. 27 | 28 | -v, \--version 29 | : Show currently installed antidote version. 30 | 31 | # COMMANDS 32 | 33 | `help` 34 | : Show documentation 35 | 36 | `load` 37 | : Statically source all bundles from the plugins file 38 | 39 | `bundle` 40 | : Clone bundle(s) and generate the static load script 41 | 42 | `install` 43 | : Clone a new bundle and add it to your plugins file 44 | 45 | `update` 46 | : Update antidote and its cloned bundles 47 | 48 | `purge` 49 | : Remove a cloned bundle 50 | 51 | `home` 52 | : Print where antidote is cloning bundles 53 | 54 | `list` 55 | : List cloned bundles 56 | 57 | `path` 58 | : Print the path of a cloned bundle 59 | 60 | `init` 61 | : Initialize the shell for dynamic bundles 62 | 63 | # EXAMPLES 64 | 65 | ## A Simple Config 66 | 67 | Create a _.zsh_plugins.txt_ file with a list of the plugins you want: 68 | 69 | | # ${ZDOTDIR:-\$HOME}/.zsh_plugins.txt 70 | | zsh-users/zsh-syntax-highlighting 71 | | zsh-users/zsh-history-substring-search 72 | | zsh-users/zsh-autosuggestions 73 | 74 | Now, simply load your newly created static plugins file in your _.zshrc_. 75 | 76 | | # ${ZDOTDIR:-\$HOME}/.zshrc 77 | | source /path/to/antidote/antidote.zsh 78 | | antidote load 79 | 80 | ## A More Advanced Config 81 | 82 | 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: 83 | 84 | | # ${ZDOTDIR:-\$HOME}/.zsh_plugins.txt 85 | | ohmyzsh/ohmyzsh path:lib 86 | | ohmyzsh/ohmyzsh path:plugins/git 87 | | ohmyzsh/ohmyzsh path:plugins/magic-enter 88 | | etc... 89 | 90 | ## Dynamic Bundling 91 | 92 | 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**. 93 | 94 | An example config might look like this: 95 | 96 | | source /path/to/antidote/antidote.zsh 97 | | source <(antidote init) 98 | | antidote bundle zsh-users/zsh-autosuggestions 99 | | antidote bundle ohmyzsh/ohmyzsh path:lib 100 | | antidote bundle ohmyzsh/ohmyzsh path:plugins/git 101 | 102 | Instead of calling **antidote bundle** over and over, you might prefer to load bundles with a HEREDOC. 103 | 104 | | source /path/to/antidote/antidote.zsh 105 | | source <(antidote init) 106 | | antidote bundle < 9 | GetAntidote Logo 13 | 14 | 15 | > [Get the cure][antidote] 16 | 17 | [Antidote][antidote] is a feature-complete Zsh implementation of the legacy 18 | [Antibody][antibody] plugin manager, which in turn was derived from [Antigen][antigen]. 19 | Antidote not only aims to provide continuity for those legacy plugin managers, but also 20 | to delight new users with high-performance, easy-to-use Zsh plugin management. 21 | 22 | ## NOTICE 23 | 24 | **The planned upcoming 2.0 release will stop defaulting to compatibility with 25 | antibody.** If maintaining compatibility with antibody is important to you, you can 26 | ensure that your config remains compatible by add the following `zstyle` to your config 27 | **now**, before the 2.0 release goes live: 28 | 29 | ```zsh 30 | zstyle ':antidote:compatibility-mode' 'antibody' 'on' 31 | ``` 32 | 33 | Breaking compatibility by default will allow antidote to continue to grow and gain new 34 | features, as well as fix some long-standing issues that have always been present in 35 | antibody, for example: 36 | 37 | - In 2.0, `fpath` can be fully set at the beginning of your bundles in you static file, 38 | making setting up completion bundles properly way easier and less frustrating 39 | ([#74](https://github.com/mattmc3/antidote/discussions/74), 40 | [#144](https://github.com/mattmc3/antidote/issues/144)). 41 | - bundles will no longer default to using fugly directory names 42 | ($ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar), making 43 | `zstyle ':antidote:bundle' use-friendly-names on` obsolete. 44 | - probably some other minor deviations as well 45 | 46 | Just to be clear, if you don't specifically care about backwards compatibility with 47 | antibody, you do not need to change a thing. 2.x will not break your 1.x antidote 48 | config. If you do care, be sure to add the compatibility mode `zstyle` above to your 49 | config **now**, before the 2.0 release. 50 | 51 | ## Usage 52 | 53 | Basic usage should look really familiar to you if you have used Antibody or Antigen. 54 | Bundles (aka: Zsh plugins) are stored in a file typically called `.zsh_plugins.txt`. 55 | 56 | ```zsh 57 | # .zsh_plugins.txt 58 | rupa/z # some bash plugins work too 59 | sindresorhus/pure # enhance your prompt 60 | 61 | # you can even use Oh My Zsh plugins 62 | getantidote/use-omz 63 | ohmyzsh/ohmyzsh path:lib 64 | ohmyzsh/ohmyzsh path:plugins/extract 65 | 66 | # add fish-like features 67 | zsh-users/zsh-syntax-highlighting 68 | zsh-users/zsh-autosuggestions 69 | zsh-users/zsh-history-substring-search 70 | ``` 71 | 72 | A typical `.zshrc` might then look like: 73 | 74 | ```zsh 75 | # .zshrc 76 | source /path-to-antidote/antidote.zsh 77 | antidote load ${ZDOTDIR:-$HOME}/.zsh_plugins.txt 78 | ``` 79 | 80 | The full documentation can be found at [https://antidote.sh][antidote]. 81 | 82 | ## Help getting started 83 | 84 | If you want to see a full-featured example Zsh configuration using antidote, you can 85 | have a look at this [example zdotdir](https://github.com/getantidote/zdotdir) project. 86 | Feel free to incorporate code or plugins from it into your own dotfiles, or you can fork 87 | it to get started building your own Zsh config from scratch driven by antidote. 88 | 89 | ## Installation 90 | 91 | ### Install with git 92 | 93 | You can install the latest release of antidote by cloning it with `git`: 94 | 95 | ```zsh 96 | # first, run this from an interactive zsh terminal session: 97 | git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-$HOME}/.antidote 98 | ``` 99 | 100 | ### Install with a package manager 101 | 102 | antidote may also be available in your system's package manager: 103 | 104 | - [macOS homebrew](https://formulae.brew.sh/formula/antidote): `brew install antidote` 105 | - [Arch AUR](https://aur.archlinux.org/packages/zsh-antidote): `yay -S zsh-antidote` 106 | - [Nix Home-Manager](https://mipmip.github.io/home-manager-option-search/?query=antidote) : `programs.zsh.antidote.enable = true;` 107 | 108 | ## Performance 109 | 110 | antidote supports ultra-high performance plugin loads using a static plugin file. 111 | It also allows deferred loading for [plugins that support it](https://github.com/romkatv/zsh-defer#caveats). 112 | 113 | ```zsh 114 | # .zsh_plugins.txt 115 | # some plugins support deferred loading 116 | zdharma-continuum/fast-syntax-highlighting kind:defer 117 | zsh-users/zsh-autosuggestions kind:defer 118 | zsh-users/zsh-history-substring-search kind:defer 119 | ``` 120 | 121 | ```zsh 122 | # .zshrc 123 | # Lazy-load antidote and generate the static load file only when needed 124 | zsh_plugins=${ZDOTDIR:-$HOME}/.zsh_plugins 125 | if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then 126 | ( 127 | source /path-to-antidote/antidote.zsh 128 | antidote bundle <${zsh_plugins}.txt >${zsh_plugins}.zsh 129 | ) 130 | fi 131 | source ${zsh_plugins}.zsh 132 | ``` 133 | 134 | ## Benchmarks 135 | 136 | You can see how antidote compares with other setups [here][benchmarks]. 137 | 138 | ## Plugin authors 139 | 140 | If you authored a Zsh plugin, the recommended snippet for antidote is: 141 | 142 | ```zsh 143 | antidote install gh_user/gh_repo 144 | ``` 145 | 146 | If your plugin is hosted somewhere other than GitHub, you can use this: 147 | 148 | ```zsh 149 | antidote install https://bitbucket.org/bb_user/bb_repo 150 | ``` 151 | 152 | ## Credits 153 | 154 | A big thank you to [Carlos](https://github.com/caarlos0) for all his work on 155 | [antibody] over the years. 156 | 157 | [antigen]: https://github.com/zsh-users/antigen 158 | [antibody]: https://github.com/getantibody/antibody 159 | [antidote]: https://antidote.sh 160 | [benchmarks]: https://github.com/romkatv/zsh-bench/blob/master/doc/linux-desktop.md 161 | [zsh]: https://www.zsh.org 162 | -------------------------------------------------------------------------------- /tests/test_helpers.md: -------------------------------------------------------------------------------- 1 | # antidote helper tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/_setup.zsh 7 | % source ./antidote.zsh 8 | % 9 | ``` 10 | 11 | ## Safe removal 12 | 13 | Appease my paranoia and ensure that you can't remove a path you shouldn't be able to: 14 | 15 | ```zsh 16 | % __antidote_del -rf -- /foo/bar 17 | antidote: Blocked attempt to rm path: '/foo/bar'. 18 | % 19 | ``` 20 | 21 | ## Pretty print path 22 | 23 | ```zsh 24 | % __antidote_print_path /foo/bar 25 | /foo/bar 26 | % __antidote_print_path $HOME/foo/bar 27 | $HOME/foo/bar 28 | % zstyle ':antidote:compatibility-mode' 'antibody' 'on' 29 | % __antidote_print_path $HOME/foo/bar | subenv T_TEMPDIR 30 | $T_TEMPDIR/foo/bar 31 | % zstyle -d ':antidote:compatibility-mode' 'antibody' 32 | % 33 | ``` 34 | 35 | ## Bundle type 36 | 37 | ```zsh 38 | % __antidote_bundle_type $PWD/antidote.zsh 39 | file 40 | % __antidote_bundle_type $PWD/functions 41 | dir 42 | % __antidote_bundle_type '$PWD/antidote.zsh' 43 | file 44 | % __antidote_bundle_type \$PWD/functions 45 | dir 46 | % __antidote_bundle_type 'git@github.com:foo/bar.git' 47 | sshurl 48 | % __antidote_bundle_type 'https://github.com/foo/bar' 49 | url 50 | % __antidote_bundle_type 'https:/bad.com/foo/bar.git' 51 | ? 52 | % __antidote_bundle_type '' 53 | empty 54 | % __antidote_bundle_type ' ' 55 | empty 56 | % __antidote_bundle_type /foo/bar 57 | path 58 | % __antidote_bundle_type /foobar 59 | path 60 | % __antidote_bundle_type foobar/ 61 | relpath 62 | % __antidote_bundle_type '~/foo/bar' 63 | path 64 | % __antidote_bundle_type '$foo/bar' 65 | path 66 | % __antidote_bundle_type \$ZDOTDIR/foo 67 | path 68 | % __antidote_bundle_type \$ZDOTDIR/.zsh_plugins.txt 69 | file 70 | % touch ~/.zshenv 71 | % __antidote_bundle_type '~/.zshenv' 72 | file 73 | % __antidote_bundle_type '~/null' 74 | path 75 | % __antidote_bundle_type foo/bar 76 | repo 77 | % __antidote_bundle_type bar/baz.git 78 | repo 79 | % __antidote_bundle_type foo/bar/baz 80 | relpath 81 | % __antidote_bundle_type foobar 82 | word 83 | % __antidote_bundle_type foo bar baz 84 | word 85 | % __antidote_bundle_type 'foo bar baz' 86 | word 87 | % 88 | ``` 89 | 90 | ## Bundle name 91 | 92 | ```zsh 93 | % __antidote_bundle_name $HOME/.zsh/custom/lib/lib1.zsh 94 | $HOME/.zsh/custom/lib/lib1.zsh 95 | % __antidote_bundle_name $HOME/.zsh/plugins/myplugin 96 | $HOME/.zsh/plugins/myplugin 97 | % __antidote_bundle_name 'git@github.com:foo/bar.git' 98 | foo/bar 99 | % __antidote_bundle_name 'https://github.com/foo/bar' 100 | foo/bar 101 | % __antidote_bundle_name 'https:/bad.com/foo/bar.git' 102 | https:/bad.com/foo/bar.git 103 | % __antidote_bundle_name '' 104 | 105 | % __antidote_bundle_name /foo/bar 106 | /foo/bar 107 | % __antidote_bundle_name /foobar 108 | /foobar 109 | % __antidote_bundle_name foobar/ 110 | foobar/ 111 | % __antidote_bundle_name '~/foo/bar' 112 | $HOME/foo/bar 113 | % __antidote_bundle_name '$foo/bar' 114 | $foo/bar 115 | % __antidote_bundle_name foo/bar 116 | foo/bar 117 | % __antidote_bundle_name bar/baz.git 118 | bar/baz.git 119 | % __antidote_bundle_name foo/bar/baz 120 | foo/bar/baz 121 | % __antidote_bundle_name foobar 122 | foobar 123 | % __antidote_bundle_name foo bar baz 124 | foo 125 | % __antidote_bundle_name 'foo bar baz' 126 | foo bar baz 127 | % 128 | ``` 129 | 130 | ## Bundle dir 131 | 132 | ```zsh 133 | % zstyle ':antidote:bundle' use-friendly-names off 134 | % # short repo 135 | % __antidote_bundle_dir foo/bar | subenv ANTIDOTE_HOME 136 | $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar 137 | % # repo url 138 | % __antidote_bundle_dir https://github.com/foo/bar | subenv ANTIDOTE_HOME 139 | $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar 140 | % # repo url.git 141 | % __antidote_bundle_dir https://github.com/foo/bar.git | subenv ANTIDOTE_HOME 142 | $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar 143 | % # repo ssh 144 | % __antidote_bundle_dir git@github.com:foo/bar.git | subenv ANTIDOTE_HOME 145 | $ANTIDOTE_HOME/git-AT-github.com-COLON-foo-SLASH-bar 146 | % # local dir 147 | % __antidote_bundle_dir ~/foo/bar | subenv HOME 148 | $HOME/foo/bar 149 | % # another local dir 150 | % __antidote_bundle_dir $ZDOTDIR/bar/baz | subenv ZDOTDIR 151 | $ZDOTDIR/bar/baz 152 | % 153 | ``` 154 | 155 | Use friendly names 156 | 157 | ```zsh 158 | % # short repo - friendly name 159 | % zstyle ':antidote:bundle' use-friendly-names on 160 | % __antidote_bundle_dir foo/bar | subenv ANTIDOTE_HOME 161 | $ANTIDOTE_HOME/foo/bar 162 | % # repo url - friendly name 163 | % __antidote_bundle_dir https://github.com/bar/baz | subenv ANTIDOTE_HOME 164 | $ANTIDOTE_HOME/bar/baz 165 | % # ssh repo - friendly name 166 | % __antidote_bundle_dir git@github.com:foo/qux.git | subenv ANTIDOTE_HOME 167 | $ANTIDOTE_HOME/foo/qux 168 | % 169 | ``` 170 | 171 | ### To URL 172 | 173 | Short repos: 174 | 175 | ```zsh 176 | % __antidote_tourl ohmyzsh/ohmyzsh 177 | https://github.com/ohmyzsh/ohmyzsh 178 | % __antidote_tourl sindresorhus/pure 179 | https://github.com/sindresorhus/pure 180 | % __antidote_tourl foo/bar 181 | https://github.com/foo/bar 182 | % 183 | ``` 184 | 185 | Proper URLs don't change: 186 | 187 | ```zsh 188 | % __antidote_tourl https://github.com/ohmyzsh/ohmyzsh 189 | https://github.com/ohmyzsh/ohmyzsh 190 | % __antidote_tourl http://github.com/ohmyzsh/ohmyzsh 191 | http://github.com/ohmyzsh/ohmyzsh 192 | % __antidote_tourl ssh://github.com/ohmyzsh/ohmyzsh 193 | ssh://github.com/ohmyzsh/ohmyzsh 194 | % __antidote_tourl git://github.com/ohmyzsh/ohmyzsh 195 | git://github.com/ohmyzsh/ohmyzsh 196 | % __antidote_tourl ftp://github.com/ohmyzsh/ohmyzsh 197 | ftp://github.com/ohmyzsh/ohmyzsh 198 | % __antidote_tourl git@github.com:sindresorhus/pure.git 199 | git@github.com:sindresorhus/pure.git 200 | % 201 | ``` 202 | 203 | ## Collect input 204 | 205 | If we \ --file tmp_home/.zsh/.zsh_plugins.txt 209 | % 210 | ``` 211 | 212 | If we \|pipe input it should output that. 213 | 214 | ```zsh 215 | % cat $ZDOTDIR/.zsh_plugins.txt | __antidote_collect_input #=> --file tmp_home/.zsh/.zsh_plugins.txt 216 | % 217 | ``` 218 | 219 | If we pass argument it should output that. 220 | 221 | ```zsh 222 | % __antidote_collect_input 'a\nb\nc\n' 223 | a 224 | b 225 | c 226 | 227 | % 228 | ``` 229 | 230 | ## Teardown 231 | 232 | ```zsh 233 | % t_teardown 234 | % 235 | ``` 236 | -------------------------------------------------------------------------------- /tests/test_real.md: -------------------------------------------------------------------------------- 1 | # antidote tests for real 2 | 3 | ## antidote bundle 4 | 5 | ### Setup 6 | 7 | ```zsh 8 | % TESTDATA=$PWD/tests/testdata/real 9 | % source ./tests/_setup.zsh 10 | % # do it for real! 11 | % t_setup_real 12 | % 13 | ``` 14 | 15 | ### Config 16 | 17 | ```zsh 18 | % zstyle ':antidote:bundle:*' zcompile 'yes' 19 | % 20 | ``` 21 | 22 | ### Bundle 23 | 24 | Clone and generate bundle script 25 | 26 | ```zsh 27 | % antidote bundle <$TESTDATA/.zsh_plugins.txt >$ZDOTDIR/.zsh_plugins.zsh 2>/dev/null 28 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME #=> --file testdata/real/.zsh_plugins.zsh 29 | % 30 | ``` 31 | 32 | Check to see that everything cloned 33 | 34 | ```zsh 35 | % antidote list | subenv ANTIDOTE_HOME #=> --file testdata/real/repo-list.txt 36 | % 37 | ``` 38 | 39 | Test that everything compiled 40 | 41 | ```zsh 42 | % zwcfiles=($(ls $(antidote home)/**/*.zwc(N) | wc -l)) 43 | % test $zwcfiles -gt 100 #=> --exit 0 44 | % 45 | ``` 46 | 47 | Test that everything updated 48 | 49 | ```zsh 50 | % rm -rf -- $(antidote home)/**/*.zwc(N) 51 | % antidote update &>/dev/null 52 | % zwcfiles=($(ls $(antidote home)/**/*.zwc(N) | wc -l)) 53 | % test $zwcfiles -gt 100 #=> --exit 0 54 | % 55 | ``` 56 | 57 | Check to see that branch:br annotations properly changed the cloned branch 58 | 59 | ```zsh 60 | % branched_plugin="$ANTIDOTE_HOME/mattmc3/antidote" 61 | % git -C $branched_plugin branch --show-current 2>/dev/null 62 | pz 63 | % 64 | ``` 65 | 66 | Test that `antidote purge --all` aborts when told "no". 67 | 68 | ```zsh 69 | % function test_exists { [[ -e "$1" ]] } 70 | % zstyle ':antidote:purge:all' answer 'n' 71 | % antidote purge --all #=> --exit 1 72 | % antidote list | subenv ANTIDOTE_HOME #=> --file testdata/real/repo-list.txt 73 | % antidote list | wc -l | awk '{print $1}' 74 | 15 75 | % test_exists $ZDOTDIR/.zsh_plugins.zsh(.N) #=> --exit 0 76 | % test_exists $ZDOTDIR/.zsh_plugins*.bak(.N) #=> --exit 1 77 | % 78 | ``` 79 | 80 | Test that `antidote purge --all` does the work when told "yes". 81 | 82 | ```zsh 83 | % function test_exists { [[ -e "$1" ]] } 84 | % zstyle ':antidote:purge:all' answer 'y' 85 | % antidote purge --all | tail -n 1 #=> --exit 0 86 | Antidote purge complete. Be sure to start a new Zsh session. 87 | % antidote list | wc -l | awk '{print $1}' 88 | 0 89 | % test_exists $ZDOTDIR/.zsh_plugins.zsh(.N) #=> --exit 1 90 | % test_exists $ZDOTDIR/.zsh_plugins*.bak(.N) #=> --exit 0 91 | % 92 | ``` 93 | 94 | ### Teardown 95 | 96 | ```zsh 97 | % zstyle -d ':antidote:purge:all' answer 98 | % t_teardown 99 | % 100 | ``` 101 | 102 | ## CRLF testing 103 | 104 | ### Redo setup 105 | 106 | ```zsh 107 | % TESTDATA=$PWD/tests/testdata/real 108 | % source ./tests/_setup.zsh 109 | % t_setup_real 110 | % 111 | ``` 112 | 113 | Clone and generate bundle script 114 | 115 | ```zsh 116 | % antidote bundle <$TESTDATA/.zsh_plugins.crlf.txt >$ZDOTDIR/.zsh_plugins.zsh 2>/dev/null 117 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 118 | fpath+=( $ANTIDOTE_HOME/rupa/z ) 119 | source $ANTIDOTE_HOME/rupa/z/z.sh 120 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting ) 121 | source $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh 122 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-completions ) 123 | source $ANTIDOTE_HOME/zsh-users/zsh-completions/zsh-completions.plugin.zsh 124 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions ) 125 | source $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh 126 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search ) 127 | source $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh 128 | % 129 | ``` 130 | 131 | Check to see that everything cloned 132 | 133 | ```zsh 134 | % antidote list | subenv ANTIDOTE_HOME 135 | https://github.com/rupa/z $ANTIDOTE_HOME/rupa/z 136 | https://github.com/zsh-users/zsh-autosuggestions $ANTIDOTE_HOME/zsh-users/zsh-autosuggestions 137 | https://github.com/zsh-users/zsh-completions $ANTIDOTE_HOME/zsh-users/zsh-completions 138 | https://github.com/zsh-users/zsh-history-substring-search $ANTIDOTE_HOME/zsh-users/zsh-history-substring-search 139 | https://github.com/zsh-users/zsh-syntax-highlighting $ANTIDOTE_HOME/zsh-users/zsh-syntax-highlighting 140 | % 141 | ``` 142 | 143 | ### Teardown 144 | 145 | ```zsh 146 | % t_teardown 147 | % 148 | ``` 149 | 150 | ## antidote load 151 | 152 | ### Redo setup 153 | 154 | ```zsh 155 | % TESTDATA=$PWD/tests/testdata/real 156 | % source ./tests/_setup.zsh 157 | % t_setup_real 158 | % 159 | ``` 160 | 161 | ### Load 162 | 163 | Load rupa/z 164 | 165 | ```zsh 166 | % zstyle ':antidote:bundle' use-friendly-names on 167 | % echo "rupa/z" > $ZDOTDIR/.zsh_plugins.txt 168 | % antidote load 2>&1 169 | # antidote cloning rupa/z... 170 | % echo $+aliases[z] 171 | 1 172 | % wc -l <$ZDOTDIR/.zsh_plugins.zsh | sed 's/ //g' 173 | 2 174 | % (( ! $+aliases[z] )) || unalias z 175 | % 176 | ``` 177 | 178 | Load re-generates .zsh_plugins.zsh when .zsh_plugins.txt changes 179 | 180 | ```zsh 181 | % compdir=$ANTIDOTE_HOME/zsh-users/zsh-completions/src 182 | % (( $fpath[(Ie)$compdir] )) || echo "completions are not in fpath" 183 | completions are not in fpath 184 | % echo $+aliases[z] 185 | 0 186 | % 187 | ``` 188 | 189 | ...add a new plugin 190 | 191 | ```zsh 192 | % wc -l <$ZDOTDIR/.zsh_plugins.txt | sed 's/ //g' 193 | 1 194 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 195 | fpath+=( $ANTIDOTE_HOME/rupa/z ) 196 | source $ANTIDOTE_HOME/rupa/z/z.sh 197 | % echo "zsh-users/zsh-completions path:src kind:fpath" >> $ZDOTDIR/.zsh_plugins.txt 198 | % # static cache file hasn't changed yet 199 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 200 | fpath+=( $ANTIDOTE_HOME/rupa/z ) 201 | source $ANTIDOTE_HOME/rupa/z/z.sh 202 | % 203 | ``` 204 | 205 | ...now do `antidote load` and show that it actually loaded all plugins 206 | 207 | ```zsh 208 | % antidote load 2>&1 209 | # antidote cloning zsh-users/zsh-completions... 210 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 211 | fpath+=( $ANTIDOTE_HOME/rupa/z ) 212 | source $ANTIDOTE_HOME/rupa/z/z.sh 213 | fpath+=( $ANTIDOTE_HOME/zsh-users/zsh-completions/src ) 214 | % echo $+aliases[z] 215 | 1 216 | % (( $fpath[(Ie)$compdir] )) && echo "completions are in fpath" 217 | completions are in fpath 218 | % 219 | % wc -l <$ZDOTDIR/.zsh_plugins.zsh | sed 's/ //g' 220 | 3 221 | % 222 | ``` 223 | 224 | ### Teardown 225 | 226 | ```zsh 227 | % t_teardown 228 | % 229 | ``` 230 | -------------------------------------------------------------------------------- /man/man1/antidote.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pandoc 2 | .\" 3 | .TH "antidote" "1" "" "" "Antidote Manual" 4 | .SH NAME 5 | \f[B]antidote\f[R] \- the cure to slow zsh plugin management 6 | .SH SYNOPSIS 7 | .PP 8 | antidote [\-v | \[en]version] [\-h | \[en]help] [ \&...] 9 | .SH DESCRIPTION 10 | \f[B]antidote\f[R] is a Zsh plugin manager made from the ground up 11 | thinking about performance. 12 | .PP 13 | It is fast because it can do things concurrently, and generates an 14 | ultra\-fast static plugin file that you can easily load from your Zsh 15 | config. 16 | .PP 17 | It is written natively in Zsh, is well tested, and picks up where 18 | Antigen and Antibody left off. 19 | .SH OPTIONS 20 | .TP 21 | \-h, \-\-help 22 | Show context\-sensitive help for antidote. 23 | .TP 24 | \-v, \-\-version 25 | Show currently installed antidote version. 26 | .SH COMMANDS 27 | .TP 28 | \f[CR]help\f[R] 29 | Show documentation 30 | .TP 31 | \f[CR]load\f[R] 32 | Statically source all bundles from the plugins file 33 | .TP 34 | \f[CR]bundle\f[R] 35 | Clone bundle(s) and generate the static load script 36 | .TP 37 | \f[CR]install\f[R] 38 | Clone a new bundle and add it to your plugins file 39 | .TP 40 | \f[CR]update\f[R] 41 | Update antidote and its cloned bundles 42 | .TP 43 | \f[CR]purge\f[R] 44 | Remove a cloned bundle 45 | .TP 46 | \f[CR]home\f[R] 47 | Print where antidote is cloning bundles 48 | .TP 49 | \f[CR]list\f[R] 50 | List cloned bundles 51 | .TP 52 | \f[CR]path\f[R] 53 | Print the path of a cloned bundle 54 | .TP 55 | \f[CR]init\f[R] 56 | Initialize the shell for dynamic bundles 57 | .SH EXAMPLES 58 | .SS A Simple Config 59 | Create a \f[I].zsh_plugins.txt\f[R] file with a list of the plugins you 60 | want: 61 | .PP 62 | \ \ \ # ${ZDOTDIR:\-$HOME}/.zsh_plugins.txt 63 | .PD 0 64 | .P 65 | .PD 66 | \ \ \ zsh\-users/zsh\-syntax\-highlighting 67 | .PD 0 68 | .P 69 | .PD 70 | \ \ \ zsh\-users/zsh\-history\-substring\-search 71 | .PD 0 72 | .P 73 | .PD 74 | \ \ \ zsh\-users/zsh\-autosuggestions 75 | .PP 76 | Now, simply load your newly created static plugins file in your 77 | \f[I].zshrc\f[R]. 78 | .PP 79 | \ \ \ # ${ZDOTDIR:\-$HOME}/.zshrc 80 | .PD 0 81 | .P 82 | .PD 83 | \ \ \ source /path/to/antidote/antidote.zsh 84 | .PD 0 85 | .P 86 | .PD 87 | \ \ \ antidote load 88 | .SS A More Advanced Config 89 | Your \f[I].zsh_plugins.txt\f[R] file supports annotations. 90 | Annotations tell antidote how to do things like load plugins from 91 | alternate paths. 92 | This lets you use plugins from popular frameworks like Oh\-My\-Zsh: 93 | .PP 94 | \ \ \ # ${ZDOTDIR:\-$HOME}/.zsh_plugins.txt 95 | .PD 0 96 | .P 97 | .PD 98 | \ \ \ ohmyzsh/ohmyzsh path:lib 99 | .PD 0 100 | .P 101 | .PD 102 | \ \ \ ohmyzsh/ohmyzsh path:plugins/git 103 | .PD 0 104 | .P 105 | .PD 106 | \ \ \ ohmyzsh/ohmyzsh path:plugins/magic\-enter 107 | .PD 0 108 | .P 109 | .PD 110 | \ \ \ etc\&... 111 | .SS Dynamic Bundling 112 | Users familiar with legacy plugin managers like Antigen might prefer to 113 | use dynamic bundling. 114 | With dynamic bundling you sacrifice some performance to avoid having 115 | separate plugin files. 116 | To use dynamic bundling, we need to change how \f[B]antidote bundle\f[R] 117 | handles your plugins. 118 | We do this by sourcing the output from \f[B]antidote init\f[R]. 119 | .PP 120 | An example config might look like this: 121 | .PP 122 | \ \ \ source /path/to/antidote/antidote.zsh 123 | .PD 0 124 | .P 125 | .PD 126 | \ \ \ source <(antidote init) 127 | .PD 0 128 | .P 129 | .PD 130 | \ \ \ antidote bundle zsh\-users/zsh\-autosuggestions 131 | .PD 0 132 | .P 133 | .PD 134 | \ \ \ antidote bundle ohmyzsh/ohmyzsh path:lib 135 | .PD 0 136 | .P 137 | .PD 138 | \ \ \ antidote bundle ohmyzsh/ohmyzsh path:plugins/git 139 | .PP 140 | Instead of calling \f[B]antidote bundle\f[R] over and over, you might 141 | prefer to load bundles with a HEREDOC. 142 | .PP 143 | \ \ \ source /path/to/antidote/antidote.zsh 144 | .PD 0 145 | .P 146 | .PD 147 | \ \ \ source <(antidote init) 148 | .PD 0 149 | .P 150 | .PD 151 | \ \ \ antidote bundle <] [ ...] 30 | 31 | flags: 32 | -h, --help Show context-sensitive help 33 | -v, --version Show application version 34 | 35 | commands: 36 | help Show documentation 37 | load Statically source all bundles from the plugins file 38 | bundle Clone bundle(s) and generate the static load script 39 | install Clone a new bundle and add it to your plugins file 40 | update Update antidote and its cloned bundles 41 | purge Remove a cloned bundle 42 | home Print where antidote is cloning bundles 43 | list List cloned bundles 44 | path Print the path of a cloned bundle 45 | init Initialize the shell for dynamic bundles 46 | % 47 | ``` 48 | 49 | ## Bundling 50 | 51 | Bundle the foo/bar repo using old antibody style directories: 52 | 53 | ```zsh 54 | % zstyle ':antidote:bundle' use-friendly-names off 55 | % antidote bundle foo/bar 56 | # antidote cloning foo/bar... 57 | fpath+=( $HOME/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar ) 58 | source $HOME/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar/bar.plugin.zsh 59 | % 60 | ``` 61 | 62 | Use new-style directory naming: 63 | 64 | ```zsh 65 | % zstyle ':antidote:bundle' use-friendly-names on 66 | % 67 | ``` 68 | 69 | Bundle a repo at https://github.com/foo/bar 70 | 71 | ```zsh 72 | % antidote bundle foo/bar 73 | fpath+=( $HOME/.cache/antidote/foo/bar ) 74 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 75 | % 76 | ``` 77 | 78 | Bundle a repo at git@bitbucket.org:foo/bar 79 | 80 | ```zsh 81 | % antidote bundle git@bitbucket.org:foo/bar 82 | fpath+=( $HOME/.cache/antidote/foo/bar ) 83 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 84 | % 85 | ``` 86 | 87 | Bundle a specific branch of a repo with `branch:`. 88 | 89 | ```zsh 90 | % antidote bundle foo/bar branch:dev 91 | fpath+=( $HOME/.cache/antidote/foo/bar ) 92 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 93 | % 94 | ``` 95 | 96 | ### Annotations: kind 97 | 98 | Bundles support a `kind:` annotation. The default is `kind:zsh`. 99 | 100 | ```zsh 101 | % antidote bundle foo/bar kind:zsh 102 | fpath+=( $HOME/.cache/antidote/foo/bar ) 103 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 104 | % 105 | ``` 106 | 107 | Bundle foo/bar with `kind:path` to add it to your `$PATH`. 108 | 109 | ```zsh 110 | % antidote bundle foo/bar kind:path 111 | export PATH="$HOME/.cache/antidote/foo/bar:$PATH" 112 | % 113 | ``` 114 | 115 | Bundle foo/bar with `kind:fpath` to add it to your `$fpath`. 116 | 117 | ```zsh 118 | % antidote bundle foo/bar kind:fpath 119 | fpath+=( $HOME/.cache/antidote/foo/bar ) 120 | % 121 | ``` 122 | 123 | Bundle foo/bar with `kind:clone` to just clone the repo, but do nothing to load it. 124 | 125 | ```zsh 126 | % antidote bundle foo/bar kind:clone 127 | % 128 | ``` 129 | 130 | Autoload a path within foo/bar with the `kind:autoload` annotation. 131 | 132 | ```zsh 133 | % antidote bundle foo/baz kind:autoload path:functions 134 | fpath+=( $HOME/.cache/antidote/foo/baz/functions ) 135 | builtin autoload -Uz $fpath[-1]/*(N.:t) 136 | % 137 | ``` 138 | 139 | Defer loading the foo/bar bundle with the `kind:defer` annotation. 140 | 141 | ```zsh 142 | % antidote bundle foo/baz kind:defer 143 | if ! (( $+functions[zsh-defer] )); then 144 | fpath+=( $HOME/.cache/antidote/getantidote/zsh-defer ) 145 | source $HOME/.cache/antidote/getantidote/zsh-defer/zsh-defer.plugin.zsh 146 | fi 147 | fpath+=( $HOME/.cache/antidote/foo/baz ) 148 | zsh-defer source $HOME/.cache/antidote/foo/baz/baz.plugin.zsh 149 | % 150 | ``` 151 | 152 | ### Annotations: path 153 | 154 | Use the `path:` annotation to load subplugins. 155 | 156 | ```zsh 157 | % antidote bundle ohmy/ohmy path:plugins/docker 158 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/plugins/docker ) 159 | source $HOME/.cache/antidote/ohmy/ohmy/plugins/docker/docker.plugin.zsh 160 | % 161 | ``` 162 | 163 | Use `path:` to load a whole directory full of files. 164 | 165 | ```zsh 166 | % antidote bundle ohmy/ohmy path:lib 167 | fpath+=( $HOME/.cache/antidote/ohmy/ohmy/lib ) 168 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib1.zsh 169 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib2.zsh 170 | source $HOME/.cache/antidote/ohmy/ohmy/lib/lib3.zsh 171 | % 172 | ``` 173 | 174 | Use `path:` to load a specific file. 175 | 176 | ```zsh 177 | % antidote bundle ohmy/ohmy path:custom/themes/pretty.zsh-theme 178 | source $HOME/.cache/antidote/ohmy/ohmy/custom/themes/pretty.zsh-theme 179 | % 180 | ``` 181 | 182 | ### Annotations: conditional 183 | 184 | Use a existing boolean function to wrap a bundle in `if` logic: 185 | 186 | ```zsh 187 | % is-macos() { [[ "$OSTYPE" == "darwin"* ]]; } 188 | % antidote bundle foo/bar conditional:is-macos 189 | if is-macos; then 190 | fpath+=( $HOME/.cache/antidote/foo/bar ) 191 | source $HOME/.cache/antidote/foo/bar/bar.plugin.zsh 192 | fi 193 | % 194 | ``` 195 | 196 | ## Dynamic bundling 197 | 198 | If you run `source <(antidote init)`, antidote will emit a wrapper so that you can 199 | dynamically bundle. 200 | 201 | ```zsh 202 | % antidote init 203 | #!/usr/bin/env zsh 204 | function antidote { 205 | case "$1" in 206 | bundle) 207 | source <( antidote-main $@ ) || antidote-main $@ 208 | ;; 209 | *) 210 | antidote-main $@ 211 | ;; 212 | esac 213 | } 214 | % 215 | ``` 216 | 217 | ## Home 218 | 219 | Show where antidote stores its bundles: 220 | 221 | ```zsh 222 | % antidote home | subenv HOME 223 | $HOME/.cache/antidote 224 | % 225 | ``` 226 | 227 | ## List bundles 228 | 229 | List directories: 230 | 231 | ```zsh 232 | % antidote list --dirs | subenv HOME 233 | $HOME/.cache/antidote/foo/bar 234 | $HOME/.cache/antidote/foo/baz 235 | $HOME/.cache/antidote/foo/qux 236 | $HOME/.cache/antidote/getantidote/zsh-defer 237 | $HOME/.cache/antidote/ohmy/ohmy 238 | % 239 | ``` 240 | 241 | List repo URLs: 242 | 243 | ```zsh 244 | % antidote list --url 245 | git@github.com:foo/qux 246 | https://github.com/foo/bar 247 | https://github.com/foo/baz 248 | https://github.com/getantidote/zsh-defer 249 | https://github.com/ohmy/ohmy 250 | % 251 | ``` 252 | 253 | List short repos: 254 | 255 | ```zsh 256 | % antidote list --short 257 | foo/bar 258 | foo/baz 259 | getantidote/zsh-defer 260 | git@github.com:foo/qux 261 | ohmy/ohmy 262 | % 263 | ``` 264 | 265 | ## Bundle paths 266 | 267 | Show the path to a bundle: 268 | 269 | ```zsh 270 | % ZSH=$(antidote path ohmy/ohmy) 271 | % echo $ZSH | subenv HOME 272 | $HOME/.cache/antidote/ohmy/ohmy 273 | % 274 | ``` 275 | 276 | ## Update bundles 277 | 278 | ```zsh 279 | % antidote update 280 | Updating bundles... 281 | antidote: checking for updates: https://github.com/foo/bar 282 | antidote: checking for updates: https://github.com/foo/baz 283 | antidote: checking for updates: git@github.com:foo/qux 284 | antidote: checking for updates: https://github.com/getantidote/zsh-defer 285 | antidote: checking for updates: https://github.com/ohmy/ohmy 286 | Waiting for bundle updates to complete... 287 | 288 | Bundle updates complete. 289 | 290 | Updating antidote... 291 | antidote self-update complete. 292 | 293 | antidote version 1.9.7 294 | % 295 | ``` 296 | 297 | ## Teardown 298 | 299 | ```zsh 300 | % t_teardown 301 | % 302 | ``` 303 | -------------------------------------------------------------------------------- /functions/antidote-script: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Generate the Zsh script to load a plugin. 4 | # 5 | # usage: antidote script [-h|--help] [-k|--kind ] [-p|--path ] 6 | # [-c|--conditional ] [-b|--branch ] 7 | # [--pre ] [--post ] 8 | # [-a|--autoload ] 9 | # : zsh,path,fpath,defer,clone,autoload 10 | # : Relative path from the bundle root 11 | # : The git branch 12 | # : A bundle can be a directory, a zsh script, or a git repo 13 | # 14 | 15 | ### Generate the Zsh script to load a plugin. 16 | #function antidote-script { 17 | emulate -L zsh; setopt local_options $_adote_funcopts 18 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 19 | local REPLY= 20 | 21 | local o_help o_kind o_path o_branch o_cond o_autoload o_pre o_post o_fpath_rule 22 | zparseopts $_adote_zparopt_flags -- \ 23 | h=o_help -help=h \ 24 | a:=o_autoload -autoload:=a \ 25 | b:=o_branch -branch:=b \ 26 | k:=o_kind -kind:=k \ 27 | p:=o_path -path:=p \ 28 | -pre:=o_pre \ 29 | -post:=o_post \ 30 | -fpath-rule:=o_fpath_rule \ 31 | c:=o_cond -conditional:=c || 32 | return 1 33 | 34 | # set defaults 35 | (( $#o_kind )) || o_kind=(--kind zsh) 36 | if ! (( $#o_fpath_rule )); then 37 | zstyle -a ':antidote:fpath' rule 'o_fpath_rule' || o_fpath_rule=(append) 38 | fi 39 | 40 | # strip '=' or ':' from beginning of arg values 41 | local re='^[=:]?(.+)$' 42 | [[ $o_kind[-1] =~ $re ]] && o_kind[-1]=$match 43 | [[ $o_autoload[-1] =~ $re ]] && o_autoload[-1]=$match 44 | [[ $o_path[-1] =~ $re ]] && o_path[-1]=$match 45 | [[ $o_cond[-1] =~ $re ]] && o_cond[-1]=$match 46 | [[ $o_branch[-1] =~ $re ]] && o_branch[-1]=$match 47 | [[ $o_pre[-1] =~ $re ]] && o_pre[-1]=$match 48 | [[ $o_post[-1] =~ $re ]] && o_post[-1]=$match 49 | [[ $o_fpath_rule[-1] =~ $re ]] && o_fpath_rule[-1]=$match 50 | 51 | local supported_kind_vals=(autoload clone defer fpath path zsh) 52 | if (( $#o_kind )) && ! (( $supported_kind_vals[(Ie)$o_kind[-1]] )); then 53 | print -ru2 "antidote: error: unexpected kind value: '$o_kind[-1]'" && return 1 54 | fi 55 | 56 | # If no fpath_rule is set, use the zstyle 57 | if ! (( $#o_fpath_rule )); then 58 | local zstyle_fpath_rule 59 | zstyle -s ':antidote:fpath' rule 'zstyle_fpath_rule' 60 | [[ -z "$zstyle_fpath_rule" ]] || o_fpath_rule=($zstyle_fpath_rule) 61 | fi 62 | 63 | local supported_fpath_rules=(append prepend) 64 | if ! (( $supported_fpath_rules[(Ie)$o_fpath_rule[-1]] )); then 65 | print -ru2 "antidote: error: unexpected fpath rule: '$o_fpath_rule[-1]'" && return 1 66 | fi 67 | 68 | local bundle=$1 69 | if [[ -z "$bundle" ]]; then 70 | print -ru2 "antidote: error: bundle argument expected" && return 1 71 | fi 72 | local bundle_name=$(__antidote_bundle_name $bundle) 73 | 74 | # replace ~/ with $HOME/ 75 | if [[ "$bundle" == '~/'* ]]; then 76 | bundle=$HOME/${bundle#'~/'*} 77 | fi 78 | 79 | # set the path to the bundle (repo or local) 80 | local bundle_path 81 | [[ -e "$bundle" ]] && bundle_path=$bundle || bundle_path=$(__antidote_bundle_dir $bundle) 82 | 83 | # handle cloning repo bundles 84 | local bundle_type 85 | bundle_type="$(__antidote_bundle_type $bundle)" 86 | if [[ "$bundle_type" == (repo|url|sshurl) ]] && [[ ! -e "$bundle_path" ]]; then 87 | local giturl=$(__antidote_tourl $bundle) 88 | print -ru2 "# antidote cloning $bundle_name..." 89 | git clone --quiet --depth 1 --recurse-submodules --shallow-submodules $o_branch $giturl $bundle_path 90 | [[ $? -eq 0 ]] || return 1 91 | fi 92 | 93 | # if we only needed to clone the bundle, compile and we're done 94 | if [[ "$o_kind[-1]" == "clone" ]]; then 95 | if zstyle -t ":antidote:bundle:$bundle" zcompile; then 96 | __antidote_bundle_zcompile $bundle_path 97 | fi 98 | return 99 | fi 100 | 101 | # add path to bundle 102 | [[ -n "$o_path[-1]" ]] && bundle_path+="/$o_path[-1]" 103 | 104 | # handle defer pre-reqs first 105 | local dopts zsh_defer='zsh-defer' 106 | zstyle -s ":antidote:bundle:${bundle}" defer-options 'dopts' 107 | [[ -n "$dopts" ]] && zsh_defer="zsh-defer $dopts" 108 | 109 | # generate the script 110 | local -a script=() 111 | 112 | # add pre-load function 113 | (( $#o_pre )) && script+=("$o_pre[-1]") 114 | 115 | # handle defers 116 | local source_cmd="source" 117 | local zsh_defer_bundle 118 | zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \ 119 | || zsh_defer_bundle='romkatv/zsh-defer' 120 | if [[ "$o_kind[-1]" == "defer" ]]; then 121 | source_cmd="${zsh_defer} source" 122 | script+=( 123 | 'if ! (( $+functions[zsh-defer] )); then' 124 | "$(antidote-script $zsh_defer_bundle | __antidote_indent)" 125 | 'fi' 126 | ) 127 | fi 128 | 129 | # Let's make the path a little nicer to deal with 130 | local print_bundle_path="$(__antidote_print_path "$bundle_path")" 131 | 132 | # handle autoloading before sourcing 133 | if (( $#o_autoload )); then 134 | if [[ "$o_fpath_rule[-1]" == prepend ]]; then 135 | script+=("fpath=( ${print_bundle_path}/${o_autoload[-1]} \$fpath )") 136 | script+=("builtin autoload -Uz \$fpath[1]/*(N.:t)") 137 | else 138 | script+=("fpath+=( ${print_bundle_path}/${o_autoload[-1]} )") 139 | script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)") 140 | fi 141 | fi 142 | 143 | # generate load script 144 | bundle_type="$(__antidote_bundle_type $bundle_path)" 145 | local fpath_script 146 | if [[ "$o_fpath_rule[-1]" == prepend ]]; then 147 | fpath_script="fpath=( $print_bundle_path \$fpath )" 148 | else 149 | fpath_script="fpath+=( $print_bundle_path )" 150 | fi 151 | 152 | if [[ "$o_kind[-1]" == fpath ]]; then 153 | # fpath 154 | script+="$fpath_script" 155 | elif [[ "$o_kind[-1]" == path ]]; then 156 | # path 157 | script+="export PATH=\"$print_bundle_path:\$PATH\"" 158 | elif [[ "$o_kind[-1]" == autoload ]]; then 159 | # autoload 160 | script+=("$fpath_script") 161 | if [[ "$o_fpath_rule[-1]" == prepend ]]; then 162 | script+=("builtin autoload -Uz \$fpath[1]/*(N.:t)") 163 | else 164 | script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)") 165 | fi 166 | else 167 | if zstyle -t ":antidote:bundle:$bundle" zcompile; then 168 | __antidote_bundle_zcompile $bundle_path 169 | fi 170 | if [[ $bundle_type == file ]]; then 171 | script+="$source_cmd $print_bundle_path" 172 | else 173 | # directory/default 174 | local initfile initfiles 175 | initfiles=(${(@f)$(__antidote_initfiles $bundle_path)}) 176 | # if no init file was found, assume the default 177 | if [[ $#initfiles -eq 0 ]]; then 178 | if (( $#o_path )); then 179 | initfiles=($bundle_path/${bundle_path:t}.plugin.zsh) 180 | else 181 | initfiles=($bundle_path/${bundle_name:t}.plugin.zsh) 182 | fi 183 | fi 184 | script+="$fpath_script" 185 | local print_initfile 186 | for initfile in $initfiles; do 187 | print_initfile="$(__antidote_print_path "$initfile")" 188 | script+="$source_cmd $print_initfile" 189 | done 190 | fi 191 | fi 192 | 193 | # add post-load function 194 | if (( $#o_post )); then 195 | if [[ "$o_kind[-1]" == "defer" ]]; then 196 | script+=("${zsh_defer} $o_post[-1]") 197 | else 198 | script+=("$o_post[-1]") 199 | fi 200 | fi 201 | 202 | # mark bundle as loaded 203 | # script+="zstyle ':antidote:bundle:${bundle_name}' loaded yes" 204 | 205 | # wrap conditional 206 | if [[ -n "$o_cond[-1]" ]]; then 207 | print "if $o_cond[-1]; then" 208 | printf " %s\n" $script 209 | print "fi" 210 | else 211 | printf "%s\n" $script 212 | fi 213 | #} 214 | --------------------------------------------------------------------------------