├── .bumpversion.cfg ├── .editorconfig ├── .github ├── CODE_OF_CONDUCT.md └── workflows │ ├── test-zsh-5.4.2.yml │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md ├── antidote ├── antidote.zsh ├── functions ├── __antidote_bulk_clone ├── __antidote_bundle_dir ├── __antidote_bundle_name ├── __antidote_bundle_type ├── __antidote_bundle_zcompile ├── __antidote_collect_input ├── __antidote_del ├── __antidote_get_cachedir ├── __antidote_indent ├── __antidote_initfiles ├── __antidote_load_prep ├── __antidote_mktemp ├── __antidote_parse_bundles ├── __antidote_parser ├── __antidote_print_path ├── __antidote_setup ├── __antidote_tourl ├── __antidote_usage ├── __antidote_version ├── _antidote ├── antidote ├── antidote-bundle ├── antidote-help ├── antidote-home ├── antidote-init ├── antidote-install ├── antidote-list ├── antidote-load ├── antidote-main ├── antidote-path ├── antidote-purge ├── antidote-script └── antidote-update ├── makefile ├── man ├── antidote-bundle.md ├── antidote-help.md ├── antidote-home.md ├── antidote-init.md ├── antidote-install.md ├── antidote-list.md ├── antidote-load.md ├── antidote-path.md ├── antidote-purge.md ├── antidote-update.md ├── antidote.md ├── footer.md └── man1 │ ├── antidote-bundle.1 │ ├── antidote-help.1 │ ├── antidote-home.1 │ ├── antidote-init.1 │ ├── antidote-install.1 │ ├── antidote-list.1 │ ├── antidote-load.1 │ ├── antidote-path.1 │ ├── antidote-purge.1 │ ├── antidote-update.1 │ └── antidote.1 ├── tests ├── README.md ├── __init__.zsh ├── fakegitsite.com │ └── fakeuser │ │ └── fakerepo │ │ ├── .mockgit │ │ └── config │ │ │ └── remote.origin.url │ │ ├── fakerepo.plugin.zsh │ │ └── functions │ │ ├── _fakerepo │ │ └── fakerepo ├── functions │ ├── aarr_val │ ├── mockgit │ ├── normalize_aarr │ ├── print_aarr │ ├── subenv │ ├── t_reset │ ├── t_setup │ ├── t_setup_real │ ├── t_teardown │ └── t_unload_antidote ├── test_alt_zsh_defer_bundle.md ├── test_antidote.md ├── test_antidote_core.md ├── test_bundle_helpers.md ├── test_cmd_bundle.md ├── test_cmd_help.md ├── test_cmd_home.md ├── test_cmd_init.md ├── test_cmd_install.md ├── test_cmd_list.md ├── test_cmd_load.md ├── test_cmd_main.md ├── test_cmd_path.md ├── test_cmd_purge.md ├── test_cmd_script.md ├── test_cmd_update.md ├── test_fpath_rules.md ├── test_helpers.md ├── test_mockgit.md ├── test_parser.md ├── test_paths_with_spaces.md ├── test_real.md ├── test_setopts_special.md ├── test_zcompile_bundle.md ├── test_zcompile_static.md ├── test_zsetopts.md ├── testdata │ ├── .zplugins_fake_load.zsh │ ├── .zplugins_fake_zcompile_static.zsh │ ├── .zsh_plugins.zsh │ ├── .zsh_plugins_empty.txt │ ├── .zsh_plugins_multi_defer.zsh │ ├── .zsh_plugins_no_defer.zsh │ ├── .zsh_plugins_purged.txt │ ├── .zsh_plugins_repos.txt │ ├── antibody │ │ ├── script-foobar.zsh │ │ └── script-fooqux.zsh │ ├── real │ │ ├── .zsh_plugins.crlf.txt │ │ ├── .zsh_plugins.txt │ │ ├── .zsh_plugins.zsh │ │ └── repo-list.txt │ ├── script-foobar.zsh │ └── script-fooqux.zsh └── tmp_home │ ├── .cache │ ├── 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 │ │ │ ├── baz.plugin.zsh │ │ │ └── functions │ │ │ │ ├── _baz │ │ │ │ └── baz │ │ ├── https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer │ │ │ ├── .mockgit │ │ │ │ └── .gitkeep │ │ │ └── zsh-defer.plugin.zsh │ │ └── https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy │ │ │ ├── .mockgit │ │ │ └── .gitkeep │ │ │ ├── custom │ │ │ └── themes │ │ │ │ ├── pretty.zsh-theme │ │ │ │ └── ugly.zsh-theme │ │ │ ├── lib │ │ │ ├── lib1.zsh │ │ │ ├── lib2.zsh │ │ │ └── lib3.zsh │ │ │ ├── oh-my.sh │ │ │ ├── plugins │ │ │ ├── docker │ │ │ │ ├── _docker │ │ │ │ └── docker.plugin.zsh │ │ │ ├── extract │ │ │ │ └── extract.plugin.zsh │ │ │ ├── macos │ │ │ │ ├── functions │ │ │ │ │ └── macos_func │ │ │ │ └── macos.plugin.zsh │ │ │ └── magic-enter │ │ │ │ └── magic-enter.plugin.zsh │ │ │ └── themes │ │ │ └── pretty.zsh-theme │ └── antidote │ │ ├── foo │ │ ├── bar │ │ │ ├── .mockgit │ │ │ │ └── config │ │ │ │ │ └── remote.origin.url │ │ │ └── bar.plugin.zsh │ │ ├── baz │ │ │ ├── .mockgit │ │ │ │ └── config │ │ │ │ │ └── remote.origin.url │ │ │ ├── baz.plugin.zsh │ │ │ └── functions │ │ │ │ ├── _baz │ │ │ │ └── baz │ │ └── qux │ │ │ ├── .mockgit │ │ │ └── config │ │ │ │ └── remote.origin.url │ │ │ └── qux.plugin.zsh │ │ ├── getantidote │ │ └── zsh-defer │ │ │ ├── .mockgit │ │ │ └── config │ │ │ │ └── remote.origin.url │ │ │ └── zsh-defer.plugin.zsh │ │ └── ohmy │ │ └── ohmy │ │ ├── .mockgit │ │ └── config │ │ │ └── remote.origin.url │ │ ├── custom │ │ └── themes │ │ │ ├── pretty.zsh-theme │ │ │ └── ugly.zsh-theme │ │ ├── lib │ │ ├── lib1.zsh │ │ ├── lib2.zsh │ │ └── lib3.zsh │ │ ├── oh-my.sh │ │ ├── plugins │ │ ├── docker │ │ │ ├── _docker │ │ │ └── docker.plugin.zsh │ │ ├── extract │ │ │ └── extract.plugin.zsh │ │ ├── macos │ │ │ ├── functions │ │ │ │ └── macos_func │ │ │ └── macos.plugin.zsh │ │ └── magic-enter │ │ │ └── magic-enter.plugin.zsh │ │ └── themes │ │ └── pretty.zsh-theme │ └── .zsh │ ├── .zplugins_fake_load │ ├── .zsh_plugins.txt │ ├── aliases.zsh │ ├── custom │ ├── lib │ │ ├── lib1.zsh │ │ └── lib2.zsh │ └── plugins │ │ ├── grizwold │ │ └── grizwold.plugin.zsh │ │ ├── myplugin │ │ └── myplugin.plugin.zsh │ │ └── mytheme │ │ └── mytheme.zsh-theme │ └── functions │ └── myfunc └── tools ├── buildman ├── bumpver ├── run-clitests └── sloc /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.9.10 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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/workflows/test-zsh-5.4.2.yml: -------------------------------------------------------------------------------- 1 | name: test-zsh-5.4.2 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: actions/checkout@v3 14 | with: 15 | repository: "aureliojargas/clitest" 16 | path: bin/clitest 17 | - run: | 18 | sudo apt update 19 | sudo apt install -y wget build-essential libncursesw5-dev 20 | wget https://sourceforge.net/projects/zsh/files/zsh/5.4.2/zsh-5.4.2.tar.xz 21 | tar -xf zsh-5.4.2.tar.xz 22 | cd zsh-5.4.2 23 | ./configure --with-tcsetpgrp 24 | make 25 | sudo make install 26 | - run: | 27 | which zsh 28 | zsh --version 29 | name: Verify Zsh Installation 30 | - run: | 31 | export PATH=$GITHUB_WORKSPACE/bin/clitest:$PATH 32 | export ZSH_BINARY=/usr/local/bin/zsh 33 | make test 34 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # antidote 2 | 3 | [![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg)](/LICENSE) 4 | ![version](https://img.shields.io/badge/version-v1.9.10-df5e88) 5 | 6 | 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | # Replace ~ and $HOME with \$HOME 16 | bundle=${bundle/#\~\//\$HOME/} 17 | bundle=${bundle/#$HOME/\$HOME} 18 | print -r -- "$bundle" 19 | fi 20 | #} 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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 | -------------------------------------------------------------------------------- /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 | local tmpdir 24 | if [[ -n "$TMPDIR" && (( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp )) ]]; then 25 | tmpdir="${TMPDIR%/}" 26 | else 27 | tmpdir="/tmp" 28 | fi 29 | 30 | for p in $@; do 31 | p="${p:a}" 32 | if [[ "$p" != ${HOME}/* ]] && [[ "$p" != ${tmpdir}/* ]]; then 33 | print -ru2 -- "antidote: Blocked attempt to rm path: '$p'." 34 | return 1 35 | fi 36 | done 37 | 38 | command rm ${rmflags[@]} -- "$@" 39 | #} 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /functions/__antidote_mktemp: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Create a cross-platform temporary directory/file for antidote. 4 | # 5 | # usage: __antidote_mktemp [-d] [-f suffix] 6 | # -d Create a directory rather than a file 7 | # -s Use this for the temp file/dir 8 | # 9 | # Returns the path of created temp directory/file. 10 | # 11 | #function __antidote_mktemp { 12 | emulate -L zsh; setopt local_options $_adote_funcopts 13 | 14 | local -a o_dir o_suffix 15 | zparseopts $_adote_zparopt_flags -- d=o_dir s:=o_suffix 16 | 17 | # Set the appropriate temp directory (cargo cult code from p10k) 18 | local tmpbase 19 | if [[ -n "$TMPDIR" && (( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp )) ]]; then 20 | tmpbase="${TMPDIR%/}" 21 | else 22 | tmpbase="/tmp" 23 | fi 24 | 25 | # Create the pattern with PID 26 | local pattern="antidote.$$" 27 | 28 | # Add suffix if provided with -s 29 | if (( $#o_suffix )) && [[ -n "${o_suffix[-1]}" ]]; then 30 | pattern="${pattern}.${o_suffix[-1]}" 31 | fi 32 | 33 | # Add random chars 34 | pattern="${pattern}.XXXXXXXXXX" 35 | 36 | # Create temp directory or file 37 | if (( $#o_dir )); then 38 | command mktemp -d "${tmpbase}/${pattern}" 39 | else 40 | command mktemp "${tmpbase}/${pattern}" 41 | fi 42 | #} 43 | -------------------------------------------------------------------------------- /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 | 7 | # Declare vars 8 | local bundle_str bundle_repr collected_input err lineno=0 skip_load_defer=0 9 | local key val 10 | local -a bundles 11 | local -A bundle 12 | 13 | # Get piped/passed bundles 14 | collected_input="$(__antidote_collect_input "$@")" 15 | if [[ -n "$collected_input" ]]; then 16 | bundles=( "${(@f)collected_input}" ) 17 | else 18 | bundles=() 19 | fi 20 | if ! (( $#bundles )) ; then 21 | print -ru2 -- "antidote: error: bundle argument expected" 22 | return 1 23 | fi 24 | 25 | # Loop through bundles 26 | for bundle_str in $bundles; do 27 | (( lineno += 1 )) 28 | 29 | # Parse the bundle. 30 | bundle_repr=$(__antidote_parser "$bundle_str"); err=$? 31 | if [[ -z "$bundle_repr" ]]; then 32 | continue 33 | elif [[ "$err" -ne 0 ]]; then 34 | print -ru2 -- "antidote: Bundle parser error on line ${lineno}: '$bundle_str'" 35 | return 1 36 | fi 37 | 38 | # Turn the typeset repr into the bundle assoc_arr 39 | eval "$bundle_repr" 40 | 41 | # move flags to front and call antidote-script 42 | print -rn -- "antidote-script" 43 | for key in ${(ok)bundle}; do 44 | [[ "$key" != name ]] && [[ "$key" != '_'* ]] || continue 45 | val="${bundle[$key]}" 46 | if [[ "$val" == "${(q)val}" ]]; then 47 | printf ' --%s %s' $key $val 48 | else 49 | printf ' --%s %s' $key ${(qqq)val} 50 | fi 51 | done 52 | 53 | # Add flag for first defer 54 | if [[ "${bundle[kind]}" == "defer" ]]; then 55 | if [[ "$skip_load_defer" -eq 0 ]]; then 56 | skip_load_defer=1 57 | else 58 | printf ' --skip-load-defer' 59 | fi 60 | fi 61 | 62 | # Escape leading '$' variables 63 | if [[ "${bundle[name]}" == '$'* ]]; then 64 | printf ' \$%s\n' "${bundle[name]#\$}" 65 | else 66 | printf ' %s\n' "${bundle[name]}" 67 | fi 68 | done 69 | #} 70 | -------------------------------------------------------------------------------- /functions/__antidote_parser: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ### Parse antidote's bundle DSL to an associative array. 4 | # Example: 5 | # __antidote_parser 'foo/bar path:plugins/baz kind:fpath pre:myprecmd # comment' 6 | # typeset -A bundle=( [kind]=fpath [path]=plugins/baz [pre]=myprecmd [name]=foo/bar ) 7 | # 8 | # Notes: 9 | # bundle_str : antidote DSL syntax 10 | # bundle : assoc array representation 11 | # bundle_repr : Zsh serialization of the bundle assoc arrary 12 | # 13 | # Metadata: 14 | # _repodir : The clone destination dir 15 | # _type : The type of bundle (url, repo, path, ?) 16 | # _repo : The user/repo short form of the URL 17 | # _url : The git repo URL 18 | # 19 | #function __antidote_parser { 20 | emulate -L zsh; setopt local_options $_adote_funcopts 21 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 22 | local bundle_str bundle_var bundle_repr gitsite str pair key value 23 | local -a kvpairs parts 24 | local -A bundle 25 | 26 | bundle_str="$1" 27 | bundle_var="${2:-bundle}" 28 | 29 | # Allow the user to override the default git site if they really want to 30 | zstyle -s ':antidote:gitremote' url 'gitsite' \ 31 | || gitsite='https://github.com' 32 | gitsite="${gitsite%/}" 33 | 34 | # Remove anything after the first '#' 35 | bundle_str=${bundle_str%%\#*} 36 | # Trim spaces 37 | bundle_str=${${bundle_str/#[[:space:]]#}/%[[:space:]]#} 38 | # Skip empty bundle strings 39 | [[ -z "$bundle_str" ]] && return 0 40 | # 1st field gets a 'name:' prefix so we can treat everything as key:val pairs 41 | bundle_str="name:${bundle_str}" 42 | 43 | # Split line into key-value pairs with quoting 44 | kvpairs=(${(Q)${(z)bundle_str}}) 45 | for pair in "${kvpairs[@]}"; do 46 | key=${pair%%:*} # Extract key (before first ':') 47 | if [[ "$pair" == *:* ]]; then 48 | value=${pair#*:} # Extract value (after first ':') 49 | else 50 | value= 51 | fi 52 | bundle[$key]=$value 53 | done 54 | 55 | # Enhance the bundle with metadata fields. Metadata fields begin with an underscore 56 | # since those will never be part of the DSL. Let's start with _type, which tells us 57 | # whether the bundle is a URL, a user/repo, or a path 58 | if [[ "$bundle[name]" == *://*/*/* || "$bundle[name]" == (ssh|git)@*:*/* ]]; then 59 | if [[ "$bundle[name]" == *://*/*/*/* || "$bundle[name]" == *@*:*/*/* ]]; then 60 | bundle[_type]="?" 61 | else 62 | bundle[_type]="url" 63 | fi 64 | elif [[ "$bundle[name]" == *('@'|':')* ]] ; then 65 | bundle[_type]="?" # bad URLs 66 | elif [[ "$bundle[name]" == ('~'|'$'|'.')* ]]; then 67 | bundle[_type]="path" 68 | elif [[ "$bundle[name]" == */* && "$bundle[name]" != */*/* ]]; then 69 | bundle[_type]="repo" 70 | elif [[ "$bundle[name]" == */* ]]; then 71 | bundle[_type]="path" 72 | else 73 | bundle[_type]="?" 74 | fi 75 | 76 | # For git repos, we add a metadata field for the URL 77 | if [[ "$bundle[_type]" == url ]]; then 78 | str="$bundle[name]" 79 | str=${str%.git} 80 | str=${str:gs/\:/\/} 81 | parts=( ${(ps./.)str} ) 82 | if [[ $#parts -gt 1 ]]; then 83 | bundle[_repo]="${parts[-2]}/${parts[-1]}" 84 | else 85 | bundle[_repo]="$str" 86 | fi 87 | bundle[_url]="$bundle[name]" 88 | elif [[ "$bundle[_type]" == repo ]]; then 89 | bundle[_repo]="${bundle[name]}" 90 | bundle[_url]="${gitsite}/${bundle[name]}" 91 | fi 92 | 93 | # If there's a git URL, we also need to set the _repodir 94 | if [[ -v bundle[_url] ]]; then 95 | # TODO: Remove for antidote 2.0 96 | if zstyle -t ':antidote:compatibility-mode' 'antibody' || ! zstyle -t ':antidote:bundle' use-friendly-names; then 97 | # sanitize URL for safe use as a dir name 98 | # ex: $ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions 99 | str="$bundle[_url]" 100 | str=${str%.git} 101 | str=${str:gs/\@/-AT-} 102 | str=${str:gs/\:/-COLON-} 103 | str=${str:gs/\//-SLASH-} 104 | bundle[_repodir]="$str" 105 | else 106 | bundle[_repodir]="$bundle[_repo]" 107 | fi 108 | fi 109 | 110 | # Print the parsed bundle assoc arr using whatever bundle_var the user wants 111 | bundle_repr="$(declare -p bundle)" 112 | bundle_repr="typeset -A ${bundle_var}=${bundle_repr#*=}" 113 | 114 | # Sanity check that I probably don't need. 115 | if [[ ! "$bundle_repr" =~ "^typeset\ -A\ ${bundle_var}=" ]]; then 116 | print -ru2 -- "antidote: Unable to parse bundle string: '$bundle_str'." 117 | return 1 118 | fi 119 | 120 | # Return/print the result. 121 | typeset -g REPLY="$bundle_repr" 122 | print -r -- "$REPLY" 123 | #} 124 | -------------------------------------------------------------------------------- /functions/__antidote_print_path: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | ### Pretty print a path 3 | #function __antidote_print_path { 4 | emulate -L zsh; setopt local_options $_adote_funcopts 5 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 6 | if zstyle -t ':antidote:compatibility-mode' 'antibody'; then 7 | print -r -- "$1" 8 | else 9 | print -r -- "${1/#$HOME/\$HOME}" 10 | fi 11 | #} 12 | -------------------------------------------------------------------------------- /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 | # -D : Delete flags from the param array once they are detected 26 | # -M : Map a flag to alternative names (useful for defining -s(hort) and --long options) 27 | # -F : Fail if a flad is provided that was not defined in the zparseops spec 28 | # the -F option was added in 5.8 29 | typeset -gHa _adote_zparopt_flags=( -D -M -F ) 30 | else 31 | typeset -gHa _adote_zparopt_flags=( -D -M ) 32 | fi 33 | 34 | typeset -gHa _adote_funcopts=( extended_glob no_monitor pipefail ) 35 | if zstyle -t ':antidote:tests' set-warn-options; then 36 | typeset -gHa _adote_funcopts=( $_adote_funcopts warn_create_global warn_nested_var ) 37 | fi 38 | 39 | gawk --version &>/dev/null && typeset -gH __adote_awkcmd=gawk || typeset -gH __adote_awkcmd=awk 40 | typeset -gHi __adote_ksh_arrays 41 | typeset -gHi __adote_sh_glob 42 | #} 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.10' 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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) 49 | #} 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 blue normal 25 | if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then 26 | if (( $+commands[tput] )); then 27 | green=$(tput setaf 2) 28 | blue=$(tput setaf 4) 29 | normal=$(tput sgr0) 30 | else 31 | green=$'\E[32m' 32 | blue=$'\E[34m' 33 | normal=$'\E[0m' 34 | fi 35 | fi 36 | 37 | if (( $#o_bundles )) || ! (( $#o_self )); then 38 | print "Updating bundles..." 39 | local bundledir url repo 40 | 41 | # remove zcompiled files 42 | __antidote_del -rf -- $(antidote-home)/**/*.zwc(N) 43 | 44 | # remove check file 45 | local loadable_check_path="$(antidote-home)/.antidote.load" 46 | [[ -r "$loadable_check_path" ]] && __antidote_del -- "$loadable_check_path" 47 | 48 | # Setup temporary directory and tracking 49 | local tmpfile 50 | typeset -g __antidote_update_tmpdir=$(__antidote_mktemp -d -s update) 51 | local tmpdir=$__antidote_update_tmpdir 52 | 53 | # Cleanup function to ensure we don't leave temp files behind 54 | __antidote_update_cleanup() { 55 | [[ -d "$__antidote_update_tmpdir" ]] && __antidote_del -rf -- "$__antidote_update_tmpdir" 56 | unset __antidote_update_tmpdir 57 | } 58 | 59 | # Set trap to ensure cleanup on exit, interrupt, etc. 60 | # (EXIT is special, 2=INT, 15=TERM, 1=HUP) 61 | trap __antidote_update_cleanup EXIT 2 15 1 62 | 63 | # update all bundles 64 | for bundledir in $(antidote-list --dirs); do 65 | url=$(git -C "$bundledir" config remote.origin.url) 66 | repo="${url:h:t}/${${url:t}%.git}" 67 | print "antidote: checking for updates: $url" 68 | 69 | () { 70 | # Create a temporary output file in our temp directory 71 | local repo_id="${repo//\//-SLASH-}" 72 | local tmpfile="${tmpdir}/${repo_id}.output" 73 | local oldsha=$(git -C "$1" rev-parse --short HEAD) 74 | 75 | # Set environment variables to isolate git from user config 76 | local GIT_CONFIG_GLOBAL=/dev/null 77 | local GIT_CONFIG_SYSTEM=/dev/null 78 | 79 | # Unshallow the repo, because with the SHA locking feature coming in v2, we'll 80 | # need to have everything. 81 | if git -C "$1" rev-parse --is-shallow-repository 2>/dev/null | grep -q "true" || [[ -f "$1/.git/shallow" ]]; then 82 | git -C "$1" fetch --quiet --unshallow 83 | else 84 | git -C "$1" fetch --quiet 85 | fi 86 | 87 | git -C "$1" pull --quiet --ff --rebase --autostash 88 | git -C "$1" submodule --quiet sync --recursive 89 | git -C "$1" submodule --quiet update --init --recursive --depth 1 90 | local newsha=$(git -C "$1" rev-parse --short HEAD) 91 | 92 | # Capture all output to temporary file 93 | { 94 | if [[ $oldsha != $newsha ]]; then 95 | print -- "${green}antidote: updated: $2 ${oldsha} -> ${newsha}${normal}" 96 | git -C "$1" --no-pager log --oneline --ancestry-path --first-parent "${oldsha}^..${newsha}" 2>/dev/null 97 | fi 98 | 99 | # recompile bundles 100 | if zstyle -t ":antidote:bundle:$repo" zcompile; then 101 | __antidote_bundle_zcompile $bundledir 102 | fi 103 | } > "$tmpfile" 2>&1 104 | } "$bundledir" "$url" & 105 | done 106 | 107 | print "Waiting for bundle updates to complete..." 108 | print "" 109 | wait 110 | 111 | # Display all output in sequence 112 | for tmpfile in "$tmpdir"/*.output(N); do 113 | if [[ -s "$tmpfile" ]]; then 114 | # Extract the repo id from the filename and decode it 115 | local filename=${tmpfile:t} 116 | local repo_id=${filename%.output} 117 | repo_id=${repo_id//-SLASH-/\/} 118 | 119 | print "${blue}Bundle ${repo_id} update check complete.${normal}" 120 | 121 | # Colorize the SHA 122 | ${__adote_awkcmd:-awk} ' 123 | BEGIN { 124 | YELLOW="\033[33m" 125 | NORMAL="\033[0m" 126 | } 127 | NF >= 1 { 128 | printf "%s%s%s %s\n", YELLOW, $1, NORMAL, substr($0, length($1) + 2) 129 | next 130 | } 131 | { print } 132 | END { print "" } 133 | ' "$tmpfile" 134 | fi 135 | done 136 | 137 | # The trap will do this cleanup too, but let's run this ASAP. 138 | __antidote_update_cleanup 139 | print "${green}Bundle updates complete.${normal}" 140 | print "" 141 | fi 142 | 143 | # update antidote 144 | if (( $#o_self )) || ! (( $#o_bundles )); then 145 | print "Updating antidote..." 146 | if [[ -d "${0:A:h:h}/.git" ]]; then 147 | git -C "${0:A:h:h}" pull --quiet --ff --rebase --autostash 148 | print "antidote self-update complete.\n" 149 | 150 | # setup antidote again 151 | (( $+functions[__antidote_setup] )) && unfunction __antidote_setup 152 | builtin autoload -Uz ${0:A:h}/__antidote_setup 153 | __antidote_setup 154 | 155 | # show antidote version 156 | antidote -v 157 | else 158 | print "Self updating is disabled in this build." 159 | print "Use your OS package manager to update antidote itself." 160 | fi 161 | fi 162 | #} 163 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /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 < 4 | 5 | # AUTHORS 6 | 7 | - Copyright (c) 2021-2024 Matt McElheny 8 | - antidote contributors: 9 | 10 | # LICENSE 11 | 12 | MIT 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/__init__.zsh 24 | % t_setup 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.10 (abcd123) 63 | % 64 | ``` 65 | 66 | ## Teardown 67 | 68 | ```zsh 69 | % t_teardown 70 | % 71 | ``` 72 | -------------------------------------------------------------------------------- /tests/__init__.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | () { 3 | emulate -L zsh 4 | setopt local_options 5 | 6 | 0=${(%):-%x} 7 | local projdir="${0:A:h:h}" 8 | local testdir="${projdir}/tests" 9 | 10 | # setup test functions 11 | fpath+=( $testdir/functions ) 12 | autoload -Uz $testdir/functions/* 13 | } 14 | -------------------------------------------------------------------------------- /tests/fakegitsite.com/fakeuser/fakerepo/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://fakegitsite.com/fakeuser/fakerepo 2 | -------------------------------------------------------------------------------- /tests/fakegitsite.com/fakeuser/fakerepo/fakerepo.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing fakeuser/fakerepo..." 2 | plugins=($plugins fakeuser/fakerepo) 3 | -------------------------------------------------------------------------------- /tests/fakegitsite.com/fakeuser/fakerepo/functions/_fakerepo: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | echo _fakerepo completion 3 | -------------------------------------------------------------------------------- /tests/fakegitsite.com/fakeuser/fakerepo/functions/fakerepo: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function fakerepo { 3 | echo fakerepo function 4 | } 5 | fakerepo "$@" 6 | -------------------------------------------------------------------------------- /tests/functions/aarr_val: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function aar_val() { 3 | emulate -L zsh; setopt local_options 4 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 5 | 6 | local input key val array_name 7 | local -A assoc_array 8 | 9 | # Read from standard input 10 | while IFS= read -r input; do 11 | if [[ $input =~ '^typeset -A ([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$' ]]; then 12 | array_name=${match[1]} 13 | eval "assoc_array=( ${match[2]} )" 14 | print -- "$assoc_array[$1]" 15 | else 16 | echo "Error: Input does not match an associative array declaration" >&2 17 | return 1 18 | fi 19 | done 20 | #} 21 | -------------------------------------------------------------------------------- /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 | local prjdir="${0:A:h:h:h}" 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 "mockgit version 0.0.0" 34 | elif [[ "$1" = "clone" ]]; then 35 | local giturl="$2" 36 | local repo="${giturl:h:t}/${${giturl:t}%.git}" 37 | local bundledir="${3:-.}" 38 | local gitsite_repodir="$prjdir/tests/fakegitsite.com/${repo}" 39 | if [[ -d "$gitsite_repodir" ]]; then 40 | [[ -d "${bundledir:A}" ]] || mkdir -p "${bundledir:A}" 41 | cp -r -- "$gitsite_repodir" "${bundledir:A}" 42 | elif ! (( $#o_quiet )); then 43 | echo "MOCKGIT: Cloning into '${repo:t}'..." 44 | echo "MOCKGIT: Repository not found." 45 | echo "MOCKGIT: repository '$giturl' not found" 46 | fi 47 | elif [[ "$@" = "config remote.origin.url" ]]; then 48 | if [[ -e $bundledir/.git/config/remote.origin.url ]]; then 49 | cat $bundledir/.git/config/remote.origin.url 50 | else 51 | # un-sanitize dir into URL 52 | local url=$o_path[-1] 53 | url=${url:t} 54 | url=${url:gs/-AT-/\@} 55 | url=${url:gs/-COLON-/\:} 56 | url=${url:gs/-SLASH-/\/} 57 | echo "$url" 58 | fi 59 | elif [[ "$@" = "pull" ]]; then 60 | (( $#o_quiet )) || echo "MOCKGIT: Already up to date." 61 | elif [[ "$@" = "rev-parse HEAD" ]]; then 62 | if (( $#o_short )); then 63 | echo "abcd123" 64 | else 65 | echo "abcd1230abcd1230abcd1230abcd1230abcd1230" 66 | fi 67 | elif [[ "$1" == (submodule|fetch) ]]; then 68 | # nothing to do 69 | else 70 | echo >&2 "mocking not implemented for git command: git $@" 71 | return 1 72 | fi 73 | #} 74 | -------------------------------------------------------------------------------- /tests/functions/normalize_aarr: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #normalize_aarr() { 3 | emulate -L zsh; setopt local_options 4 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 5 | 6 | local input key value array_name 7 | local -A assoc_array 8 | 9 | # Read from standard input 10 | while IFS= read -r input; do 11 | if [[ $input =~ '^typeset -A ([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$' ]]; then 12 | array_name=${match[1]} 13 | eval "assoc_array=( ${match[2]} )" 14 | 15 | # Print in the new format 16 | echo -n "typeset -A $array_name=(" 17 | for key in "${(@ok)assoc_array}"; do 18 | value=${assoc_array[$key]} 19 | quoted_value=${(q)value} # Apply (q) to check if quoting is needed 20 | 21 | # Use quoted_value only if it differs from value 22 | [[ $quoted_value != "$value" ]] && value=${(qq)value} 23 | 24 | echo -n " [$key]=$value" 25 | done 26 | echo " )" 27 | else 28 | echo "Error: Input does not match an associative array declaration" >&2 29 | return 1 30 | fi 31 | done 32 | #} 33 | -------------------------------------------------------------------------------- /tests/functions/print_aarr: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function print_aarr() { 3 | emulate -L zsh; setopt local_options 4 | local MATCH MBEGIN MEND; local -a match mbegin mend # appease 'warn_create_global' 5 | 6 | local input key val array_name 7 | local -A assoc_array 8 | 9 | # Read from standard input 10 | while IFS= read -r input; do 11 | if [[ $input =~ '^typeset -A ([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$' ]]; then 12 | array_name=${match[1]} 13 | printf '%-12s: %s\n' "\$assoc_arr" "${array_name}" 14 | eval "assoc_array=( ${match[2]} )" 15 | 16 | for key in ${(ok)assoc_array}; do 17 | val="$( print -r -- ${assoc_array[$key]} | subenv ANTIDOTE_HOME )" 18 | if [[ -z "$val" ]]; then 19 | printf '%-12s:\n' $key 20 | else 21 | printf '%-12s: %s\n' $key $val 22 | fi 23 | done 24 | else 25 | echo "Error: Input does not match an associative array declaration" >&2 26 | return 1 27 | fi 28 | done 29 | #} 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | typeset -g T_PRJDIR="${0:A:h:h:h}" 8 | typeset -g T_TESTDATA=$T_PRJDIR/tests/testdata 9 | local testdir="$T_PRJDIR/tests" 10 | 11 | # save path/fpath 12 | typeset -ga T_PREV_PATH=( $path ) 13 | typeset -ga T_PREV_FPATH=( $fpath ) 14 | 15 | # save zstyles, and clear them all for the test session 16 | typeset -ga T_PREV_ZSTYLES=( ${(@f)"$(zstyle -L ':antidote:*')"} ) 17 | source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}') 18 | 19 | # setup test functions 20 | fpath+=( $testdir/functions ) 21 | autoload -Uz $testdir/functions/* 22 | 23 | # mock git 24 | function git { mockgit "$@" } 25 | 26 | # works with BSD and GNU gmktemp 27 | T_TEMPDIR=${$(mktemp -d -t t_antidote.XXXXXXXX):A} 28 | typeset -g T_PREV_HOME=$HOME 29 | typeset -g T_PREV_ZDOTDIR=$ZDOTDIR 30 | 31 | export HOME=$T_TEMPDIR 32 | export ZDOTDIR=$HOME/.zsh 33 | typeset -g ANTIDOTE_HOME=$HOME/.cache/antidote 34 | 35 | # put tmp_home into position 36 | for p in $testdir/tmp_home/*; do 37 | cp -rf $p $T_TEMPDIR 38 | done 39 | 40 | # put testdata into position 41 | cp -rf -- $T_PRJDIR/tests $T_TEMPDIR/tests 42 | 43 | # rename .mockgit to .git 44 | local mockdir 45 | for mockdir in $T_TEMPDIR/**/.mock*; do 46 | mv $mockdir ${mockdir:s/.mock/.} 47 | done 48 | 49 | # our mock plugins use this 50 | typeset -ga plugins=() 51 | typeset -ga libs=() 52 | 53 | # setup antidote 54 | zstyle ':antidote:tests' set-warn-options 'on' 55 | zstyle ':antidote:tests' cloning 'off' 56 | zstyle ':antidote:bundle' use-friendly-names on 57 | zstyle ':antidote:defer' bundle 'getantidote/zsh-defer' 58 | 59 | # start from tmp home 60 | pushd 61 | cd $T_TEMPDIR 62 | 63 | # source antidote 64 | source $T_PRJDIR/antidote.zsh 65 | #} 66 | -------------------------------------------------------------------------------- /tests/functions/t_setup_real: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | #function t_setup_real { 3 | 0=${(%):-%x} 4 | 5 | # Setup for regular tests 6 | t_setup 7 | 8 | # Now undo some of the testing bits to run for real 9 | typeset -g T_PRJDIR="${0:A:h:h:h}" 10 | typeset -g T_TESTDATA=$T_PRJDIR/tests/testdata/real 11 | local testdir="$T_PRJDIR/tests" 12 | 13 | # undo setup so we clone for real 14 | zstyle ':antidote:tests' cloning 'on' 15 | (( $+functions[git] )) && unfunction git 16 | 17 | # unset other testing zstyles 18 | zstyle -d ':antidote:defer' bundle 19 | 20 | # unset rupa/z 21 | (( $+aliases[z] )) && unalias z 22 | 23 | # replace test versions of bundle files with real versions 24 | for file in .zsh_plugins.txt .zsh_plugins.zsh; do 25 | [[ -f $T_TESTDATA/$file ]] && command cp -f -- "$T_TESTDATA/$file" "$ZDOTDIR/$file" 26 | done 27 | 28 | # clean out antidote home 29 | [[ -d $ANTIDOTE_HOME ]] && command rm -rf -- "$ANTIDOTE_HOME" 30 | mkdir -p "$ANTIDOTE_HOME" 31 | 32 | # source antidote 33 | # source $T_PRJDIR/antidote.zsh 34 | #} 35 | -------------------------------------------------------------------------------- /tests/functions/t_teardown: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | #function t_teardown { 4 | emulate -L zsh 5 | setopt local_options 6 | 7 | # Return to project directory 8 | popd 9 | 10 | # reset current session 11 | HOME=$T_PREV_HOME 12 | ZDOTDIR=$T_PREV_ZDOTDIR 13 | 14 | # unfunction all antidote 15 | for fn in ${(k)functions}; do 16 | [[ $fn == *antidote* ]] && unfunction -- $fn 17 | done 18 | (( $+functions[git] )) && unfunction git 19 | 20 | # unfunction zsh-defer 21 | (( $+functions[zsh-defer] )) && unfunction zsh-defer 22 | 23 | # restore original path/fpath 24 | path=( $T_PREV_PATH ) 25 | fpath=( $T_PREV_FPATH ) 26 | 27 | # restore original zstyles 28 | source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}') 29 | source <(printf '%s\n' $T_PREV_ZSTYLES) 30 | 31 | # remove tempdir 32 | [[ -d "$T_TEMPDIR" ]] && command rm -rf -- "$T_TEMPDIR" 33 | 34 | # remove vars 35 | for var in \ 36 | ANTIDOTE_HOME \ 37 | T_TEMPDIR \ 38 | T_PREV_HOME \ 39 | T_PREV_ZDOTDIR \ 40 | T_PREV_PATH \ 41 | T_PREV_FPATH \ 42 | plugins \ 43 | libs 44 | do 45 | [[ -v $var ]] && unset $var 46 | done 47 | #} 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/test_alt_zsh_defer_bundle.md: -------------------------------------------------------------------------------- 1 | # antidote test alternative zsh-defer repo 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_antidote_core.md: -------------------------------------------------------------------------------- 1 | # antidote core tests 2 | 3 | Tests for antidote's most basic functionality. 4 | 5 | fails gracefully when someone tries bash 6 | 7 | ```zsh 8 | % bash -c "source ./antidote.zsh" 9 | antidote: Expecting zsh. Found 'bash'. 10 | % 11 | ``` 12 | 13 | ## Setup 14 | 15 | ```zsh 16 | % echo $+functions[antidote] 17 | 0 18 | % source ./tests/__init__.zsh 19 | % t_setup 20 | % echo $+functions[antidote] 21 | 1 22 | % git --version 23 | mockgit version 0.0.0 24 | % 25 | ``` 26 | 27 | ## General 28 | 29 | No args displays help: 30 | 31 | ```zsh 32 | % antidote 33 | antidote - the cure to slow zsh plugin management 34 | 35 | usage: antidote [] [ ...] 36 | 37 | flags: 38 | -h, --help Show context-sensitive help 39 | -v, --version Show application version 40 | 41 | commands: 42 | help Show documentation 43 | load Statically source all bundles from the plugins file 44 | bundle Clone bundle(s) and generate the static load script 45 | install Clone a new bundle and add it to your plugins file 46 | update Update antidote and its cloned bundles 47 | purge Remove a cloned bundle 48 | home Print where antidote is cloning bundles 49 | list List cloned bundles 50 | path Print the path of a cloned bundle 51 | init Initialize the shell for dynamic bundles 52 | % 53 | ``` 54 | 55 | No arg exit status is 2: 56 | 57 | ```zsh 58 | % antidote >/dev/null; err=$? 59 | % echo $err 60 | 2 61 | % 62 | ``` 63 | 64 | ## Help 65 | 66 | `-h` and `--help` work: 67 | 68 | ```zsh 69 | % antidote -h >/dev/null; err=$? 70 | % echo $err 71 | 0 72 | % antidote --help >/dev/null; err=$? 73 | % echo $err 74 | 0 75 | % 76 | ``` 77 | 78 | ## Version 79 | 80 | `-v` and `--version` work: 81 | 82 | ```zsh 83 | % antidote --version 84 | antidote version 1.9.10 (abcd123) 85 | % antidote -v >/dev/null; echo $? 86 | 0 87 | % antidote --version >/dev/null; echo $? 88 | 0 89 | % 90 | ``` 91 | 92 | ## Unrecognized options 93 | 94 | ```zsh 95 | % antidote --foo >/dev/null; err=$? #=> --regex (bad option|command not found) 96 | % echo $err 97 | 1 98 | % 99 | ``` 100 | 101 | ## Unrecognized commands 102 | 103 | ```zsh 104 | % antidote foo; err=$? 105 | antidote: command not found 'foo' 106 | % echo $err 107 | 1 108 | % 109 | ``` 110 | 111 | ## All commands 112 | 113 | ```zsh 114 | % cmds=( bundle help home init install list load path purge update main null ) 115 | % for cmd in $cmds; printf '%s' $+functions[antidote-$cmd]; echo 116 | 111111111110 117 | % 118 | ``` 119 | 120 | ## Teardown 121 | 122 | ```zsh 123 | % t_teardown 124 | % 125 | ``` 126 | -------------------------------------------------------------------------------- /tests/test_bundle_helpers.md: -------------------------------------------------------------------------------- 1 | # antidote bundle helper tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % TESTDATA=$PWD/tests/testdata 7 | % source ./tests/__init__.zsh 8 | % t_setup 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 | ## Bundle parser 41 | 42 | Parse a simple repo: 43 | 44 | ```zsh 45 | % echo foo/bar | __antidote_parse_bundles 46 | antidote-script foo/bar 47 | % 48 | ``` 49 | 50 | ```zsh 51 | % echo 'https://github.com/foo/bar path:lib branch:dev' | __antidote_parse_bundles 52 | antidote-script --branch dev --path lib https://github.com/foo/bar 53 | % echo 'git@github.com:foo/bar.git kind:clone branch:main' | __antidote_parse_bundles 54 | antidote-script --branch main --kind clone git@github.com:foo/bar.git 55 | % echo 'foo/bar kind:fpath abc:xyz' | __antidote_parse_bundles 56 | antidote-script --abc xyz --kind fpath foo/bar 57 | % echo 'foo/bar path:plugins/myplugin kind:path # trailing comment' | __antidote_parse_bundles 58 | antidote-script --kind path --path plugins/myplugin foo/bar 59 | % 60 | ``` 61 | 62 | ```zsh 63 | % print 'foo/bar kind:defer\nbar/baz kind:defer\nbaz/qux kind:defer' | __antidote_parse_bundles 64 | antidote-script --kind defer foo/bar 65 | antidote-script --kind defer --skip-load-defer bar/baz 66 | antidote-script --kind defer --skip-load-defer baz/qux 67 | % 68 | ``` 69 | 70 | Handle funky whitespace 71 | 72 | ```zsh 73 | % cr=$'\r'; lf=$'\n'; tab=$'\t' 74 | % echo "foo/bar${tab}kind:path${cr}${lf}" | __antidote_parse_bundles 75 | antidote-script --kind path foo/bar 76 | % 77 | ``` 78 | 79 | The bundle parser needs to properly handle quoted annotations. 80 | 81 | ```zsh 82 | % bundle='foo/bar conditional:"is-macos || is-linux"' 83 | % __antidote_parser $bundle | print_aarr 84 | $assoc_arr : bundle 85 | _repo : foo/bar 86 | _repodir : foo/bar 87 | _type : repo 88 | _url : https://github.com/foo/bar 89 | conditional : is-macos || is-linux 90 | name : foo/bar 91 | % __antidote_parse_bundles $bundle 92 | antidote-script --conditional "is-macos || is-linux" foo/bar 93 | % antidote bundle $bundle 94 | if is-macos || is-linux; then 95 | fpath+=( "$HOME/.cache/antidote/foo/bar" ) 96 | source "$HOME/.cache/antidote/foo/bar/bar.plugin.zsh" 97 | fi 98 | % 99 | ``` 100 | 101 | ```zsh 102 | % bundle="foo/bar pre:'echo hello \$world' post:\"echo \\\"goodbye \$world\\\"\"" 103 | % echo $bundle 104 | foo/bar pre:'echo hello $world' post:"echo \"goodbye $world\"" 105 | % __antidote_parser $bundle | print_aarr 106 | $assoc_arr : bundle 107 | _repo : foo/bar 108 | _repodir : foo/bar 109 | _type : repo 110 | _url : https://github.com/foo/bar 111 | name : foo/bar 112 | post : echo "goodbye $world" 113 | pre : echo hello $world 114 | % __antidote_parse_bundles $bundle 115 | antidote-script --post "echo \"goodbye \$world\"" --pre "echo hello \$world" foo/bar 116 | % antidote bundle $bundle 117 | echo hello $world 118 | fpath+=( "$HOME/.cache/antidote/foo/bar" ) 119 | source "$HOME/.cache/antidote/foo/bar/bar.plugin.zsh" 120 | echo "goodbye $world" 121 | % 122 | ``` 123 | 124 | The bundle parser turns the bundle DSL into antidote-script statements. 125 | 126 | ```zsh 127 | % __antidote_parse_bundles < $ZDOTDIR/.zsh_plugins.txt 128 | antidote-script ~/foo/bar 129 | antidote-script --path plugins/myplugin \$ZSH_CUSTOM 130 | antidote-script foo/bar 131 | antidote-script git@github.com:foo/qux.git 132 | antidote-script --kind clone getantidote/zsh-defer 133 | antidote-script --kind zsh foo/bar 134 | antidote-script --kind fpath foo/bar 135 | antidote-script --kind path foo/bar 136 | antidote-script --path lib ohmy/ohmy 137 | antidote-script --path plugins/extract ohmy/ohmy 138 | antidote-script --kind defer --path plugins/magic-enter ohmy/ohmy 139 | antidote-script --path custom/themes/pretty.zsh-theme ohmy/ohmy 140 | % 141 | ``` 142 | 143 | ## Teardown 144 | 145 | ```zsh 146 | % t_teardown 147 | % 148 | ``` 149 | -------------------------------------------------------------------------------- /tests/test_cmd_bundle.md: -------------------------------------------------------------------------------- 1 | # antidote bundle helper tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 38 | % echo 'foo/bar' | antidote bundle | subenv ANTIDOTE_HOME #=> --file testdata/script-foobar.zsh 39 | % echo 'git@github.com:foo/qux' >$ZDOTDIR/.zsh_plugins_simple.txt 40 | % antidote bundle <$ZDOTDIR/.zsh_plugins_simple.txt | subenv ANTIDOTE_HOME #=> --file testdata/script-fooqux.zsh 41 | % 42 | ``` 43 | 44 | ### Do the same thing, but with antibody mode this time 45 | 46 | Test \|piping, \ --file testdata/antibody/script-foobar.zsh 53 | % echo 'foo/bar' | antidote bundle | subenv ANTIDOTE_HOME #=> --file testdata/antibody/script-foobar.zsh 54 | % echo 'git@github.com:foo/qux' >$ZDOTDIR/.zsh_plugins_simple.txt 55 | % antidote bundle <$ZDOTDIR/.zsh_plugins_simple.txt | subenv ANTIDOTE_HOME #=> --file testdata/antibody/script-fooqux.zsh 56 | % zstyle ':antidote:compatibility-mode' 'antibody' 'off' 57 | % ANTIDOTE_HOME=$HOME/.cache/antidote 58 | % zstyle ':antidote:bundle' use-friendly-names on 59 | % 60 | ``` 61 | 62 | Multiple defers 63 | 64 | ```zsh 65 | % antidote bundle 'foo/bar kind:defer\nbar/baz kind:defer' 2>/dev/null | subenv ANTIDOTE_HOME 66 | if ! (( $+functions[zsh-defer] )); then 67 | fpath+=( "$ANTIDOTE_HOME/getantidote/zsh-defer" ) 68 | source "$ANTIDOTE_HOME/getantidote/zsh-defer/zsh-defer.plugin.zsh" 69 | fi 70 | fpath+=( "$ANTIDOTE_HOME/foo/bar" ) 71 | zsh-defer source "$ANTIDOTE_HOME/foo/bar/bar.plugin.zsh" 72 | fpath+=( "$ANTIDOTE_HOME/bar/baz" ) 73 | zsh-defer source "$ANTIDOTE_HOME/bar/baz/baz.plugin.zsh" 74 | % 75 | ``` 76 | 77 | ## Fails 78 | 79 | ```zsh 80 | % echo "foo/bar\nfoo/baz kind:whoops" | antidote bundle 2>&1 >/dev/null 81 | antidote: error: unexpected kind value: 'whoops' 82 | % 83 | ``` 84 | 85 | ## Teardown 86 | 87 | ```zsh 88 | % t_teardown 89 | % 90 | ``` 91 | -------------------------------------------------------------------------------- /tests/test_cmd_help.md: -------------------------------------------------------------------------------- 1 | # antidote help tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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" == *"$T_PRJDIR/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-foo 154 | 155 | ```zsh 156 | % antidote help foo 157 | No manual entry for antidote-foo 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 | -------------------------------------------------------------------------------- /tests/test_cmd_home.md: -------------------------------------------------------------------------------- 1 | # antidote home tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_cmd_init.md: -------------------------------------------------------------------------------- 1 | # antidote init tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_cmd_install.md: -------------------------------------------------------------------------------- 1 | # antidote installs tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_cmd_list.md: -------------------------------------------------------------------------------- 1 | # antidote list tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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/test_cmd_load.md: -------------------------------------------------------------------------------- 1 | # antidote load tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_cmd_main.md: -------------------------------------------------------------------------------- 1 | # antidote main tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 $T_PRJDIR/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 $T_PRJDIR/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 | -------------------------------------------------------------------------------- /tests/test_cmd_path.md: -------------------------------------------------------------------------------- 1 | # antidote path tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_cmd_purge.md: -------------------------------------------------------------------------------- 1 | # antidote purge tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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_cmd_update.md: -------------------------------------------------------------------------------- 1 | # antidote update tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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.10 (abcd123) 29 | % 30 | ``` 31 | 32 | ## Teardown 33 | 34 | ```zsh 35 | % t_teardown 36 | % 37 | ``` 38 | -------------------------------------------------------------------------------- /tests/test_fpath_rules.md: -------------------------------------------------------------------------------- 1 | # antidote bundle fpath-rule: 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 | -------------------------------------------------------------------------------- /tests/test_helpers.md: -------------------------------------------------------------------------------- 1 | # antidote helper tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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 $T_PRJDIR/antidote.zsh 39 | file 40 | % __antidote_bundle_type $T_PRJDIR/functions 41 | dir 42 | % __antidote_bundle_type '$T_PRJDIR/antidote.zsh' 43 | file 44 | % __antidote_bundle_type \$T_PRJDIR/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_mockgit.md: -------------------------------------------------------------------------------- 1 | # Test git mocking 2 | 3 | ```zsh 4 | % source ./tests/__init__.zsh 5 | % function git { mockgit "$@" } 6 | % 7 | ``` 8 | 9 | Mock: `git --version` 10 | 11 | ```zsh 12 | % git --version 13 | mockgit version 0.0.0 14 | % 15 | ``` 16 | 17 | Mock: SHA 18 | 19 | ```zsh 20 | % git rev-parse HEAD 21 | abcd1230abcd1230abcd1230abcd1230abcd1230 22 | % git rev-parse --short HEAD 23 | abcd123 24 | % 25 | ``` 26 | 27 | Mock: pull 28 | 29 | ```zsh 30 | % git pull --quiet 31 | % git pull 32 | MOCKGIT: Already up to date. 33 | % 34 | ``` 35 | 36 | Mock: clone 37 | 38 | Setup... 39 | 40 | ```zsh 41 | % T_TEMPDIR=${$(mktemp -d -t t_antidote.XXXXXXXX):A} 42 | % 43 | ``` 44 | 45 | ```zsh 46 | % % test -d $T_TEMPDIR/fakeuser #=> --exit 1 47 | % git clone --quiet --depth 1 --recurse-submodules --shallow-submodules https://fakegitsite.com/fakeuser/fakerepo $T_TEMPDIR/fakeuser 48 | % test -d $T_TEMPDIR/fakeuser #=> --exit 0 49 | % test -e $T_TEMPDIR/fakeuser/fakerepo/fakerepo.plugin.zsh #=> --exit 0 50 | % 51 | ``` 52 | 53 | Clean up 54 | 55 | ```zsh 56 | % rm -rf -- $T_TEMPDIR 57 | % 58 | ``` 59 | 60 | Mock: clone missing 61 | 62 | ```zsh 63 | % git clone --depth 1 --recurse-submodules --shallow-submodules https://fakegitsite.com/testy/mctestface 64 | MOCKGIT: Cloning into 'mctestface'... 65 | MOCKGIT: Repository not found. 66 | MOCKGIT: repository 'https://fakegitsite.com/testy/mctestface' not found 67 | % 68 | ``` 69 | 70 | Mock: no-op commands 71 | 72 | ```zsh 73 | % git submodule sync #=> --exit 0 74 | % git submodule sync 75 | % git submodule update #=> --exit 0 76 | % git submodule update 77 | % 78 | ``` 79 | 80 | Mock: non-recognized 81 | 82 | ```zsh 83 | % git status -sb #=> --exit 1 84 | % git status -sb 85 | mocking not implemented for git command: git status -sb 86 | % 87 | ``` 88 | -------------------------------------------------------------------------------- /tests/test_parser.md: -------------------------------------------------------------------------------- 1 | # antidote bundle parser tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 8 | % zstyle ':antidote:gitremote' url 'https://fakegitsite.com/' 9 | % 10 | ``` 11 | 12 | ## Test bundle parser associative arrays 13 | 14 | The bundle parser takes the antidote bundle format and returns an associative array 15 | from the results of `declare -p parsed_bundle` 16 | 17 | Test empty: 18 | 19 | ```zsh 20 | % __antidote_parser 21 | % __antidote_parser '# This is a full line comment' 22 | % 23 | ``` 24 | 25 | Test assoc array for repo 26 | 27 | ```zsh 28 | % __antidote_parser 'foo/bar' | print_aarr 29 | $assoc_arr : bundle 30 | _repo : foo/bar 31 | _repodir : foo/bar 32 | _type : repo 33 | _url : https://fakegitsite.com/foo/bar 34 | name : foo/bar 35 | % 36 | ``` 37 | 38 | Test assoc array for repo in compatibility mode 39 | 40 | ```zsh 41 | % zstyle ':antidote:bundle' use-friendly-names off 42 | % __antidote_parser 'foo/bar' | print_aarr 43 | $assoc_arr : bundle 44 | _repo : foo/bar 45 | _repodir : https-COLON--SLASH--SLASH-fakegitsite.com-SLASH-foo-SLASH-bar 46 | _type : repo 47 | _url : https://fakegitsite.com/foo/bar 48 | name : foo/bar 49 | % zstyle ':antidote:bundle' use-friendly-names on 50 | % 51 | ``` 52 | 53 | Test assoc array for path 54 | 55 | ```zsh 56 | % __antidote_parser '$ZSH_CUSTOM/foo' 'mybundle' | print_aarr 57 | $assoc_arr : mybundle 58 | _type : path 59 | name : $ZSH_CUSTOM/foo 60 | % 61 | ``` 62 | 63 | Test assoc array for jibberish 64 | 65 | ```zsh 66 | % __antidote_parser 'a b c d:e:f' | print_aarr 67 | $assoc_arr : bundle 68 | _type : ? 69 | b : 70 | c : 71 | d : e:f 72 | name : a 73 | % __antidote_parser 'foo bar:baz' | print_aarr 74 | $assoc_arr : bundle 75 | _type : ? 76 | bar : baz 77 | name : foo 78 | % 79 | ``` 80 | 81 | Test assoc array for everything 82 | 83 | ```zsh 84 | % __antidote_parser 'foo/bar branch:baz kind:zsh path:plugins/baz pre:precmd post:"post cmd"' | print_aarr 85 | $assoc_arr : bundle 86 | _repo : foo/bar 87 | _repodir : foo/bar 88 | _type : repo 89 | _url : https://fakegitsite.com/foo/bar 90 | branch : baz 91 | kind : zsh 92 | name : foo/bar 93 | path : plugins/baz 94 | post : post cmd 95 | pre : precmd 96 | % 97 | ``` 98 | 99 | ## Test specific keys have known values 100 | 101 | Test name: 102 | 103 | ```zsh 104 | % __antidote_parser 'foo/bar' | aarr_val name 105 | foo/bar 106 | % 107 | ``` 108 | 109 | Test \_type: 110 | 111 | ```zsh 112 | % __antidote_parser 'foo/bar' | aarr_val _type 113 | repo 114 | % __antidote_parser 'https://github.com/foo/bar' | aarr_val _type 115 | url 116 | % __antidote_parser 'git@bitbucket.org:foo/bar' | aarr_val _type 117 | url 118 | % __antidote_parser '$foo/bar' | aarr_val _type 119 | path 120 | % __antidote_parser '$foo/bar/baz.zsh' | aarr_val _type 121 | path 122 | % __antidote_parser '~foo/bar' | aarr_val _type 123 | path 124 | % __antidote_parser '~/foo' | aarr_val _type 125 | path 126 | % __antidote_parser './foo.zsh' | aarr_val _type 127 | path 128 | % __antidote_parser '../foo.zsh' | aarr_val _type 129 | path 130 | % __antidote_parser 'foo/bar/' | aarr_val _type 131 | path 132 | % __antidote_parser 'foo:bar' | aarr_val _type 133 | ? 134 | % __antidote_parser 'bad@gitsite.com/foo/bar' | aarr_val _type 135 | ? 136 | % __antidote_parser 'http:/badsite.com/foo/bar' | aarr_val _type 137 | ? 138 | % __antidote_parser 'https://badsite.com/foo/bar/baz' | aarr_val _type 139 | ? 140 | % __antidote_parser 'https://badsite.com/foo' | aarr_val _type 141 | ? 142 | % 143 | ``` 144 | 145 | ## Teardown 146 | 147 | ```zsh 148 | % t_teardown 149 | % 150 | ``` 151 | -------------------------------------------------------------------------------- /tests/test_paths_with_spaces.md: -------------------------------------------------------------------------------- 1 | # antidote test paths with spaces 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % TESTDATA=$PWD/tests/testdata 7 | % source ./tests/__init__.zsh 8 | % t_setup 9 | % antidote-bundle -h &>/dev/null 10 | % ANTIDOTE_HOME="$HOME/.cache/antidote with spaces" 11 | % mkdir -p -- "$ANTIDOTE_HOME" 12 | % 13 | ``` 14 | 15 | The bundle parser needs to properly handle quoted annotations. 16 | 17 | ```zsh 18 | % __antidote_parser 'foo/bar' | print_aarr 19 | $assoc_arr : bundle 20 | _repo : foo/bar 21 | _repodir : foo/bar 22 | _type : repo 23 | _url : https://github.com/foo/bar 24 | name : foo/bar 25 | % __antidote_parse_bundles 'foo/bar' 26 | antidote-script foo/bar 27 | % antidote bundle 'foo/bar' 28 | # antidote cloning foo/bar... 29 | fpath+=( "$HOME/.cache/antidote with spaces/foo/bar" ) 30 | source "$HOME/.cache/antidote with spaces/foo/bar/bar.plugin.zsh" 31 | % 32 | ``` 33 | 34 | ## Teardown 35 | 36 | ```zsh 37 | % t_teardown 38 | % 39 | ``` 40 | -------------------------------------------------------------------------------- /tests/test_real.md: -------------------------------------------------------------------------------- 1 | # antidote tests for real 2 | 3 | ## antidote bundle 4 | 5 | ### Setup 6 | 7 | ```zsh 8 | % TESTDATA=$T_PRJDIR/tests/testdata/real 9 | % source ./tests/__init__.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 <$T_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/__init__.zsh 109 | % t_setup_real 110 | % 111 | ``` 112 | 113 | Clone and generate bundle script 114 | 115 | ```zsh 116 | % antidote bundle <$T_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 | % T_TESTDATA=$T_PRJDIR/tests/testdata/real 156 | % source ./tests/__init__.zsh 157 | % t_setup_real 158 | % 159 | ``` 160 | 161 | ### Load 162 | 163 | Load rupa/z 164 | 165 | ```zsh 166 | % echo "rupa/z" > $ZDOTDIR/.zsh_plugins.txt 167 | % antidote load 2>&1 168 | # antidote cloning rupa/z... 169 | % echo $+aliases[z] 170 | 1 171 | % wc -l <$ZDOTDIR/.zsh_plugins.zsh | sed 's/ //g' 172 | 2 173 | % (( ! $+aliases[z] )) || unalias z 174 | % 175 | ``` 176 | 177 | Load re-generates .zsh_plugins.zsh when .zsh_plugins.txt changes 178 | 179 | ```zsh 180 | % compdir=$ANTIDOTE_HOME/zsh-users/zsh-completions/src 181 | % (( $fpath[(Ie)$compdir] )) || echo "completions are not in fpath" 182 | completions are not in fpath 183 | % echo $+aliases[z] 184 | 0 185 | % 186 | ``` 187 | 188 | ...add a new plugin 189 | 190 | ```zsh 191 | % wc -l <$ZDOTDIR/.zsh_plugins.txt | sed 's/ //g' 192 | 1 193 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 194 | fpath+=( "$ANTIDOTE_HOME/rupa/z" ) 195 | source "$ANTIDOTE_HOME/rupa/z/z.sh" 196 | % echo "zsh-users/zsh-completions path:src kind:fpath" >> $ZDOTDIR/.zsh_plugins.txt 197 | % # static cache file hasn't changed yet 198 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 199 | fpath+=( "$ANTIDOTE_HOME/rupa/z" ) 200 | source "$ANTIDOTE_HOME/rupa/z/z.sh" 201 | % 202 | ``` 203 | 204 | ...now do `antidote load` and show that it actually loaded all plugins 205 | 206 | ```zsh 207 | % antidote load 2>&1 208 | # antidote cloning zsh-users/zsh-completions... 209 | % cat $ZDOTDIR/.zsh_plugins.zsh | subenv ANTIDOTE_HOME 210 | fpath+=( "$ANTIDOTE_HOME/rupa/z" ) 211 | source "$ANTIDOTE_HOME/rupa/z/z.sh" 212 | fpath+=( "$ANTIDOTE_HOME/zsh-users/zsh-completions/src" ) 213 | % echo $+aliases[z] 214 | 1 215 | % (( $fpath[(Ie)$compdir] )) && echo "completions are in fpath" 216 | completions are in fpath 217 | % 218 | % wc -l <$ZDOTDIR/.zsh_plugins.zsh | sed 's/ //g' 219 | 3 220 | % 221 | ``` 222 | 223 | ### Teardown 224 | 225 | ```zsh 226 | % t_teardown 227 | % 228 | ``` 229 | -------------------------------------------------------------------------------- /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/__init__.zsh 9 | % t_setup 10 | % setopt KSH_ARRAYS SH_GLOB 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 | -------------------------------------------------------------------------------- /tests/test_zcompile_bundle.md: -------------------------------------------------------------------------------- 1 | # antidote load tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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_zcompile_static.md: -------------------------------------------------------------------------------- 1 | # antidote load tests 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 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/test_zsetopts.md: -------------------------------------------------------------------------------- 1 | # antidote respects setopts 2 | 3 | ## Setup 4 | 5 | ```zsh 6 | % source ./tests/__init__.zsh 7 | % t_setup 8 | % 9 | ``` 10 | 11 | Set up a plugin that changes Zsh options 12 | 13 | ```zsh 14 | % plugin_file=$ANTIDOTE_HOME/lampoon/xmas/xmas.plugin.zsh 15 | % mkdir -p $plugin_file:h && touch $plugin_file 16 | % echo "unsetopt noaliases" >>$plugin_file 17 | % echo "setopt autocd" >>$plugin_file 18 | % echo "lampoon/xmas" >$ZDOTDIR/.zsh_plugins.txt 19 | % 20 | ``` 21 | 22 | ## Test that plugins that run setopts work 23 | 24 | Verify initial state 25 | 26 | ```zsh 27 | % setopt noaliases 28 | % set -o | grep noaliases 29 | noaliases on 30 | % set -o | grep autocd 31 | autocd off 32 | % 33 | ``` 34 | 35 | Load the plugins and see if the option took 36 | 37 | ```zsh 38 | % antidote load &>/dev/null #=> --exit 0 39 | % set -o | grep noaliases 40 | noaliases off 41 | % set -o | grep autocd 42 | autocd on 43 | % # cleanup 44 | % setopt noaliases no_autocd 45 | % 46 | ``` 47 | 48 | Tests to ensure [#86](https://github.com/mattmc3/antidote/issues/86) stays fixed. 49 | Check that stderr is empty. 50 | 51 | ```zsh 52 | % setopt posix_identifiers 53 | % antidote -v 3>&1 2>&3 >/dev/null #=> --exit 0 54 | 55 | % antidote -h 3>&1 2>&3 >/dev/null #=> --exit 0 56 | 57 | % antidote help 3>&1 2>&3 >/dev/null #=> --exit 0 58 | 59 | % # cleanup 60 | % unsetopt posix_identifiers 61 | % 62 | ``` 63 | 64 | ## Clark Grizwold lighting ceremony! 65 | 66 |

via GIPHY

67 | 68 | ```zsh 69 | % optcnt=$(setopt | wc -l | tr -d ' ') 70 | % echo $optcnt #=> --regex ^\d+$ 71 | % test $optcnt -lt 10 && echo "less than 10 enabled zsh opts" 72 | less than 10 enabled zsh opts 73 | % # now lets turn on all the lights 74 | % echo '$ZDOTDIR/custom/plugins/grizwold' >$ZDOTDIR/.zsh_plugins.txt 75 | % antidote load 76 | % optcnt=$(setopt | wc -l | tr -d ' ') 77 | % test $optcnt -gt 150 && echo "zillions of enabled zsh options (>150)" 78 | zillions of enabled zsh options (>150) 79 | % 80 | ``` 81 | 82 | ## Teardown 83 | 84 | ```zsh 85 | % unsetopt $grizwold_zopts 86 | % t_teardown 87 | % 88 | ``` 89 | -------------------------------------------------------------------------------- /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/.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/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/testdata/.zsh_plugins_empty.txt: -------------------------------------------------------------------------------- 1 | # comments 2 | # nothing here 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/testdata/antibody/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/testdata/antibody/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tests/testdata/script-foobar.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( "$ANTIDOTE_HOME/foo/bar" ) 2 | source "$ANTIDOTE_HOME/foo/bar/bar.plugin.zsh" 3 | -------------------------------------------------------------------------------- /tests/testdata/script-fooqux.zsh: -------------------------------------------------------------------------------- 1 | fpath+=( "$ANTIDOTE_HOME/foo/qux" ) 2 | source "$ANTIDOTE_HOME/foo/qux/qux.plugin.zsh" 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/git-AT-github.com-COLON-foo-SLASH-qux/.mockgit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattmc3/antidote/ed83f88722bf6d82f7f04a765fbf01ca025f2efb/tests/tmp_home/.cache/antibody/git-AT-github.com-COLON-foo-SLASH-qux/.mockgit/.gitkeep -------------------------------------------------------------------------------- /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/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar/.mockgit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattmc3/antidote/ed83f88722bf6d82f7f04a765fbf01ca025f2efb/tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar/.mockgit/.gitkeep -------------------------------------------------------------------------------- /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/.mockgit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattmc3/antidote/ed83f88722bf6d82f7f04a765fbf01ca025f2efb/tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-baz/.mockgit/.gitkeep -------------------------------------------------------------------------------- /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-foo-SLASH-baz/functions/_baz: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | echo _baz completion 3 | -------------------------------------------------------------------------------- /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/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/.mockgit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattmc3/antidote/ed83f88722bf6d82f7f04a765fbf01ca025f2efb/tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-getantidote-SLASH-zsh-defer/.mockgit/.gitkeep -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/.mockgit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattmc3/antidote/ed83f88722bf6d82f7f04a765fbf01ca025f2efb/tests/tmp_home/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/.mockgit/.gitkeep -------------------------------------------------------------------------------- /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/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/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/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/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-ohmy-SLASH-ohmy/plugins/docker/_docker: -------------------------------------------------------------------------------- 1 | #compdef 2 | -------------------------------------------------------------------------------- /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/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-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/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-ohmy-SLASH-ohmy/themes/pretty.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing pretty.zsh-theme..." 2 | themes=($themes ohmy:pretty) 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/bar/bar.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/bar..." 2 | plugins=($plugins foo/bar) 3 | -------------------------------------------------------------------------------- /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/baz/baz.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing foo/baz..." 2 | plugins=($plugins foo/baz) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/foo/baz/functions/_baz: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | echo _baz completion 3 | -------------------------------------------------------------------------------- /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/foo/qux/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | git@github.com:foo/qux 2 | -------------------------------------------------------------------------------- /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/getantidote/zsh-defer/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://github.com/getantidote/zsh-defer 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/.mockgit/config/remote.origin.url: -------------------------------------------------------------------------------- 1 | https://github.com/ohmy/ohmy 2 | -------------------------------------------------------------------------------- /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/custom/themes/ugly.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing ugly.zsh-theme..." 2 | themes=($themes ohmy:ugly) 3 | -------------------------------------------------------------------------------- /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/.cache/antidote/ohmy/ohmy/oh-my.sh: -------------------------------------------------------------------------------- 1 | echo "sourcing oh-my.sh..." 2 | plugins=($plugins ohmy/ohmy) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.cache/antidote/ohmy/ohmy/plugins/docker/_docker: -------------------------------------------------------------------------------- 1 | #compdef 2 | -------------------------------------------------------------------------------- /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/antidote/ohmy/ohmy/plugins/extract/extract.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing extract.plugin.zsh..." 2 | plugins+=(ohmy:extract) 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/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/plugins/magic-enter/magic-enter.plugin.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing magic-enter.plugin.zsh..." 2 | plugins+=(ohmy:magic-enter) 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/.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 | -------------------------------------------------------------------------------- /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/tmp_home/.zsh/aliases.zsh: -------------------------------------------------------------------------------- 1 | echo "sourcing aliases.zsh..." 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/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 # Not available in Zsh 5.4.2 35 | chasedots 36 | chaselinks 37 | nocheckjobs 38 | # nocheckrunningjobs # Not available in Zsh 5.4.2 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 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/plugins/myplugin/myplugin.plugin.zsh: -------------------------------------------------------------------------------- 1 | # fake foo/bar 2 | echo "sourcing myplugin..." 3 | plugins+=(custom:myplugin) 4 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/custom/plugins/mytheme/mytheme.zsh-theme: -------------------------------------------------------------------------------- 1 | echo "sourcing mytheme..." 2 | plugins+=(custom:mytheme) 3 | -------------------------------------------------------------------------------- /tests/tmp_home/.zsh/functions/myfunc: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | function myfunc { 3 | echo myfunc "$@" 4 | } 5 | myfunc "$@" 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/run-clitests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 0=${(%):-%x} 3 | setopt extended_glob 4 | 5 | local T_PRJDIR="${0:A:h:h}" 6 | cd "$T_PRJDIR" 7 | 8 | local o_unit o_rev 9 | zparseopts -D -M -- -unit=o_unit -rev=o_rev || return 1 10 | 11 | testfiles=() 12 | if (( $# > 0 )); then 13 | testfiles=($@) 14 | elif (( $#o_unit )); then 15 | testfiles=($T_PRJDIR/tests/README.md $T_PRJDIR/tests/test_*.md~*test_real*~*foo*) 16 | else 17 | testfiles=($T_PRJDIR/tests/README.md $T_PRJDIR/tests/test_*.md) 18 | fi 19 | 20 | # if tests are run in reverse order, I can catch places where I didn't teardown properly 21 | if (( $#o_rev )); then 22 | testfiles=(${(O)testfiles}) 23 | fi 24 | 25 | # foo example test command 26 | # env -i PATH=$PATH FPATH=$FPATH \ 27 | # zsh -f -- =clitest --list-run --progress dot --prompt '%' --color always $T_PRJDIR/tests/foo.md 28 | 29 | # Use ZSH_BINARY if set, otherwise fallback to default zsh 30 | ZSH=${ZSH_BINARY:-zsh} 31 | 32 | env -i PATH=$PATH FPATH=$FPATH PAGER=cat \ 33 | $ZSH -f -- \ 34 | =clitest \ 35 | --list-run --progress dot --prompt '%' \ 36 | --color always \ 37 | --pre-flight 'git --version; print $T_PRJDIR $VENDOR $OSTYPE =$ZSH $ZSH_VERSION $ZSH_PATCHLEVEL' \ 38 | -- $testfiles 39 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------