pax_global_header00006660000000000000000000000064132232667220014517gustar00rootroot0000000000000052 comment=d3d4ee03897eed73efc20c3f779b31194bfa64d8 antigen-2.2.3/000077500000000000000000000000001322326672200131505ustar00rootroot00000000000000antigen-2.2.3/.gitignore000066400000000000000000000010621322326672200151370ustar00rootroot00000000000000# Running tests creates this completion dump file. .zcompdump* # Test failure reports tests/*.t.err # If the $ADOTDIR is the same as the antigen's clone directory itself, the # following would be shown as untracked. repos/ bundles/ revert-info # Cache directory for ext/zcache .cache/ # Default antigen.log location *.log # Release archives and signatures *.tar.gz *.tar.gz.sign # Ignore compiled zsh files *.zwc # Ignore timestamp file for zcache auto-reset config *.timestamp # Cache init /init.zsh .antigenrc .zshrc .zcomp* # Config files .resources antigen-2.2.3/.travis.yml000066400000000000000000000025341322326672200152650ustar00rootroot00000000000000sudo: required dist: trusty language: generic services: - docker cache: pip: true env: global: - USE_CONTAINER=docker matrix: include: - os: linux env: ZSH_VERSION=zsh-5.4.2 - os: linux env: ZSH_VERSION=zsh-5.4.1 - os: linux env: ZSH_VERSION=zsh-5.4 - os: linux env: ZSH_VERSION=zsh-5.3.1 - os: linux env: ZSH_VERSION=zsh-5.3 - os: linux env: ZSH_VERSION=zsh-5.2 - os: linux env: ZSH_VERSION=zsh-5.1.1 - os: linux env: ZSH_VERSION=zsh-5.0.0 - os: linux env: ZSH_VERSION=zsh-4.3.17 - os: linux env: ZSH_VERSION=zsh-4.3.11 notifications: webhooks: urls: - "https://webhooks.gitter.im/e/30fdb3abe241aa03af20" on_success: always on_failure: always on_start: always script: - if [ $TRAVIS_OS_NAME == 'osx' ]; then brew install zsh; pip install cram; fi - make info tests stats USE_CONTAINER=$USE_CONTAINER # Ensure the checked-in build matches the build produced in CI. Since the CI # will run this on both OS X and Linux, the two platforms must also produce # the same build, else one of them will fail. - SHASUM=$(shasum -a 256 ./bin/antigen.zsh) - VERSION=$(cat ./VERSION) make USE_CONTAINER=$USE_CONTAINER - SHACHECK=$(shasum -a 256 ./bin/antigen.zsh) - echo -e "$SHASUM\n$SHACHECK" - test "$SHASUM" == "$SHACHECK" antigen-2.2.3/CHANGELOG.md000066400000000000000000000464721322326672200147760ustar00rootroot00000000000000# CHANGELOG All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) [v2.0.0](http://semver.org/spec/v2.0.0.html). ## [2.2.3] - 2017-12-31 ## Added - [#630] Add zsh version 5.4.x to travis ci - [#633, #634] Add configuration `ANTIGEN_COMPINIT_OPTS` for `compinit` command ## Changed - [#636] Show built-date to version command ## Fixed - [#635] Fix missing common resource file - [#628, #629] Handle `GREP_OPTIONS` env variable ## [2.2.2] - 2017-11-19 ## Added - [#605] Create `CODE_OF_CONDUCT.md` ## Changed - [#611] Remove "no extensions loaded" message - [#610, #596, #608] Fix cache generation with `cache-gen` command - [#609, #593] Add autoload for is-at-least - [#615] Oh-my-zsh themes backward compatibility ## Fixed - [#590, #588, #587, #606] Fix multiple issues with caching generation - [#613] Defer cache loading to `antigen-apply` command - [#618, #617] Unalias built-in `cd` ## [2.2.1] - 2017-06-24 We're adding a new environment variable: - `ANTIGEN_MUTEX` - Use to configure whether to check for mutex or ignore it. This configuration effectively controls if the `lock` should work. Alternatively you may configure which extension you want to load: _ANTIGEN_BUILTIN_EXTENSIONS='lock parallel defer cache' Just remove `lock` from the `_ANTIGEN_BUILTIN_EXTENSIONS` environment variable. Take into account that this may change in the future. ## Added - [#561, #563] Add flag to disable mutex check ## Changed - [#559, #562] Update wiki with all installation options (Debian package, OpenSUSE, Homebrew, etc) - [#564] Improve README.md installation section and content ## Fixed - [#569, #565] Avoid compiled theme artifact showing up on completion - [#558] Fix Makefile's glob used to build logging library if required - [#555, #557, #556] Fix issue with `ps` command's output being discarded (breaking parallel extension) - [#571, #568] Fix issues with `typeset` on zsh 5.0.x and below Thanks everyone who reported issues and provided feedback. ## [2.2.0] - 2017-06-18 We're deploying an extension system to further extend Antigen's functionality. Core functionality such as parallel install and cache are built upon this system, see `src/ext`. Extensions must adhere to a basic interface: - `-antigen-{extension-name}-init` - `-antigen-{extension-name}-execute` Both these functions must return 0 or 1 to abort initialization. Example: antigen ext custom # -antigen-custom-init # -antigne-custom-execute Internally an extension must use Antigen's hook system to retrieve arguments and run custom functionality: - `antigen-add-hook`: antigen-add-hook [antigen-function] [hook-function] ["replace"|"pre"|"post"] ["once"|"repeat"] - `antigen-remove-hook`: antigen-remove-hook [hook-function] ### Added - [#529, #506] Parallel bundle install - [#542] Reset default library url with antigen-use ### Changed - [#547, #552] `antigen-theme` command won't switch between themes ### Fixed - [#550, #548] Fix parallel extension running multiple clone instances - [#549, #463] Fix compdump missing completions - [#553] Catch spurious error message by `ps` Thanks everyone who reported issues and provided feedback. ## [2.1.1] - 2017-05-20 ### Changed - [#537] Clean up README.mkd - [#534] Add new article on zsh and antigen ### Fixed - [#540] Don't require confirmation when removing lock - [#535, #536] Avoid duplicate paths Thanks everyone who reported issues and provided feedback. ## [2.1.0] - 2017-05-14 ### Fixed - [#525] Use `GIT_TERMINAL_PROMPT=0` to avoid password prompt on clone - [#511] Clean up globally defined variables ### Added - [#527] Internal extension system - [#526] Use mutex to prevent concurrent installations - [#501] Autodetect config files ### Changed - [#513] Defer bundle loading to `antigen-apply` command - [#512] Show warning message when bundle is already - [#520] Remove runtime hack to load themes Thanks everyone who reported issues and provided feedback. ## [2.0.2] - 2017-04-22 ### Changed - [#521, #515] Update TravisCI Badges' labels - [#509] Use "Roadmap" for Trello where possible ### Added - [#514] FAQ for dynamic `antigen-theme` usage ### Fixed - [#510] Remove possibly destructive command on broken tests - [#508, #507] Fix status code non-zero when last command is `antigen` wrapper Thanks everyone who reported issues and provided feedback. ## [2.0.1] - 2017-04-15 ### Changed - [#489] Update `CHANGELOG` link to semver documentation - [#497, #498] Improve `antigen-list` command performance ### Fixed - [#487] Fix documentation regarding `ANTIGEN_CHECK_FILES` - [#486, #485] Missing env vars for Oh-My-Zsh - [#492, #490] Fix parsing git/ssh URLS - [#495, #494] Fix `antigen-theme` command changing CWD - [#493, #491] Fix `no-local-clone` flag being ignored Thanks everyone who reported issues and provided feedback. ## [2.0.0] - 2017-04-08 There are functions and configurations being either removed or renamed, please review this document before updating your Antigen installation. Removed functions: - `-antigen-lib` - Deprecated since v1 - `-antigen-prezto-lib` - Deprecated since v1 Deprecated configuration: - `_ANTIGEN_FORCE_RESET_COMPDUMP` - `_ANTIGEN_RESET_THEME_HOOKS` - `_ANTIGEN_AUTODETECT_CONFIG_CHANGES` - `_ANTIGEN_CACHE_ENABLED` - `_ANTIGEN_COMP_ENABLED` Renamed configuration: - `_ANTIGEN_LOG_PATH` ~> `ANTIGEN_LOG` - `_ANTIGEN_CACHE_PATH` ~> `ANTIGEN_CACHE` - `_ANTIGEN_COMPDUMPFILE` ~> `ANTIGEN_COMPDUMP` Added configurations: - `ANTIGEN_CHECK_FILES` - Use to configure which files to check for changes - `ANTIGEN_SUBMODULE_OPTS` - Use to pass arguments to `git submodule` command - `ANTIGEN_CLONE_OPTS` - Use to pass arguments to `git clone` command - `ANTIGEN_BUNDLES` - Use to configure bundle path location - `ANTIGEN_PREZTO_REPO_URL` - Use to configure Prezto default url ### Removed - [#197, #298] Removed `-antigen-lib`, `-antigen-prezto-lib` ### Added - [#309] Use `git` shallow cloning to speed up bundle install - [#299, #261] Handles `$PATH` - [#415] Added link to multiple OS install methods - [#423, #262] Support semver-like bundling - [#461] Use Docker container for tests and stats generation - [#462, #466] Add extended help text for `antigen-help` command - [#467, #465] Show version hash on `antgen-version` command - [#469] Function to migrate old bundle paths to new format - [#464] Update wiki pages for new version ### Changed - [#326, #259] Support updating a single bundle - [#352] Support `antigen-update` tab completion - [#351, #379] Update `Makefile` release tasks - [#411, #371, #445] `antigen-list` show version information (tag, branch, git hash) - [#420] Support reference cache (vs bundle cache) - [#450] Refactor `_ANTIGEN_BUNDLE_RECORD` - [#454] Simplify change detection - [#457, #460] Change bundle path generation function ### Fixed - [#353] `antigen-update` properly handles `--no-local-clone` - [#419] Don't require confirmation when cleaning up - [#439, #442, #438] Fix `antigen-selfupdate` failing with sym-links - [#441, #440] `antigen-init` command checks input - [#453, #452] Respect `_ANTIGEN_COMPDUMP` configuration Thanks everyone who reported issues and provided feedback. ## [1.4.1] - 2017-02-26 ### Changed - [#402, #409] `antigen-use` command handle library url - [#404, #408] Update README.md with new antigen-related articles ### Fixed - [#403, #407] Disable OS X builds on TravisCI Thanks everyone who reported issues and provided feedback. ## [1.4.0] - 2017-02-11 ### Changed - [#386, #387] Use reference cache rather than source bundle ### Fixed - [#400, #391] Cache library handle environment variables for default libraries Thanks @lukechilds, @shoeffner and everyone who reported issues and provided feedback. ## [1.3.5] - 2017-02-03 ### Changed - [#393, #392] Add hint in readme to alternative install methods ### Fixed - [#398, #396] Add argument completion for `antigen-list` command - [#394, #395] Fix syntax issue on zsh 4.3.11 Thanks @TBird2001, @einSelbst and everyone who reported issues and provided feedback. ## [1.3.4] - 2017-01-16 ### Changed - [#389, #385] `antigen-theme` command load themes from path ### Fixed - [#384] Fix updating version references Thanks to everyone who reported issues and provided feedback. ## [1.3.3] - 2017-01-07 ### Changed - [#379, #382] Update makefile release tasks - [#378] Add entry in wiki regarding COMPDUMP location configuration - [#376] Update README.md with external articles - [#375, #374] Add LICENSE file to repository Thanks to everyone who reported issues and provided feedback. ## [1.3.2] - 2016-12-29 ### Fixed - [#367, #368] Fix interactively changing between themes ### Changed - [#369] Enforce coding style - [#370, #372] Update README.md with new external articles Thanks to everyone who reported issues and provided feedback. ## [1.3.1] - 2016-12-17 ### Fixed - [#360, #361] Avoid error when CLOBBER is unset - [#355, #356] Bundle short name breaks on OSX (BSD sed) ### Changed - [#363] Added zsh 5.3 to the build pipeline - [#365, #357] Configure Travis-Ci to build against OS X (10.11, xcode 7.3) - [#350] Add makefile task to create signed releases - [#364, #362] Add note about variable handling inside `antigen-bundles` heredoc Thanks @rltbennett, @rherrick and everyone who reported issues and provided feedback. ## [1.3.0] - 2016-12-10 ### Fixed - [#340, #347] Fix bundle short name broken with branched bundles - [#341] Improve TravisCI performance ### Changed - [#343, #344] Add `--short` option for `antigen-list` command ### Added - [#301, #348] Sign git commits & releases (tags) - [#337, #345] Theme command tab completion - [#335, #342] Purge command for removing bundles from file system Thanks @rugk and everyone who reported issues and provided feedback. ## [1.2.4] - 2016-12-03 ### Fixed - [#321, #322] Fix `antigen-init` command unable to detect bundles - [#328, #331] Display error message if `antigen-theme` fails to load theme ### Changed - [#327, #330] Moved `-antigen-echo-record` to `helpers` directory ### Added - [#323, #329] Add `antigen-init` command entry in `README.md` Thanks @orf, @VincentBel, @wsargent and everyone who reported issues and provided feedback. ## [1.2.3] - 2016-11-21 ### Fixed - [#318, #317] Fixed issue with sed regexp format between BSD and GNU Thanks @john-kurkowski and everyone who reported issues and provided feedback. ## [1.2.2] - 2016-11-18 ### Changed - [#315, #308] Bundle command returns error if repository is not found - [#313, #314] Enhanced cache process-source function ### Fixed - [#310, #307] Disabling cache-related commands if cache is disabled - [#311, #304] Handle bundle's default branch different than master Thanks @DestyNova, @yacoob, @qstrahl and everyone who reported issues and provided feedback. ## [1.2.1] - 2016-10-15 Antigen now resets compdump file on `antigen-apply` or with cache resetting (be it with `antigen-reset` or auto-detecting changes in bundling configuration). This is necessary to handle completions correctly. Activate this functionality with `_ANTIGEN_FORCE_RESET_COMPDUMP`, defaults to `true`. Antigen previously didn't created `$ADOTDIR` explicitly, now it does so on start up. This directory defaults to `$HOME/.antigen` and it's used to store logs, repositories and cache files. Theme switching, with `antigen-theme` command, now removes hooks applied by themes. This is done in order to be able to interactively switch between themes without issues, such as prompt broken by hooks left by previous themes. This functionality is actived by default and can be disabled with `_ANTIGEN_RESET_THEME_HOOKS`. New environment variables: - `_ANTIGEN_FORCE_RESET_COMPDUMP`: Whether to force compdump to be reset with `antigen-apply` or cache reset. - `_ANTIGEN_RESET_THEME_HOOKS`: Whether to remove theme hooks on `antigen-theme` command. ### Added - [#289, #286] Check $ADOTDIR exists on start up ### Changed - [#291, #281] Reset compdump on apply and cache reset - [#282] Fixed a simple typo in a code comment regarding git availability ### Fixed - [#290, #283] Remove theme hooks when changing themes - [#288, #285] Fix keybindings hook disabled in zcache-done - [#284] Fix `local`s in themes Thanks @jordi9, @edqu3, @jmusal, @ming13, @kmikolaj and everyone who reported issues and provided feedback. ## [1.2.0] - 2016-10-09 Antigen now auto-detects configuration changes. This is done by detecting new/removed bundles/ordering changes in configuration (bundles, themes, use etc). When a change is detected next time Antigen is loaded it'll rebuild cache. `cache-reset` command is now deprecated and should be used `reset` instead. `-antigen-parse-args` function was removed in favor of a more flexible, lax and performant implementation. The following errors are not present anymore: - Positional argument count mismatch - Argument repeated - No argument required Positional argument count mismatch: There is no `spec` argument from now on so there is no definition on arguments. Argument repeated: All arguments are parsed and returned. Last value is used. No argument required: The case is `--no-local-clone` and the value passed is ignored. New environment variables: - `_ANTIGEN_AUTODETECT_CONFIG_CHANGES`: Whether to check for configuration changes (true by default). ### Changed - [#257, #271] Remove parse-args function - [#255, #265, #275, #253] Refactor/clean up code - [#274, #267] Hook antigen-bundles command - [#266, #258] Deprecate cache-reset command in favor of reset - [#256, #264] Auto detect changes in bundling - [#277] Fix for antigen 1.1.4 ### Fixed - [#273] Missing antigen-apply on zcache-done - [#272] Fix bundle-short-name function to handle gist urls Thanks everyone who reported issues and provided feedback. ## [1.1.4] - 2016-09-25 Default cache and bundles path is now `$ADOTDIR/.cache` and `$ADOTDIR/repos` (it was `$_ANTIGEN_INSTALL_DIR/.cache` and `$_ANTIGEN_INSTALL_DIR/repos`). New environment variables: - `_ANTIGEN_INTERACTIVE_MODE`: Use to force Antigen into running the caching mechanism even in interactive mode (by default it deactivate caching in interactive shells). ### Changed - [#248] Enhanced caching performance - [#245, #244] Changed default caching and logging paths ### Fixed - [#249, #240, #246] Makefile BSD compatibility - [#247, #228] Fix apply and antigen-apply command - [#251] Fix Makefile publish task Thanks @fladi, @jdkbx, @extink and everyone who reported issues and provided feedback. ## [1.1.3] - 2016-09-20 ### Changed - [#236] Add Makefile release and publish tasks ### Fixed - [#239] Issue with BSD sed (MacOS, FreeBSD) Thanks @pawelad, @laurenbenichou, @zawadzkip and everyone who reported issues and provided feedback. ## [1.1.2] - 2016-09-16 ### Changed - [#234] Cache process-source function now handles function-context - [#233] Antigen selfupdate command now clears cache automatically ### Fixed - [#219] Issue with zsh-navigation-tools plugin and powerlevel9k theme - [#230] Issue with stalled cache Thanks @xasx, @ilkka, @NelsonBrandao and everyone who reported issues and provided feedback. ## [1.1.1] - 2016-09-13 ### Changed - [#223] Update tests cases ### Fixed - [#220] Fpath was not updated correctly - [#221, #217] Fix various typos in CHANGELOG.md - [#224] Update README.md Thanks @xasx, @azu and @mikeys ## [1.1.0] - 2016-09-10 New environment variables: - `_ANTIGEN_LOG_PATH`: Antigen path for logging (mostly git commands). - `_ANTIGEN_COMP_ENABLED`: Flag to enable/disable Antigen own completions `compinit`, which adds `~0.02s` to load time. - `_ANTIGEN_CACHE_ENABLED`: Flag to enable/disable cache system. New commands: - `init`: Use this command to load antigen configuration. Example set up: .zshrc: source antigen.zsh antigen init .antigenrc .antigenrc: antigen use oh-my-zsh antigen bundle ... antigen theme ... antigen apply This setup further improves cache performance (`~0.02s`). It's fully optional. - `cache-reset`: Clears current cache. Doesn't removes your bundles. This is done automatically after `antigen update` command. - `version`: Show antigen running version. ### Added - [#129] Cache system for better performance - [#191] Version command - [#211] Option to disable antigen's own completions compinit on start up ### Changed - [#205] Bundle short syntax on install/update - [#156, #213] Improved continuos integration set up - [#195] Restructured project directory ### Fixed - [#210] Prezto issue with environment variable - [#162] Fix issue with antigen update after revert ## [1.0.4] - 2016-08-27 ### Added - [#188] Add CONTRIBUTING.md to documentation - [#183] Update README.md to use rawgit in examples - [#182] Add Gitter, Trello and Travis CI badges ### Changed - [#171] Continuous integration against multiple Zsh versions ### Fixed - [#170] Check git dependency on sourcing - [#169] Load Antigen's own completions at load time ## [1.0.3] - 2016-08-20 ### Changed - [#172] Fix TravisCI configuration ## [1.0.2] - 2016-08-11 ### Changed - [#168] Update README.md example code thanks to @chadmoore ## [1.0.1] - 2016-07-21 ### Added - [#141] Performance improvements thanks to @outcoldman - Added CHANGELOG.md - Following [Semantic Versioning](http://semver.org/) [2.2.3]: https://github.com/zsh-users/antigen/compare/v2.2.2...v2.2.3 [2.2.2]: https://github.com/zsh-users/antigen/compare/v2.2.1...v2.2.2 [2.2.1]: https://github.com/zsh-users/antigen/compare/v2.2.0...v2.2.1 [2.2.0]: https://github.com/zsh-users/antigen/compare/v2.1.1...v2.2.0 [2.1.1]: https://github.com/zsh-users/antigen/compare/v2.1.0...v2.1.1 [2.1.0]: https://github.com/zsh-users/antigen/compare/v2.0.2...v2.1.0 [2.0.2]: https://github.com/zsh-users/antigen/compare/v2.0.1...v2.0.2 [2.0.1]: https://github.com/zsh-users/antigen/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/zsh-users/antigen/compare/v1.4.1...v2.0.0 [1.4.1]: https://github.com/zsh-users/antigen/compare/v1.4.0...v1.4.1 [1.4.0]: https://github.com/zsh-users/antigen/compare/v1.3.5...v1.4.0 [1.3.5]: https://github.com/zsh-users/antigen/compare/v1.3.4...v1.3.5 [1.3.4]: https://github.com/zsh-users/antigen/compare/v1.3.3...v1.3.4 [1.3.3]: https://github.com/zsh-users/antigen/compare/v1.3.2...v1.3.3 [1.3.2]: https://github.com/zsh-users/antigen/compare/v1.3.1...v1.3.2 [1.3.1]: https://github.com/zsh-users/antigen/compare/v1.3.0...v1.3.1 [1.3.0]: https://github.com/zsh-users/antigen/compare/v1.2.4...v1.3.0 [1.2.4]: https://github.com/zsh-users/antigen/compare/v1.2.3...v1.2.4 [1.2.3]: https://github.com/zsh-users/antigen/compare/v1.2.2...v1.2.3 [1.2.2]: https://github.com/zsh-users/antigen/compare/v1.2.1...v1.2.2 [1.2.1]: https://github.com/zsh-users/antigen/compare/v1.2.0...v1.2.1 [1.2.0]: https://github.com/zsh-users/antigen/compare/v1.1.4...v1.2.0 [1.1.4]: https://github.com/zsh-users/antigen/compare/v1.1.3...v1.1.4 [1.1.3]: https://github.com/zsh-users/antigen/compare/v1.1.2...v1.1.3 [1.1.2]: https://github.com/zsh-users/antigen/compare/v1.1.1...v1.1.2 [1.1.1]: https://github.com/zsh-users/antigen/compare/v1.1.0...v1.1.1 [1.1.0]: https://github.com/zsh-users/antigen/compare/v1.0.4...v1.1.0 [1.0.4]: https://github.com/zsh-users/antigen/compare/v1.0.3...v1.0.4 [1.0.3]: https://github.com/zsh-users/antigen/compare/v1.0.2...v1.0.3 [1.0.2]: https://github.com/zsh-users/antigen/compare/v1.0.1...v1.0.2 [1.0.1]: https://github.com/zsh-users/antigen/compare/v1...v1.0.1 antigen-2.2.3/CODE_OF_CONDUCT.md000066400000000000000000000125311322326672200157510ustar00rootroot00000000000000# Code of Conduct ## 1. Purpose A primary goal of Antigen is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior. We invite all those who participate in Antigen to help us create safe and positive experiences for everyone. ## 2. Open Source Citizenship A supplemental goal of this Code of Conduct is to increase open source citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community. Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society. If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know. ## 3. Expected Behavior The following behaviors are expected and requested of all community members: * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. * Exercise consideration and respect in your speech and actions. * Attempt collaboration before conflict. * Refrain from demeaning, discriminatory, or harassing behavior and speech. * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. * Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. ## 4. Unacceptable Behavior The following behaviors are considered harassment and are unacceptable within our community: * Violence, threats of violence or violent language directed against another person. * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. * Posting or displaying sexually explicit or violent material. * Posting or threatening to post other people’s personally identifying information ("doxing"). * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. * Inappropriate photography or recording. * Inappropriate physical contact. You should have someone’s consent before touching them. * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. * Deliberate intimidation, stalking or following (online or in person). * Advocating for, or encouraging, any of the above behavior. * Sustained disruption of community events, including talks and presentations. ## 5. Consequences of Unacceptable Behavior Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated. Anyone asked to stop unacceptable behavior is expected to comply immediately. If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event). ## 6. Reporting Guidelines If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. desyncr@riseup.net. Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. ## 7. Addressing Grievances If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify Zsh Users with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. ## 8. Scope We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues–online and in-person–as well as in all one-on-one communications pertaining to community business. This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members. ## 9. Contact info desyncr@riseup.net ## 10. License and attribution This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/) antigen-2.2.3/CONTRIBUTING.md000066400000000000000000000123761322326672200154120ustar00rootroot00000000000000# Contributing to this project Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved. Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features. ## Using the issue tracker The [issue tracker](issues) is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests) and [submitting pull requests](#pull-requests), but please respect the following restrictions: * Please **do not** use the issue tracker for personal support requests (use [Stack Overflow](http://stackoverflow.com/search?q=antigen) or [Gitter](https://gitter.im/antigen-zsh/develop)). * Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. ## Bug reports A bug is a _demonstrable problem_ that is caused by the code in the repository. Good bug reports are extremely helpful - thank you! Guidelines for bug reports: 1. **Use the GitHub issue search** — check if the issue has already been reported. 2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository. 3. **Isolate the problem** — create a reduced test case and a live example. A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. Be sure to include: - Antigen, Zsh and OS version - Antigen and Zsh configurations (usually `~/.zshrc` and `~/.antigenrc`) - What would you expect to be the outcome? - What are the steps to reproduce the issue All these details will help people to fix any potential bugs. Example: > Short and descriptive example bug report title > > A summary of the issue and the Zsh version/OS environment in which it occurs. > If suitable, include the steps required to reproduce the bug. > > 1. This is the first step > 2. This is the second step > 3. Further steps, etc. > > `` - a link to the zsh configuration > > Any other information you want to share that is relevant to the issue being > reported. This might include the lines of code that you have identified as > causing the bug, and potential solutions (and your opinions on their > merits). ## Feature requests Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible. ## Pull requests Good pull requests (patches, improvements, new features) are a fantastic help. They should remain focused in scope and avoid containing unrelated commits. **Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project. Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). Follow this process if you'd like your work considered for inclusion in the project: 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: ```bash # Clone your fork of the repo into the current directory git clone https://github.com// # Navigate to the newly cloned directory cd # Assign the original repo to a remote called "upstream" git remote add upstream https://github.com/zsh-users/antigen ``` 2. If you cloned a while ago, get the latest changes from upstream: ```bash git checkout git pull upstream ``` 3. Create a new topic branch (off the main project development branch `develop`) to contain your feature, change, or fix: ```bash git checkout -b ``` > Please use `documentation/`, `feature/` or `bugfix/` for branch names if you are enhancing documentation, adding a new feature or creating a bugfix. 4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your code is unlikely be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. 5. Locally merge (or rebase) the upstream development branch into your topic branch: ```bash git pull [--rebase] upstream ``` 6. Push your topic branch up to your fork: ```bash git push origin ``` 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description. **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project. antigen-2.2.3/LICENSE000066400000000000000000000021201322326672200141500ustar00rootroot00000000000000The MIT License (MIT) Copyright © Shrikant Sharat Kandula, http://sharats.me. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. antigen-2.2.3/Makefile000066400000000000000000000115201322326672200146070ustar00rootroot00000000000000###################################################################### # This file was autogenerated by 'configure'. Do not edit it directly! # Invocation was: ./configure ###################################################################### WITH_LOCK=yes WITH_DEFER=yes WITH_CACHE=yes WITH_DEBUG=yes WITH_PARALLEL=yes WITH_EXTENSIONS=yes WITH_COMPLETION=yes ###################################################################### SHELL ?= sh PREFIX ?= /usr/local CRAM_OPTS ?= -v PROJECT ?= $(CURDIR) BIN ?= ${PROJECT}/bin SRC ?= ${PROJECT}/src TESTS ?= ${PROJECT}/tests TOOLS ?= ${PROJECT}/tools TEST ?= ${PROJECT}/tests ZSH_VERSION ?= zsh-5.3 CONTAINER_ROOT ?= /antigen USE_CONTAINER ?= docker CONTAINER_IMAGE ?= desyncr/zsh-docker- TARGET ?= ${BIN}/antigen.zsh SRC ?= ${SRC} EXTENSIONS ?= GLOB ?= WITH_DEBUG ?= yes WITH_EXTENSIONS ?= yes WITH_DEFER ?= yes WITH_LOCK ?= yes WITH_PARALLEL ?= yes WITH_CACHE ?= yes WITH_COMPLETION ?= yes ifeq (${WITH_EXTENSIONS}, yes) EXTENSIONS += ${SRC}/ext/ext.zsh endif ifeq (${WITH_DEFER}, yes) EXTENSIONS += ${SRC}/ext/defer.zsh endif ifeq (${WITH_LOCK}, yes) EXTENSIONS += ${SRC}/ext/lock.zsh endif ifeq (${WITH_PARALLEL}, yes) EXTENSIONS += ${SRC}/ext/parallel.zsh endif ifeq (${WITH_CACHE}, yes) GLOB += ${SRC}/boot.zsh EXTENSIONS += ${SRC}/ext/cache.zsh endif LIB = $(filter-out ${SRC}/lib/log.zsh,$(sort $(wildcard ${PWD}/src/lib/*.zsh))) HELPERS = $(sort $(wildcard ${PWD}/src/helpers/*.zsh)) COMMANDS= $(sort $(wildcard ${PWD}/src/commands/*.zsh)) GLOB += ${SRC}/antigen.zsh ${HELPERS} ${LIB} ${COMMANDS} ${EXTENSIONS} ifeq (${WITH_COMPLETION}, yes) GLOB += ${SRC}/_antigen endif # If debug is enabled then load debug functions ifeq (${WITH_DEBUG}, yes) GLOB += ${SRC}/lib/log.zsh endif VERSION ?= develop VERSION_FILE = ${PROJECT}/VERSION BANNER_SEP =$(shell printf '%*s' 70 | tr ' ' '\#') BANNER_TEXT =This file was autogenerated by \`make\`. Do not edit it directly! BANNER =${BANNER_SEP}\n\# ${BANNER_TEXT}\n${BANNER_SEP}\n HEADER_TEXT =\# Antigen: A simple plugin manager for zsh\n\ \# Authors: Shrikant Sharat Kandula\n\ \# and Contributors \n\ \# Homepage: http://antigen.sharats.me\n\ \# License: MIT License \n define ised sed $(1) $(2) > "$(2).1" mv "$(2).1" "$(2)" endef define isede sed -E $(1) $(2) > "$(2).1" mv "$(2).1" "$(2)" endef .PHONY: itests tests install all build: @echo Building Antigen... @printf "${BANNER}" > ${BIN}/antigen.zsh @printf "${HEADER_TEXT}" >> ${BIN}/antigen.zsh @for src in ${GLOB}; do echo "----> $$src"; cat "$$src" >> ${TARGET}; done @echo "-antigen-env-setup" >> ${TARGET} @echo "${VERSION}" > ${VERSION_FILE} @$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET}) @$(call ised,"s/{{ANTIGEN_REVISION}}/$$(git log -n1 --format=%h -- src)/",${TARGET}) @$(call ised,"s/{{ANTIGEN_REVISION_DATE}}/$$(git log -n1 --format='%ai' -- src)/",${TARGET}) ifeq (${WITH_DEBUG}, no) @$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET}) @$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET}) endif @echo Done. @ls -sh ${TARGET} release: # Move to release branch git checkout develop git checkout -b release/${VERSION} # Run build and tests ${MAKE} build tests # Update changelog ${EDITOR} CHANGELOG.md # Build release commit git add CHANGELOG.md README.mkd ${VERSION_FILE} git commit -S -m "Update changelog for ${VERSION}" # Update binary artifact git add ${TARGET} git commit -S -m "Build release ${VERSION}" publish: git push origin release/${VERSION} # Merge release branch into develop before deploying deploy: git checkout develop git tag -m "Build release ${VERSION}" -s ${VERSION} git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign # Verify signature zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign - # Push upstream git push upstream ${VERSION} .container: ifeq (${USE_CONTAINER}, docker) @docker run --rm --privileged=true -it -v ${PROJECT}:/antigen ${CONTAINER_IMAGE}${ZSH_VERSION} $(shell echo "${COMMAND}" | sed "s|${PROJECT}|${CONTAINER_ROOT}|g") else ifeq (${USE_CONTAINER}, no) ${COMMAND} endif info: @${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'" itests: @${MAKE} tests CRAM_OPTS=-i tests: @${MAKE} .container COMMAND="sh -c 'ZDOTDIR=${TESTS} ANTIGEN=${PROJECT} cram ${CRAM_OPTS} --shell=zsh ${TEST}'" stats: @${MAKE} .container COMMAND="${TOOLS}/stats --zsh zsh --antigen ${PROJECT}" install: mkdir -p ${PREFIX}/share && cp ${TARGET} ${PREFIX}/share/antigen.zsh clean: rm -f ${PREFIX}/share/antigen.zsh install-deps: sudo pip install cram=='0.6.*' all: clean build install antigen-2.2.3/Makefile.in000066400000000000000000000106401322326672200152160ustar00rootroot00000000000000SHELL ?= sh PREFIX ?= /usr/local CRAM_OPTS ?= -v PROJECT ?= $(CURDIR) BIN ?= ${PROJECT}/bin SRC ?= ${PROJECT}/src TESTS ?= ${PROJECT}/tests TOOLS ?= ${PROJECT}/tools TEST ?= ${PROJECT}/tests ZSH_VERSION ?= zsh-5.3 CONTAINER_ROOT ?= /antigen USE_CONTAINER ?= docker CONTAINER_IMAGE ?= desyncr/zsh-docker- TARGET ?= ${BIN}/antigen.zsh SRC ?= ${SRC} EXTENSIONS ?= GLOB ?= WITH_DEBUG ?= yes WITH_EXTENSIONS ?= yes WITH_DEFER ?= yes WITH_LOCK ?= yes WITH_PARALLEL ?= yes WITH_CACHE ?= yes WITH_COMPLETION ?= yes ifeq (${WITH_EXTENSIONS}, yes) EXTENSIONS += ${SRC}/ext/ext.zsh endif ifeq (${WITH_DEFER}, yes) EXTENSIONS += ${SRC}/ext/defer.zsh endif ifeq (${WITH_LOCK}, yes) EXTENSIONS += ${SRC}/ext/lock.zsh endif ifeq (${WITH_PARALLEL}, yes) EXTENSIONS += ${SRC}/ext/parallel.zsh endif ifeq (${WITH_CACHE}, yes) GLOB += ${SRC}/boot.zsh EXTENSIONS += ${SRC}/ext/cache.zsh endif LIB = $(filter-out ${SRC}/lib/log.zsh,$(sort $(wildcard ${PWD}/src/lib/*.zsh))) HELPERS = $(sort $(wildcard ${PWD}/src/helpers/*.zsh)) COMMANDS= $(sort $(wildcard ${PWD}/src/commands/*.zsh)) GLOB += ${SRC}/antigen.zsh ${HELPERS} ${LIB} ${COMMANDS} ${EXTENSIONS} ifeq (${WITH_COMPLETION}, yes) GLOB += ${SRC}/_antigen endif # If debug is enabled then load debug functions ifeq (${WITH_DEBUG}, yes) GLOB += ${SRC}/lib/log.zsh endif VERSION ?= develop VERSION_FILE = ${PROJECT}/VERSION BANNER_SEP =$(shell printf '%*s' 70 | tr ' ' '\#') BANNER_TEXT =This file was autogenerated by \`make\`. Do not edit it directly! BANNER =${BANNER_SEP}\n\# ${BANNER_TEXT}\n${BANNER_SEP}\n HEADER_TEXT =\# Antigen: A simple plugin manager for zsh\n\ \# Authors: Shrikant Sharat Kandula\n\ \# and Contributors \n\ \# Homepage: http://antigen.sharats.me\n\ \# License: MIT License \n define ised sed $(1) $(2) > "$(2).1" mv "$(2).1" "$(2)" endef define isede sed -E $(1) $(2) > "$(2).1" mv "$(2).1" "$(2)" endef .PHONY: itests tests install all build: @echo Building Antigen... @printf "${BANNER}" > ${BIN}/antigen.zsh @printf "${HEADER_TEXT}" >> ${BIN}/antigen.zsh @for src in ${GLOB}; do echo "----> $$src"; cat "$$src" >> ${TARGET}; done @echo "-antigen-env-setup" >> ${TARGET} @echo "${VERSION}" > ${VERSION_FILE} @$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET}) @$(call ised,"s/{{ANTIGEN_REVISION}}/$$(git log -n1 --format=%h -- src)/",${TARGET}) @$(call ised,"s/{{ANTIGEN_REVISION_DATE}}/$$(git log -n1 --format='%ai' -- src)/",${TARGET}) ifeq (${WITH_DEBUG}, no) @$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET}) @$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET}) endif @echo Done. @ls -sh ${TARGET} release: # Move to release branch git checkout develop git checkout -b release/${VERSION} # Run build and tests ${MAKE} build tests # Update changelog ${EDITOR} CHANGELOG.md # Build release commit git add CHANGELOG.md README.mkd ${VERSION_FILE} git commit -S -m "Update changelog for ${VERSION}" # Update binary artifact git add ${TARGET} git commit -S -m "Build release ${VERSION}" publish: git push origin release/${VERSION} # Merge release branch into develop before deploying deploy: git checkout develop git tag -m "Build release ${VERSION}" -s ${VERSION} git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign # Verify signature zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign - # Push upstream git push upstream ${VERSION} .container: ifeq (${USE_CONTAINER}, docker) @docker run --rm --privileged=true -it -v ${PROJECT}:/antigen ${CONTAINER_IMAGE}${ZSH_VERSION} $(shell echo "${COMMAND}" | sed "s|${PROJECT}|${CONTAINER_ROOT}|g") else ifeq (${USE_CONTAINER}, no) ${COMMAND} endif info: @${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'" itests: @${MAKE} tests CRAM_OPTS=-i tests: @${MAKE} .container COMMAND="sh -c 'ZDOTDIR=${TESTS} ANTIGEN=${PROJECT} cram ${CRAM_OPTS} --shell=zsh ${TEST}'" stats: @${MAKE} .container COMMAND="${TOOLS}/stats --zsh zsh --antigen ${PROJECT}" install: mkdir -p ${PREFIX}/share && cp ${TARGET} ${PREFIX}/share/antigen.zsh clean: rm -f ${PREFIX}/share/antigen.zsh install-deps: sudo pip install cram=='0.6.*' all: clean build install antigen-2.2.3/README.mkd000066400000000000000000000150311322326672200146020ustar00rootroot00000000000000

Antigen
Antigen v2

The plugin manager for zsh.

Latest Build Status Build Status

Installation | Documentation | Bug tracker | Roadmap | Chat | License

Antigen is a small set of functions that help you easily manage your shell (zsh) plugins, called bundles. The concept is pretty much the same as bundles in a typical vim+pathogen setup. Antigen is to zsh, what [Vundle][] is to vim. [![https://asciinema.org/a/cn20v8fy6wrhab4l5kifv6dce](https://asciinema.org/a/cn20v8fy6wrhab4l5kifv6dce.png)](https://asciinema.org/a/cn20v8fy6wrhab4l5kifv6dce) Antigen has reached a certain level of stability and has been used in the wild for around a couple of years. If you face any problems, please open an issue. Antigen works with zsh versions `>= 4.3.11`. ## Installation Install Antigen from our main repository with the latest stable version available: curl -L git.io/antigen > antigen.zsh # or use git.io/antigen-nightly for the latest version There are several installation methods using your System Package manager, just look at the [Installation][] wiki page. Now you may head towards the [Commands][] and [Configuration][] wiki pages to further understand Antigen's functionallity and customization. ## Usage The usage should be very familiar to you if you use Vundle. A typical `.zshrc` might look like this: source /path-to-antigen/antigen.zsh # Load the oh-my-zsh's library. antigen use oh-my-zsh # Bundles from the default repo (robbyrussell's oh-my-zsh). antigen bundle git antigen bundle heroku antigen bundle pip antigen bundle lein antigen bundle command-not-found # Syntax highlighting bundle. antigen bundle zsh-users/zsh-syntax-highlighting # Load the theme. antigen theme robbyrussell # Tell Antigen that you're done. antigen apply Open your zsh with this `.zshrc` and you should see all the bundles you defined here, getting installed. Once it's done, you are ready to roll. The complete syntax for the `antigen bundle` command is discussed in the [Commands][] page. Furthermore, [In the wild][wild] wiki section has more configuration examples. You may as well take a look at the [Show off][] wiki page for interactive mode usage. ## Meta ### Motivation If you use zsh and [oh-my-zsh][], you know that having many different plugins that are developed by many different authors in a single (sub)repo is not very easy to maintain. There are some really fantastic plugins and utilities in oh-my-zsh, but having them all in a single repo doesn't really scale well. And I admire robbyrussell's efforts for reviewing and merging the gigantic number of pull requests the project gets. We need a better way of plugin management. This was discussed on [a][1] [few][2] [issues][3], but it doesn't look like there was any progress made. So, I'm trying to start this off with Antigen, hoping to better this situation. Please note that I'm by no means a zsh or any shell script expert (far from it). [1]: https://github.com/robbyrussell/oh-my-zsh/issues/465 [2]: https://github.com/robbyrussell/oh-my-zsh/issues/377 [3]: https://github.com/robbyrussell/oh-my-zsh/issues/1014 Inspired by vundle, Antigen can pull oh-my-zsh style plugins from various github repositories. You are not limited to use plugins from the oh-my-zsh repository only and you don't need to maintain your own fork and pull from upstream every now and then. I actually encourage you to grab plugins and scripts from various sources, straight from the authors, before they even submit it to oh-my-zsh as a pull request. Antigen also lets you switch the prompt theme with one command, just like that antigen theme candy and your prompt is changed, just for this session of course (unless you put this line in your `.zshrc`). ### Helping out We are always looking for new contributors! We have a number of issues marked as ["Help wanted"][Help wanted] that are good places to jump in and get started. Take a look at our [Roadmap][] to see future projects and discuss ideas. Please be sure to check out our [Contributing guidelines][] to understand our workflow, and our [Coding conventions][]. ### Feedback Any comments/suggestions/feedback is truly welcome. Please say hello to us on [Gitter][]. Or open an issue to discuss something (anything!) about the project ;). ### Articles There are many articles written by Antigen users out there. Be sure to check them out in the [Articles][Articles] page. ### Plugins and Alternatives The [awesome-zsh-plugins][] list is a directory of plugins, themes and alternatives that you may find useful. [Vundle]: https://github.com/gmarik/vundle [awesome-zsh-plugins]: https://github.com/unixorn/awesome-zsh-plugins [wild]: https://github.com/zsh-users/antigen/wiki/In-the-wild [oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh [issue]: https://github.com/zsh-users/antigen/issues [license]: http://mit.sharats.me [contributing]: https://github.com/zsh-users/antigen/wiki/Contributing [wiki]: https://github.com/zsh-users/antigen/wiki [Commands]: https://github.com/zsh-users/antigen/wiki/Commands [Installation]: https://github.com/zsh-users/antigen/wiki/Installation [Configuration]: https://github.com/zsh-users/antigen/wiki/Configuration [Show off]: https://github.com/zsh-users/antigen/wiki/Show-off [Help wanted]: https://github.com/zsh-users/antigen/issues?q=is%3Aissue+is%3Aopen+label%3A%22Help+wanted%22 [Roadmap]: https://trello.com/b/P0xrGgfT/antigen [Contributing guidelines]: https://github.com/zsh-users/antigen/wiki/Contributing [Coding conventions]: https://github.com/zsh-users/antigen/wiki/Styleguide [Gitter]: https://gitter.im/antigen-zsh/develop [Articles]: https://github.com/zsh-users/antigen/wiki/Articles antigen-2.2.3/VERSION000066400000000000000000000000071322326672200142150ustar00rootroot00000000000000v2.2.3 antigen-2.2.3/antigen.png000066400000000000000000000140321322326672200153030ustar00rootroot00000000000000PNG  IHDR\rfIDATx^흍-7"08p~/ G`!C>-&9Ɲu`<ޣ_͔Q4MMA=L iP 0o|m0oho0Lbɓ) 260ltm2,`g>MV ^9%b aȿ>O+f1lpטq6R܀m4y+`ê]Hv6?;4MҊR PiaSkg ܀emZrc;)(z@9$gr6=`̼C4M,x#;2ӰO!պ c8o<{G~|) Ŏ4Mi]ҍB<h e7 zΞ((Y?R q2z.`ĬCV0 ֍O,شz?yY Pmo:B+ְF.o(;|}1S\ #p3p,}{􎒣(8o=ctJm[{n}#+30 `pjmYmS8_ D |l5RHYP殽T,㨿 >(?@*l?PKvb> cCy ` Sm(:LbL]QLZ@ᶭŋBN9p~ez K N"dmmY`!*Y[xIiY Rm8Y p(hM l%tS|ˮG4k u=n#<0- !0v=to[~/11%Qenq2SF@ߣ]f@JْU$^*>Vk +-#7FG`G_LH|{׷ g_V]osN˒i%'`η j78y5/Mu\H+`NV[AbnhmpFN?:B(`Wv|׏v*16y~"_E}{B9\URIrRd@5dXS#*Wck](Hl[s!ɣ.qK2WWR|M~9e[PYuj+NϸY"2*?UO@Z_bۯ 旀LoΉ@_ JF#ہX?ze ys`bқ2$=]Ō7Z,'퓲*fUar !*KXJ)FFy,ҠRb0oD )s `';oU.`ܨ':$Nj[7cgM;#{z5P<[}\ΤvoS5j{p0VNy$ q|gd lv`?A@9"n@Ʉl' &ߍw4 gߢ,%.=`^Sd=yn_nnbols*Z$kG_5jsۀKUU@y?*BEf0`@BxA WΣ{rǝnP˱IH\SS=4=׬]-Sp]SI0vZ v]vְ X B.]Ug^x&{SlR)4Mj*EP rJ|PbX"8ZuOիvRE|FFB 9}MdS8x>/R [8`.O>I5UPMdD]?PZIƐT@ǣh3JdPbOK$2jX*6VrP@Ez;&dPP b <-_[WߤFFbzECPM@s8HJ>钣2(s ʉ򷫿ZlH bF`c䶎^2"ekz}x'.{ ]O_:wDPvX+ud]&ZWeGZPCiȟr&0z MEd~@DմKy=4MuPw8T:s7@ I:O~'pp'V@qPy?c !Ƙ]գm濓XMTMOuw7Zn>#:)/M;iM&{%UV=~6 d0 l nV;=PD+6bMX,7٭fj+?[ `ܜ`F\)7Vt'@\ ߪ~rwg+'8V}%V l4!d' Gly;vͧV rPUw5S2_RG4!@|T%U@C-x եRJc^Wwms *Ĭ4.EaNl19_!{9ڛmΕ9 kߚ*ϊO *+~] ӿ*Trz,4,K= +۔M~U]ה"%අNJ_]q 6_ ݿ]J?N1~Öóʷ( ORi.ED(wtʙ#h@oOo)`S{ êТ9-<;}) unU06v@ٻcIκS AV\*%HLW%sK*iǃ1/Nrr*ҞH 3 Ek.*@%DbeUߗ[hIAoUZ1{`%?Vj'!)`-Xn  ؗsG#;djmuu -%?O GV+O)mr+~+ijsUp9B`1%ΎjV+SY1@^I"|/ArxDHK+:Cbţ}$CɳE'Fv_"޸!%:|}V7,=7$SK?rY<.[t@7Q{ګHRpkW׾#[>Yfvn@?F&_mΣ*/qA(fќ`oYڙ& 8V%Ʃy890S4?.dP_( p5[p WamgQhٿ_{`OPrU:=~{ߏ񒝃GOnqm3?-'x/(>l,ߏx9KMB_/- 1}`; ?2Po/=>'G0>l+h`WLosWg#A~9П=zQqP۱[hS>N _?fFGU ߵ*=famx=`G} 0h$G#+^y˵WI`_7}7ra6 ~ws" Q Ppw+,=fVczud~y6':ϻtwS;5؜qcf8 ̳=2(+=eOqʜ1≿39gᅱ[)9{ӄM l"Kk(6۰{@iF{q}N\_1 b>ʡpFiE)(ٴ\jwe}va/={խ:?=ہIO68JUZ nIGZhlq>p Tmqb |7 r7~iD MϮ K@2ٷ?}2$} b> rѳi>:!0y V@Vda [O4WҏL1|6]|qh%O m0 cx )<S 003P @``g@ 2 LC@d .PӳIENDB`antigen-2.2.3/antigen.zsh000066400000000000000000000001131322326672200153160ustar00rootroot00000000000000_ANTIGEN_INSTALL_DIR=${0:A:h} source $_ANTIGEN_INSTALL_DIR/bin/antigen.zsh antigen-2.2.3/bin/000077500000000000000000000000001322326672200137205ustar00rootroot00000000000000antigen-2.2.3/bin/antigen.zsh000066400000000000000000001630331322326672200161010ustar00rootroot00000000000000###################################################################### # This file was autogenerated by `make`. Do not edit it directly! ###################################################################### # Antigen: A simple plugin manager for zsh # Authors: Shrikant Sharat Kandula # and Contributors # Homepage: http://antigen.sharats.me # License: MIT License zmodload zsh/parameter autoload -U is-at-least # While boot.zsh is part of the ext/cache functionallity it may be disabled # with ANTIGEN_CACHE flag, and it's always compiled with antigen.zsh if [[ $ANTIGEN_CACHE != false ]]; then ANTIGEN_CACHE="${ANTIGEN_CACHE:-${ADOTDIR:-$HOME/.antigen}/init.zsh}" ANTIGEN_RSRC="${ANTIGEN_RSRC:-${ADOTDIR:-$HOME/.antigen}/.resources}" # It may not be necessary to check ANTIGEN_AUTO_CONFIG. if [[ $ANTIGEN_AUTO_CONFIG != false && -f $ANTIGEN_RSRC ]]; then # Check the list of files for configuration changes (uses -nt comp) ANTIGEN_CHECK_FILES=$(cat $ANTIGEN_RSRC 2> /dev/null) ANTIGEN_CHECK_FILES=(${(@f)ANTIGEN_CHECK_FILES}) for config in $ANTIGEN_CHECK_FILES; do if [[ "$config" -nt "$config.zwc" ]]; then # Flag configuration file as newer { zcompile "$config" } &! # Kill cache file in order to force full loading (see a few lines below) [[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE" fi done fi # If there is a cache file do load from it if [[ -f $ANTIGEN_CACHE && ! $_ANTIGEN_CACHE_LOADED == true ]]; then # Wrap antigen in order to defer cache source until `antigen-apply` antigen() { if [[ $1 == "apply" ]]; then source "$ANTIGEN_CACHE" # Handle `antigen-init` command properly elif [[ $1 == "init" ]]; then source "$2" fi } # Do not continue loading antigen as cache bundle takes care of it. return 0 fi fi [[ -z "$_ANTIGEN_INSTALL_DIR" ]] && _ANTIGEN_INSTALL_DIR=${0:A:h} # Each line in this string has the following entries separated by a space # character. # , , , [[ $_ANTIGEN_CACHE_LOADED != true ]] && typeset -aU _ANTIGEN_BUNDLE_RECORD # Do not load anything if git is not available. if (( ! $+commands[git] )); then echo 'Antigen: Please install git to use Antigen.' >&2 return 1 fi # Used to defer compinit/compdef typeset -a __deferred_compdefs compdef () { __deferred_compdefs=($__deferred_compdefs "$*") } # A syntax sugar to avoid the `-` when calling antigen commands. With this # function, you can write `antigen-bundle` as `antigen bundle` and so on. antigen () { local cmd="$1" if [[ -z "$cmd" ]]; then echo 'Antigen: Please give a command to run.' >&2 return 1 fi shift if (( $+functions[antigen-$cmd] )); then "antigen-$cmd" "$@" return $? else echo "Antigen: Unknown command: $cmd" >&2 return 1 fi } # Returns the bundle's git revision # # Usage # -antigen-bundle-rev bundle-name [is_local_clone] # # Returns # Bundle rev-parse output (branch name or short ref name) -antigen-bundle-rev () { local bundle=$1 local is_local_clone=$2 local bundle_path=$bundle # Get bunde path inside $ADOTDIR if bundle was effectively cloned if [[ "$is_local_clone" == "true" ]]; then bundle_path=$(-antigen-get-clone-dir $bundle) fi local ref ref=$(git --git-dir="$bundle_path/.git" rev-parse --abbrev-ref '@' 2>/dev/null) # Avoid 'HEAD' when in detached mode if [[ $ref == "HEAD" ]]; then ref=$(git --git-dir="$bundle_path/.git" describe --tags --exact-match 2>/dev/null \ || git --git-dir="$bundle_path/.git" rev-parse --short '@' 2>/dev/null || "-") fi echo $ref } # Usage: # -antigen-bundle-short-name "https://github.com/user/repo.git[|*]" "[branch/name]" # Returns: # user/repo@branch/name -antigen-bundle-short-name () { local bundle_name="${1%|*}" local bundle_branch="$2" local match mbegin mend MATCH MBEGIN MEND [[ "$bundle_name" =~ '.*/(.*/.*).*$' ]] && bundle_name=$match[1] bundle_name="${bundle_name%.git*}" if [[ -n $bundle_branch ]]; then bundle_name="$bundle_name@$bundle_branch" fi echo $bundle_name } # Echo the bundle specs as in the record. The first line is not echoed since it # is a blank line. -antigen-echo-record () { echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} } # Filters _ANTIGEN_BUNDLE_RECORD for $1 # # Usage # -antigen-find-bundle example/bundle # # Returns # String if bundle is found -antigen-find-bundle () { echo $(-antigen-find-record $1 | cut -d' ' -f1) } # Filters _ANTIGEN_BUNDLE_RECORD for $1 # # Usage # -antigen-find-record example/bundle # # Returns # String if record is found -antigen-find-record () { local bundle=$1 if [[ $# -eq 0 ]]; then return 1 fi local record=${bundle/\|/\\\|} echo "${_ANTIGEN_BUNDLE_RECORD[(r)*$record*]}" } # Returns bundle names from _ANTIGEN_BUNDLE_RECORD # # Usage # -antigen-get-bundles [--short|--simple|--long] # # Returns # List of bundles installed -antigen-get-bundles () { local mode revision url bundle_name bundle_entry loc no_local_clone local record bundle make_local_clone mode=${1:-"--short"} for record in $_ANTIGEN_BUNDLE_RECORD; do bundle=(${(@s/ /)record}) url=$bundle[1] loc=$bundle[2] make_local_clone=$bundle[4] bundle_name=$(-antigen-bundle-short-name $url) case "$mode" in --short) # Only check revision for bundle with a requested branch if [[ $url == *\|* ]]; then revision=$(-antigen-bundle-rev $url $make_local_clone) else revision="master" fi if [[ $loc != '/' ]]; then bundle_name="$bundle_name ~ $loc" fi echo "$bundle_name @ $revision" ;; --simple) echo "$bundle_name" ;; --long) echo "$record" ;; esac done } # Usage: # -antigen-get-clone-dir "https://github.com/zsh-users/zsh-syntax-highlighting.git[|feature/branch]" # Returns: # $ANTIGEN_BUNDLES/zsh-users/zsh-syntax-highlighting[-feature-branch] -antigen-get-clone-dir () { local bundle="$1" local url="${bundle%|*}" local branch match mbegin mend MATCH MBEGIN MEND [[ "$bundle" =~ "\|" ]] && branch="${bundle#*|}" # Takes a repo url and mangles it, giving the path that this url will be # cloned to. Doesn't actually clone anything. local clone_dir="$ANTIGEN_BUNDLES" url=$(-antigen-bundle-short-name $url) # Suffix with branch/tag name [[ -n "$branch" ]] && url="$url-${branch//\//-}" url=${url//\*/x} echo "$clone_dir/$url" } # Returns bundles flagged as make_local_clone # # Usage # -antigen-cloned-bundles # # Returns # Bundle metadata -antigen-get-cloned-bundles() { -antigen-echo-record | awk '$4 == "true" {print $1}' | sort -u } # Returns a list of themes from a default library (omz) # # Usage # -antigen-get-themes # # Returns # List of themes by name -antigen-get-themes () { local library='robbyrussell/oh-my-zsh' local bundle=$(-antigen-find-bundle $library) if [[ -n "$bundle" ]]; then local dir=$(-antigen-get-clone-dir $ANTIGEN_DEFAULT_REPO_URL) echo $(ls $dir/themes/ | eval "$_ANTIGEN_GREP_COMMAND '.zsh-theme$'" | sed 's/.zsh-theme//') fi return 0 } # This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell. # # Usage # -antigen-interactive-mode # # Returns # Either true or false depending if we are running in interactive mode -antigen-interactive-mode () { WARN "-antigen-interactive-mode: $ZSH_EVAL_CONTEXT \$_ANTIGEN_INTERACTIVE = $_ANTIGEN_INTERACTIVE" if [[ $_ANTIGEN_INTERACTIVE != "" ]]; then [[ $_ANTIGEN_INTERACTIVE == true ]]; return fi [[ "$ZSH_EVAL_CONTEXT" == toplevel* || "$ZSH_EVAL_CONTEXT" == cmdarg* ]]; } # Parses and retrieves a remote branch given a branch name. # # If the branch name contains '*' it will retrieve remote branches # and try to match against tags and heads, returning the latest matching. # # Usage # -antigen-parse-branch https://github.com/user/repo.git x.y.z # # Returns # Branch name -antigen-parse-branch () { local url="$1" branch="$2" branches local match mbegin mend MATCH MBEGIN MEND if [[ "$branch" =~ '\*' ]]; then branches=$(git ls-remote --tags -q "$url" "$branch"|cut -d'/' -f3|sort -n|tail -1) # There is no --refs flag in git 1.8 and below, this way we # emulate this flag -- also git 1.8 ref order is undefined. branch=${${branches#*/*/}%^*} # Why you are like this? fi echo $branch } -antigen-update-repos () { local repo bundle url target local log=/tmp/antigen-v2-migrate.log echo "It seems you have bundles cloned with Antigen v1.x." echo "We'll try to convert directory structure to v2." echo echo -n "Moving bundles to '\$ADOTDIR/bundles'... " # Migrate old repos -> bundles local errors=0 for repo in $ADOTDIR/repos/*; do bundle=${repo/$ADOTDIR\/repos\//} bundle=${bundle//-SLASH-/\/} bundle=${bundle//-COLON-/\:} bundle=${bundle//-STAR-/\*} url=${bundle//-PIPE-/\|} target=$(-antigen-get-clone-dir $url) mkdir -p "${target:A:h}" echo " ---> ${repo/$ADOTDIR\/} -> ${target/$ADOTDIR\/}" | tee > $log mv "$repo" "$target" &> $log if [[ $? != 0 ]]; then echo "Failed to migrate '$repo'!." errors+=1 fi done if [[ $errors == 0 ]]; then echo "Done." else echo "An error ocurred!" fi echo if [[ "$(ls -A $ADOTDIR/repos | wc -l | xargs)" == 0 ]]; then echo "You can safely remove \$ADOTDIR/repos." else echo "Some bundles couldn't be migrated. See \$ADOTDIR/repos." fi echo if [[ $errors == 0 ]]; then echo "Bundles migrated successfuly." rm $log else echo "Some errors occured. Review migration log in '$log'." fi antigen-reset } # Ensure that a clone exists for the given repo url and branch. If the first # argument is `update` and if a clone already exists for the given repo # and branch, it is pull-ed, i.e., updated. # # This function expects three arguments in order: # - 'url=' # - 'update=true|false' # - 'verbose=true|false' # # Returns true|false Whether cloning/pulling was succesful -antigen-ensure-repo () { # Argument defaults. Previously using ${1:?"missing url argument"} format # but it seems to mess up with cram if (( $# < 1 )); then echo "Antigen: Missing url argument." return 1 fi # The url. No sane default for this, so just empty. local url=$1 # Check if we have to update. local update=${2:-false} # Verbose output. local verbose=${3:-false} shift $# # Get the clone's directory as per the given repo url and branch. local clone_dir=$(-antigen-get-clone-dir $url) if [[ -d "$clone_dir" && $update == false ]]; then return true fi # A temporary function wrapping the `git` command with repeated arguments. --plugin-git () { (\cd -q "$clone_dir" && eval ${ANTIGEN_CLONE_ENV} git --git-dir="$clone_dir/.git" --no-pager "$@" &>>! $ANTIGEN_LOG) } local success=false # If its a specific branch that we want, checkout that branch. local branch="master" # TODO FIX THIS if [[ $url == *\|* ]]; then branch="$(-antigen-parse-branch ${url%|*} ${url#*|})" fi if [[ ! -d $clone_dir ]]; then eval ${ANTIGEN_CLONE_ENV} git clone ${=ANTIGEN_CLONE_OPTS} --branch "$branch" -- "${url%|*}" "$clone_dir" &>> $ANTIGEN_LOG success=$? elif $update; then # Save current revision. local old_rev="$(--plugin-git rev-parse HEAD)" # Pull changes if update requested. --plugin-git checkout "$branch" --plugin-git pull origin "$branch" success=$? # Update submodules. --plugin-git submodule update ${=ANTIGEN_SUBMODULE_OPTS} # Get the new revision. local new_rev="$(--plugin-git rev-parse HEAD)" fi if [[ -n $old_rev && $old_rev != $new_rev ]]; then echo Updated from $old_rev[0,7] to $new_rev[0,7]. if $verbose; then --plugin-git log --oneline --reverse --no-merges --stat '@{1}..' fi fi # Remove the temporary git wrapper function. unfunction -- --plugin-git return $success } # Helper function: Same as `$1=$2`, but will only happen if the name # specified by `$1` is not already set. -antigen-set-default () { local arg_name="$1" local arg_value="$2" eval "test -z \"\$$arg_name\" && typeset -g $arg_name='$arg_value'" } -antigen-env-setup () { typeset -gU fpath path # Pre-startup initializations. -antigen-set-default ANTIGEN_OMZ_REPO_URL \ https://github.com/robbyrussell/oh-my-zsh.git -antigen-set-default ANTIGEN_PREZTO_REPO_URL \ https://github.com/sorin-ionescu/prezto.git -antigen-set-default ANTIGEN_DEFAULT_REPO_URL $ANTIGEN_OMZ_REPO_URL # Default Antigen directory. -antigen-set-default ADOTDIR $HOME/.antigen [[ ! -d $ADOTDIR ]] && mkdir -p $ADOTDIR # Defaults bundles directory. -antigen-set-default ANTIGEN_BUNDLES $ADOTDIR/bundles # If there is no bundles directory, create it. if [[ ! -d $ANTIGEN_BUNDLES ]]; then mkdir -p $ANTIGEN_BUNDLES # Check for v1 repos directory, transform it to v2 format. [[ -d $ADOTDIR/repos ]] && -antigen-update-repos fi -antigen-set-default ANTIGEN_COMPDUMP "${ADOTDIR:-$HOME}/.zcompdump" -antigen-set-default ANTIGEN_COMPINIT_OPTS "-i" -antigen-set-default ANTIGEN_LOG /dev/null # CLONE_OPTS uses ${=CLONE_OPTS} expansion so don't use spaces # for arguments that can be passed as `--key=value`. -antigen-set-default ANTIGEN_CLONE_ENV "GIT_TERMINAL_PROMPT=0" -antigen-set-default ANTIGEN_CLONE_OPTS "--single-branch --recursive --depth=1" -antigen-set-default ANTIGEN_SUBMODULE_OPTS "--recursive --depth=1" # Complain when a bundle is already installed. -antigen-set-default _ANTIGEN_WARN_DUPLICATES true # Compatibility with oh-my-zsh themes. -antigen-set-default _ANTIGEN_THEME_COMPAT true -antigen-set-default _ANTIGEN_GREP_COMMAND 'GREP_OPTIONS= command grep ' # Add default built-in extensions to load at start up -antigen-set-default _ANTIGEN_BUILTIN_EXTENSIONS 'lock parallel defer cache' # Setup antigen's own completion. if -antigen-interactive-mode; then TRACE "Gonna create compdump file @ env-setup" COMPDUMP autoload -Uz compinit compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP" compdef _antigen antigen else (( $+functions[antigen-ext-init] )) && antigen-ext-init fi } # Load a given bundle by sourcing it. # # The function also modifies fpath to add the bundle path. # # Usage # -antigen-load "bundle-url" ["location"] ["make_local_clone"] ["btype"] # # Returns # Integer. 0 if success 1 if an error ocurred. -antigen-load () { local bundle list typeset -A bundle; bundle=($@) typeset -Ua list; list=() local location="${bundle[dir]}/${bundle[loc]}" # Prioritize location when given. if [[ -f "${location}" ]]; then list=(${location}) else # Directory locations must be suffixed with slash location="$location/" # Prioritize theme with antigen-theme if [[ ${bundle[btype]} == "theme" ]]; then list=(${location}*.zsh-theme(N[1])) fi # Common frameworks if [[ $#list == 0 ]]; then # dot-plugin, init and functions support (omz, prezto) # Support prezto function loading. See https://github.com/zsh-users/antigen/pull/428 list=(${location}*.plugin.zsh(N[1]) ${location}init.zsh(N[1]) ${location}/functions(N[1])) fi # Default to zsh and sh if [[ $#list == 0 ]]; then list=(${location}*.zsh(N) ${location}*.sh(N)) fi fi -antigen-load-env ${(kv)bundle} # If there is any sourceable try to load it if ! -antigen-load-source "${list[@]}" && [[ ! -d ${location} ]]; then return 1 fi return 0 } -antigen-load-env () { typeset -A bundle; bundle=($@) local location=${bundle[dir]}/${bundle[loc]} # Load to path if there is no sourceable if [[ -d ${location} ]]; then PATH="$PATH:${location:A}" fpath+=("${location:A}") return fi PATH="$PATH:${location:A:h}" fpath+=("${location:A:h}") } -antigen-load-source () { typeset -a list list=($@) local src match mbegin mend MATCH MBEGIN MEND # Return error when we're given an empty list if [[ $#list == 0 ]]; then return 1 fi # Using a for rather than `source $list` as we need to check for zsh-themes # In order to create antigen-compat file. This is only needed for interactive-mode # theme switching, for static loading (cache) there is no need. for src in $list; do if [[ $_ANTIGEN_THEME_COMPAT == true && -f "$src" && "$src" == *.zsh-theme* ]]; then local compat="${src:A}.antigen-compat" echo "# Generated by Antigen. Do not edit!" >! "$compat" cat $src | sed -Ee '/\{$/,/^\}/!{ s/^local // }' >>! "$compat" src="$compat" fi if ! source "$src" 2>/dev/null; then return 1 fi done } # Usage: # -antigen-parse-args output_assoc_arr -antigen-parse-args () { local argkey key value index=0 args local match mbegin mend MATCH MBEGIN MEND local var=$1 shift # Bundle spec arguments' default values. #setopt XTRACE VERBOSE builtin typeset -A args args[url]="$ANTIGEN_DEFAULT_REPO_URL" #unsetopt XTRACE VERBOSE args[loc]=/ args[make_local_clone]=true args[btype]=plugin #args[branch]= # commented out as it may cause assoc array kv mismatch while [[ $# -gt 0 ]]; do argkey="${1%\=*}" key="${argkey//--/}" value="${1#*=}" case "$argkey" in --url|--loc|--branch|--btype) if [[ "$value" == "$argkey" ]]; then printf "Required argument for '%s' not provided.\n" $key >&2 else args[$key]="$value" fi ;; --no-local-clone) args[make_local_clone]=false ;; --*) printf "Unknown argument '%s'.\n" $key >&2 ;; *) value=$key case $index in 0) key=url local domain="" local url_path=$value # Full url with protocol or ssh github url (github.com:org/repo) if [[ "$value" =~ "://" || "$value" =~ ":" ]]; then if [[ "$value" =~ [@.][^/:]+[:]?[0-9]*[:/]?(.*)@?$ ]]; then url_path=$match[1] domain=${value/$url_path/} fi fi if [[ "$url_path" =~ '@' ]]; then args[branch]="${url_path#*@}" value="$domain${url_path%@*}" else value="$domain$url_path" fi ;; 1) key=loc ;; esac let index+=1 args[$key]="$value" ;; esac shift done # Check if url is just the plugin name. Super short syntax. if [[ "${args[url]}" != */* ]]; then case "$ANTIGEN_DEFAULT_REPO_URL" in "$ANTIGEN_OMZ_REPO_URL") args[loc]="plugins/${args[url]}" ;; "$ANTIGEN_PREZTO_REPO_URL") args[loc]="modules/${args[url]}" ;; *) args[loc]="${args[url]}" ;; esac args[url]="$ANTIGEN_DEFAULT_REPO_URL" fi # Resolve the url. # Expand short github url syntax: `username/reponame`. local url="${args[url]}" if [[ $url != git://* && $url != https://* && $url != http://* && $url != ssh://* && $url != /* && $url != *github.com:*/* ]]; then url="https://github.com/${url%.git}.git" fi args[url]="$url" # Ignore local clone if url given is not a git directory if [[ ${args[url]} == /* && ! -d ${args[url]}/.git ]]; then args[make_local_clone]=false fi # Add the branch information to the url if we need to create a local clone. # Format url in bundle-metadata format: url[|branch] if [[ ! -z "${args[branch]}" && ${args[make_local_clone]} == true ]]; then args[url]="${args[url]}|${args[branch]}" fi # Add the theme extension to `loc`, if this is a theme, but only # if it's especified, ie, --loc=theme-name, in case when it's not # specified antige-load-list will look for *.zsh-theme files if [[ ${args[btype]} == "theme" && ${args[loc]} != "/" && ${args[loc]} != *.zsh-theme ]]; then args[loc]="${args[loc]}.zsh-theme" fi local name="${args[url]%|*}" local branch="${args[branch]}" # Extract bundle name. if [[ "$name" =~ '.*/(.*/.*).*$' ]]; then name="${match[1]}" fi name="${name%.git*}" # Format bundle name with optional branch. if [[ -n "${branch}" ]]; then args[name]="${name}@${branch}" else args[name]="${name}" fi # Format bundle path. if [[ ${args[make_local_clone]} == true ]]; then local bpath="$name" # Suffix with branch/tag name if [[ -n "$branch" ]]; then # bpath is in the form of repo/name@version => repo/name-version # Replace / with - in bundle branch. local bbranch=${branch//\//-} # If branch/tag is semver-like do replace * by x. bbranch=${bbranch//\*/x} bpath="${name}-${bbranch}" fi bpath="$ANTIGEN_BUNDLES/$bpath" args[dir]="${(qq)bpath}" else # if it's local then path is just the "url" argument, loc remains the same args[dir]=${args[url]} fi # Escape url and branch (may contain semver-like and pipe characters) args[url]="${(qq)args[url]}" if [[ -n "${args[branch]}" ]]; then args[branch]="${(qq)args[branch]}" fi # Escape bundle name (may contain semver-like characters) args[name]="${(qq)args[name]}" eval "${var}=(${(kv)args})" return 0 } # Updates revert-info data with git hash. # # This does process only cloned bundles. # # Usage # -antigen-revert-info # # Returns # Nothing. Generates/updates $ADOTDIR/revert-info. -antigen-revert-info() { local url # Update your bundles, i.e., `git pull` in all the plugin repos. date >! $ADOTDIR/revert-info -antigen-get-cloned-bundles | while read url; do local clone_dir="$(-antigen-get-clone-dir "$url")" if [[ -d "$clone_dir" ]]; then (echo -n "$clone_dir:" \cd -q "$clone_dir" git rev-parse HEAD) >> $ADOTDIR/revert-info fi done } -antigen-use-oh-my-zsh () { typeset -g ZSH ZSH_CACHE_DIR ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_OMZ_REPO_URL if [[ -z "$ZSH" ]]; then ZSH="$(-antigen-get-clone-dir "$ANTIGEN_DEFAULT_REPO_URL")" fi if [[ -z "$ZSH_CACHE_DIR" ]]; then ZSH_CACHE_DIR="$ZSH/cache/" fi antigen-bundle --loc=lib } -antigen-use-prezto () { ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_PREZTO_REPO_URL antigen-bundle "$ANTIGEN_PREZTO_REPO_URL" } # Initialize completion antigen-apply () { LOG "Called antigen-apply" # Load the compinit module. This will readefine the `compdef` function to # the one that actually initializes completions. TRACE "Gonna create compdump file @ apply" COMPDUMP autoload -Uz compinit compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP" # Apply all `compinit`s that have been deferred. local cdef for cdef in "${__deferred_compdefs[@]}"; do compdef "$cdef" done { zcompile "$ANTIGEN_COMPDUMP" } &! unset __deferred_compdefs } # Syntaxes # antigen-bundle [=/] # Keyword only arguments: # branch - The branch of the repo to use for this bundle. antigen-bundle () { TRACE "Called antigen-bundle with $@" BUNDLE if [[ -z "$1" ]]; then printf "Antigen: Must provide a bundle url or name.\n" >&2 return 1 fi builtin typeset -A bundle; -antigen-parse-args 'bundle' ${=@} if [[ -z ${bundle[btype]} ]]; then bundle[btype]=bundle fi local record="${bundle[url]} ${bundle[loc]} ${bundle[btype]} ${bundle[make_local_clone]}" if [[ $_ANTIGEN_WARN_DUPLICATES == true && ! ${_ANTIGEN_BUNDLE_RECORD[(I)$record]} == 0 ]]; then printf "Seems %s is already installed!\n" ${bundle[name]} return 1 fi # Clone bundle if we haven't done do already. if [[ ! -d "${bundle[dir]}" ]]; then if ! -antigen-bundle-install ${(kv)bundle}; then return 1 fi fi # Load the plugin. if ! -antigen-load ${(kv)bundle}; then TRACE "-antigen-load failed to load ${bundle[name]}" BUNDLE printf "Antigen: Failed to load %s.\n" ${bundle[btype]} >&2 return 1 fi # Only add it to the record if it could be installed and loaded. _ANTIGEN_BUNDLE_RECORD+=("$record") } # # Usage: # -antigen-bundle-install # Returns: # 1 if it fails to install bundle -antigen-bundle-install () { typeset -A bundle; bundle=($@) # Ensure a clone exists for this repo, if needed. # Get the clone's directory as per the given repo url and branch. local bpath="${bundle[dir]}" # Clone if it doesn't already exist. local start=$(date +'%s') printf "Installing %s... " "${bundle[name]}" if ! -antigen-ensure-repo "${bundle[url]}"; then # Return immediately if there is an error cloning TRACE "-antigen-bundle-instal failed to clone ${bundle[url]}" BUNDLE printf "Error! Activate logging and try again.\n" >&2 return 1 fi local took=$(( $(date +'%s') - $start )) printf "Done. Took %ds.\n" $took } antigen-bundles () { # Bulk add many bundles at one go. Empty lines and lines starting with a `#` # are ignored. Everything else is given to `antigen-bundle` as is, no # quoting rules applied. local line setopt localoptions no_extended_glob # See https://github.com/zsh-users/antigen/issues/456 eval "$_ANTIGEN_GREP_COMMAND '^[[:space:]]*[^[:space:]#]'" | while read line; do antigen-bundle ${=line%#*} done } # Cleanup unused repositories. antigen-cleanup () { local force=false if [[ $1 == --force ]]; then force=true fi if [[ ! -d "$ANTIGEN_BUNDLES" || -z "$(\ls -A "$ANTIGEN_BUNDLES")" ]]; then echo "You don't have any bundles." return 0 fi # Find directores in ANTIGEN_BUNDLES, that are not in the bundles record. typeset -a unused_clones clones local url record clone for record in $(-antigen-get-cloned-bundles); do url=${record% /*} clones+=("$(-antigen-get-clone-dir $url)") done for clone in $ANTIGEN_BUNDLES/*/*(/); do if [[ $clones[(I)$clone] == 0 ]]; then unused_clones+=($clone) fi done if [[ -z $unused_clones ]]; then echo "You don't have any unidentified bundles." return 0 fi echo 'You have clones for the following repos, but are not used.' echo "\n${(j:\n:)unused_clones}" if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then echo echo for clone in $unused_clones; do echo -n "Deleting clone \"$clone\"..." \rm -rf "$clone" echo ' done.' done else echo echo "Nothing deleted." fi } antigen-help () { antigen-version cat < [args] Commands: apply Must be called in the zshrc after all calls to 'antigen bundle'. bundle Install and load a plugin. cache-gen Generate Antigen's cache with currently loaded bundles. cleanup Remove clones of repos not used by any loaded plugins. init Use caching to quickly load bundles. list List currently loaded plugins. purge Remove a bundle from the filesystem. reset Clean the generated cache. restore Restore plugin state from a snapshot file. revert Revert plugins to their state prior to the last time 'antigen update' was run. selfupdate Update antigen. snapshot Create a snapshot of all active plugin repos and save it to a snapshot file. update Update plugins. use Load a supported zsh pre-packaged framework. For further details and complete documentation, visit the project's page at 'http://antigen.sharats.me'. EOF } # Antigen command to load antigen configuration # # This method is slighlty more performing than using various antigen-* methods. # # Usage # Referencing an antigen configuration file: # # antigen-init "/path/to/antigenrc" # # or using HEREDOCS: # # antigen-init <&2 return 1 fi fi # Otherwise we expect it to be a heredoc eval "$_ANTIGEN_GREP_COMMAND '^[[:space:]]*[^[:space:]#]'" | while read -r line; do eval $line done } # List instaled bundles either in long (record), short or simple format. # # Usage # antigen-list [--short|--long|--simple] # # Returns # List of bundles antigen-list () { local format=$1 # List all currently installed bundles. if [[ -z $_ANTIGEN_BUNDLE_RECORD ]]; then echo "You don't have any bundles." >&2 return 1 fi -antigen-get-bundles $format } # Remove a bundle from filesystem # # Usage # antigen-purge example/bundle [--force] # # Returns # Nothing. Removes bundle from filesystem. antigen-purge () { local bundle=$1 local force=$2 if [[ $# -eq 0 ]]; then echo "Antigen: Missing argument." >&2 return 1 fi if -antigen-purge-bundle $bundle $force; then antigen-reset else return $? fi return 0 } # Remove a bundle from filesystem # # Usage # antigen-purge example/bundle [--force] # # Returns # Nothing. Removes bundle from filesystem. -antigen-purge-bundle () { local bundle=$1 local force=$2 local clone_dir="" local record="" local url="" local make_local_clone="" if [[ $# -eq 0 ]]; then echo "Antigen: Missing argument." >&2 return 1 fi # local keyword doesn't work on zsh <= 5.0.0 record=$(-antigen-find-record $bundle) if [[ ! -n "$record" ]]; then echo "Bundle not found in record. Try 'antigen bundle $bundle' first." >&2 return 1 fi url="$(echo "$record" | cut -d' ' -f1)" make_local_clone=$(echo "$record" | cut -d' ' -f4) if [[ $make_local_clone == "false" ]]; then echo "Bundle has no local clone. Will not be removed." >&2 return 1 fi clone_dir=$(-antigen-get-clone-dir "$url") if [[ $force == "--force" ]] || read -q "?Remove '$clone_dir'? (y/n) "; then # Need empty line after read -q [[ ! -n $force ]] && echo "" || echo "Removing '$clone_dir'."; rm -rf "$clone_dir" return $? fi return 1 } # Removes cache payload and metadata if available # # Usage # antigen-reset # # Returns # Nothing antigen-reset () { [[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE" "$ANTIGEN_CACHE.zwc" 1> /dev/null [[ -f "$ANTIGEN_RSRC" ]] && rm -f "$ANTIGEN_RSRC" 1> /dev/null [[ -f "$ANTIGEN_COMPDUMP" ]] && rm -f "$ANTIGEN_COMPDUMP" "$ANTIGEN_COMPDUMP.zwc" 1> /dev/null [[ -f "$ANTIGEN_LOCK" ]] && rm -f "$ANTIGEN_LOCK" 1> /dev/null echo 'Done. Please open a new shell to see the changes.' } antigen-restore () { local line if [[ $# == 0 ]]; then echo 'Please provide a snapshot file to restore from.' >&2 return 1 fi local snapshot_file="$1" # TODO: Before doing anything with the snapshot file, verify its checksum. # If it fails, notify this to the user and confirm if restore should # proceed. echo -n "Restoring from $snapshot_file..." sed -n '1!p' "$snapshot_file" | while read line; do local version_hash="${line%% *}" local url="${line##* }" local clone_dir="$(-antigen-get-clone-dir "$url")" if [[ ! -d $clone_dir ]]; then git clone "$url" "$clone_dir" &> /dev/null fi (\cd -q "$clone_dir" && git checkout $version_hash) &> /dev/null done echo ' done.' echo 'Please open a new shell to get the restored changes.' } # Reads $ADORDIR/revert-info and restores bundles' revision antigen-revert () { local line if [[ -f $ADOTDIR/revert-info ]]; then cat $ADOTDIR/revert-info | sed -n '1!p' | while read line; do local dir="$(echo "$line" | cut -d: -f1)" git --git-dir="$dir/.git" --work-tree="$dir" \ checkout "$(echo "$line" | cut -d: -f2)" 2> /dev/null done echo "Reverted to state before running -update on $( cat $ADOTDIR/revert-info | sed -n '1p')." else echo 'No revert information available. Cannot revert.' >&2 return 1 fi } # Update (with `git pull`) antigen itself. # TODO: Once update is finished, show a summary of the new commits, as a kind of # "what's new" message. antigen-selfupdate () { (\cd -q $_ANTIGEN_INSTALL_DIR if [[ ! ( -d .git || -f .git ) ]]; then echo "Your copy of antigen doesn't appear to be a git clone. " \ "The 'selfupdate' command cannot work in this case." return 1 fi local head="$(git rev-parse --abbrev-ref HEAD)" if [[ $head == "HEAD" ]]; then # If current head is detached HEAD, checkout to master branch. git checkout master fi git pull # TODO Should be transparently hooked by zcache antigen-reset &>> /dev/null ) } antigen-snapshot () { local snapshot_file="${1:-antigen-shapshot}" local urls url dir version_hash snapshot_content local -a bundles # The snapshot content lines are pairs of repo-url and git version hash, in # the form: # urls=$(-antigen-echo-record | awk '$4 == "true" {print $1}' | sort -u) for url in ${(f)urls}; do dir="$(-antigen-get-clone-dir "$url")" version_hash="$(\cd -q "$dir" && git rev-parse HEAD)" bundles+=("$version_hash $url"); done snapshot_content=${(j:\n:)bundles} { # The first line in the snapshot file is for metadata, in the form: # key='value'; key='value'; key='value'; # Where `key`s are valid shell variable names. # Snapshot version. Has no relation to antigen version. If the snapshot # file format changes, this number can be incremented. echo -n "version='1';" # Snapshot creation date+time. echo -n " created_on='$(date)';" # Add a checksum with the md5 checksum of all the snapshot lines. chksum() { (md5sum; test $? = 127 && md5) 2>/dev/null | cut -d' ' -f1 } local checksum="$(echo "$snapshot_content" | chksum)" unset -f chksum; echo -n " checksum='${checksum%% *}';" # A newline after the metadata and then the snapshot lines. echo "\n$snapshot_content" } > "$snapshot_file" } # Loads a given theme. # # Shares the same syntax as antigen-bundle command. # # Usage # antigen-theme zsh/theme[.zsh-theme] # # Returns # 0 if everything was succesfully antigen-theme () { local name=$1 result=0 record local match mbegin mend MATCH MBEGIN MEND if [[ -z "$1" ]]; then printf "Antigen: Must provide a theme url or name.\n" >&2 return 1 fi -antigen-theme-reset-hooks record=$(-antigen-find-record "theme") if [[ "$1" != */* && "$1" != --* ]]; then # The first argument is just a name of the plugin, to be picked up from # the default repo. antigen-bundle --loc=themes/$name --btype=theme else antigen-bundle "$@" --btype=theme fi result=$? # Remove a theme from the record if the following conditions apply: # - there was no error in bundling the given theme # - there is a theme registered # - registered theme is not the same as the current one if [[ $result == 0 && -n $record ]]; then # http://zsh-workers.zsh.narkive.com/QwfCWpW8/what-s-wrong-with-this-expression if [[ "$record" =~ "$@" ]]; then return $result else _ANTIGEN_BUNDLE_RECORD[$_ANTIGEN_BUNDLE_RECORD[(I)$record]]=() fi fi return $result } -antigen-theme-reset-hooks () { # This is only needed on interactive mode autoload -U add-zsh-hook is-at-least local hook # Clear out prompts PROMPT="" if [[ -n $RPROMPT ]]; then RPROMPT="" fi for hook in chpwd precmd preexec periodic; do add-zsh-hook -D "${hook}" "prompt_*" # common in omz themes add-zsh-hook -D "${hook}" "*_${hook}" add-zsh-hook -d "${hook}" "vcs_info" done } # Updates the bundles or a single bundle. # # Usage # antigen-update [example/bundle] # # Returns # Nothing. Performs a `git pull`. antigen-update () { local bundle=$1 url # Clear log :> $ANTIGEN_LOG # Update revert-info data -antigen-revert-info # If no argument is given we update all bundles if [[ $# -eq 0 ]]; then # Here we're ignoring all non cloned bundles (ie, --no-local-clone) -antigen-get-cloned-bundles | while read url; do -antigen-update-bundle $url done # TODO next minor version # antigen-reset else if -antigen-update-bundle $bundle; then # TODO next minor version # antigen-reset else return $? fi fi } # Updates a bundle performing a `git pull`. # # Usage # -antigen-update-bundle example/bundle # # Returns # Nothing. Performs a `git pull`. -antigen-update-bundle () { local bundle="$1" local record="" local url="" local make_local_clone="" local start=$(date +'%s') if [[ $# -eq 0 ]]; then printf "Antigen: Missing argument.\n" >&2 return 1 fi record=$(-antigen-find-record $bundle) if [[ ! -n "$record" ]]; then printf "Bundle not found in record. Try 'antigen bundle %s' first.\n" $bundle >&2 return 1 fi url="$(echo "$record" | cut -d' ' -f1)" make_local_clone=$(echo "$record" | cut -d' ' -f4) local branch="master" if [[ $url == *\|* ]]; then branch="$(-antigen-parse-branch ${url%|*} ${url#*|})" fi printf "Updating %s... " $(-antigen-bundle-short-name "$url" "$branch") if [[ $make_local_clone == "false" ]]; then printf "Bundle has no local clone. Will not be updated.\n" >&2 return 1 fi # update=true verbose=false if ! -antigen-ensure-repo "$url" true false; then printf "Error! Activate logging and try again.\n" >&2 return 1 fi local took=$(( $(date +'%s') - $start )) printf "Done. Took %ds.\n" $took } antigen-use () { if [[ $1 == oh-my-zsh ]]; then -antigen-use-oh-my-zsh elif [[ $1 == prezto ]]; then -antigen-use-prezto elif [[ $1 != "" ]]; then ANTIGEN_DEFAULT_REPO_URL=$1 antigen-bundle $@ else echo 'Usage: antigen-use ' >&2 echo 'Where is any one of the following:' >&2 echo ' * oh-my-zsh' >&2 echo ' * prezto' >&2 echo ' is the full url.' >&2 return 1 fi } antigen-version () { local extensions printf "Antigen %s (%s)\nRevision date: %s\n" "v2.2.3" "ff391b5" "2018-01-02 13:19:57 +0100" # Show extension information if any is available if (( $+functions[antigen-ext] )); then typeset -a extensions; extensions=($(antigen-ext-list)) if [[ $#extensions -gt 0 ]]; then printf "Extensions loaded: %s\n" ${(j:, :)extensions} fi fi } typeset -Ag _ANTIGEN_HOOKS; _ANTIGEN_HOOKS=() typeset -Ag _ANTIGEN_HOOKS_META; _ANTIGEN_HOOKS_META=() typeset -g _ANTIGEN_HOOK_PREFIX="-antigen-hook-" typeset -g _ANTIGEN_EXTENSIONS; _ANTIGEN_EXTENSIONS=() # -antigen-add-hook antigen-apply antigen-apply-hook replace # - Replaces hooked function with hook, do not call hooked function # - Return -1 to stop calling further hooks # -antigen-add-hook antigen-apply antigen-apply-hook pre (pre-call) # - By default it will call hooked function # -antigen-add-hook antigen-pply antigen-apply-hook post (post-call) # - Calls antigen-apply and then calls hook function # Usage: # -antigen-add-hook antigen-apply antigen-apply-hook ["replace"|"pre"|"post"] ["once"|"repeat"] antigen-add-hook () { local target="$1" hook="$2" type="$3" mode="${4:-repeat}" if (( ! $+functions[$target] )); then printf "Antigen: Function %s doesn't exist.\n" $target return 1 fi if (( ! $+functions[$hook] )); then printf "Antigen: Function %s doesn't exist.\n" $hook return 1 fi if [[ "${_ANTIGEN_HOOKS[$target]}" == "" ]]; then _ANTIGEN_HOOKS[$target]="${hook}" else _ANTIGEN_HOOKS[$target]="${_ANTIGEN_HOOKS[$target]}:${hook}" fi _ANTIGEN_HOOKS_META[$hook]="target $target type $type mode $mode called 0" # Do shadow for this function if there is none already local hook_function="${_ANTIGEN_HOOK_PREFIX}$target" if (( ! $+functions[$hook_function] )); then # Preserve hooked function eval "function ${_ANTIGEN_HOOK_PREFIX}$(functions -- $target)" # Create hook, call hook-handler to further process hook functions eval "function $target () { noglob -antigen-hook-handler $target \$@ return \$? }" fi return 0 } # Private function to handle multiple hooks in a central point. -antigen-hook-handler () { local target="$1" args hook called local hooks meta shift typeset -a args; args=(${@}) typeset -a pre_hooks replace_hooks post_hooks; typeset -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]}) typeset -A meta; for hook in $hooks; do meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]}) if [[ ${meta[mode]} == "once" && ${meta[called]} == 1 ]]; then WARN "Ignoring hook due to mode ${meta[mode]}: $hook" continue fi let called=${meta[called]}+1 meta[called]=$called _ANTIGEN_HOOKS_META[$hook]="${(kv)meta}" WARN "Updated meta: "${(kv)meta} case "${meta[type]}" in "pre") pre_hooks+=($hook) ;; "replace") replace_hooks+=($hook) ;; "post") post_hooks+=($hook) ;; esac done WARN "Processing hooks: ${hooks}" for hook in $pre_hooks; do WARN "Pre hook:" $hook $args noglob $hook $args [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret done # A replace hook will return inmediately local replace_hook=0 ret=0 for hook in $replace_hooks; do replace_hook=1 # Should not be needed if `antigen-remove-hook` removed unneeded hooks. if (( $+functions[$hook] )); then WARN "Replace hook:" $hook $args noglob $hook $args [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret fi done if [[ $replace_hook == 0 ]]; then WARN "${_ANTIGEN_HOOK_PREFIX}$target $args" noglob ${_ANTIGEN_HOOK_PREFIX}$target $args ret=$? else WARN "Replaced hooked function." fi for hook in $post_hooks; do WARN "Post hook:" $hook $args noglob $hook $args [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret done LOG "Return from hook ${target} with ${ret}" return $ret } # Usage: # -antigen-remove-hook antigen-apply-hook antigen-remove-hook () { local hook="$1" typeset -A meta; meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]}) local target="${meta[target]}" local -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]}) # Remove registered hook if [[ $#hooks > 0 ]]; then hooks[$hooks[(I)$hook]]=() fi _ANTIGEN_HOOKS[${target}]="${(j|:|)hooks}" if [[ $#hooks == 0 ]]; then # Destroy base hook eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)" if (( $+functions[${_ANTIGEN_HOOK_PREFIX}$target] )); then unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" fi fi unfunction -- $hook 2> /dev/null } # Remove all defined hooks. -antigen-reset-hooks () { local target for target in ${(k)_ANTIGEN_HOOKS}; do # Release all hooked functions eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)" unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" 2> /dev/null done _ANTIGEN_HOOKS=() _ANTIGEN_HOOKS_META=() _ANTIGEN_EXTENSIONS=() } # Initializes an extension # Usage: # antigen-ext ext-name antigen-ext () { local ext=$1 local func="-antigen-$ext-init" if (( $+functions[$func] && $_ANTIGEN_EXTENSIONS[(I)$ext] == 0 )); then eval $func local ret=$? WARN "$func return code was $ret" if (( $ret == 0 )); then LOG "LOADED EXTENSION $ext" EXT -antigen-$ext-execute && _ANTIGEN_EXTENSIONS+=($ext) else WARN "IGNORING EXTENSION $func" EXT return 1 fi else printf "Antigen: No extension defined or already loaded: %s\n" $func >&2 return 1 fi } # List installed extensions # Usage: # antigen ext-list antigen-ext-list () { echo $_ANTIGEN_EXTENSIONS } # Initializes built-in extensions # Usage: # antigen-ext-init antigen-ext-init () { # Initialize extensions. unless in interactive mode. local ext for ext in ${(s/ /)_ANTIGEN_BUILTIN_EXTENSIONS}; do # Check if extension is loaded before intializing it (( $+functions[-antigen-$ext-init] )) && antigen-ext $ext done } # Initialize defer lib -antigen-defer-init () { typeset -ga _DEFERRED_BUNDLE; _DEFERRED_BUNDLE=() if -antigen-interactive-mode; then return 1 fi } -antigen-defer-execute () { # Hooks antigen-bundle in order to defer its execution. antigen-bundle-defer () { _DEFERRED_BUNDLE+=("${(j: :)${@}}") return -1 # Stop right there } antigen-add-hook antigen-bundle antigen-bundle-defer replace # Hooks antigen-apply in order to release hooked functions antigen-apply-defer () { WARN "Defer pre-apply" DEFER PRE-APPLY antigen-remove-hook antigen-bundle-defer # Process all deferred bundles. local bundle for bundle in ${_DEFERRED_BUNDLE[@]}; do LOG "Processing deferred bundle: ${bundle}" DEFER antigen-bundle $bundle done unset _DEFERRED_BUNDLE } antigen-add-hook antigen-apply antigen-apply-defer pre once } # Initialize lock lib -antigen-lock-init () { # Default lock path. -antigen-set-default ANTIGEN_LOCK $ADOTDIR/.lock typeset -g _ANTIGEN_LOCK_PROCESS=false # Use env variable to determine if we should load this extension -antigen-set-default ANTIGEN_MUTEX true # Set ANTIGEN_MUTEX to false to avoid loading this extension if [[ $ANTIGEN_MUTEX == true ]]; then return 0; fi # Do not use mutex return 1; } -antigen-lock-execute () { # Hook antigen command in order to check/create a lock file. # This hook is only run once then releases itself. antigen-lock () { LOG "antigen-lock called" # If there is a lock set up then we won't process anything. if [[ -f $ANTIGEN_LOCK ]]; then # Set up flag do the message is not repeated for each antigen-* command [[ $_ANTIGEN_LOCK_PROCESS == false ]] && printf "Antigen: Another process in running.\n" _ANTIGEN_LOCK_PROCESS=true # Do not further process hooks. For this hook to properly work it # should be registered first. return -1 fi WARN "Creating antigen-lock file at $ANTIGEN_LOCK" touch $ANTIGEN_LOCK } antigen-add-hook antigen antigen-lock pre once # Hook antigen-apply in order to release .lock file. antigen-apply-lock () { WARN "Freeing antigen-lock file at $ANTIGEN_LOCK" unset _ANTIGEN_LOCK_PROCESS rm -f $ANTIGEN_LOCK &> /dev/null } antigen-add-hook antigen-apply antigen-apply-lock post once } # Initialize parallel lib -antigen-parallel-init () { WARN "Init parallel extension" PARALLEL typeset -ga _PARALLEL_BUNDLE; _PARALLEL_BUNDLE=() if -antigen-interactive-mode; then return 1 fi } -antigen-parallel-execute() { WARN "Exec parallel extension" PARALLEL # Install bundles in parallel antigen-bundle-parallel-execute () { WARN "Parallel antigen-bundle-parallel-execute" PARALLEL typeset -a pids; pids=() local args pid WARN "Gonna install in parallel ${#_PARALLEL_BUNDLE} bundles." PARALLEL # Do ensure-repo in parallel WARN "${_PARALLEL_BUNDLE}" PARALLEL typeset -Ua repositories # Used to keep track of cloned repositories to avoid # trying to clone it multiple times. for args in ${_PARALLEL_BUNDLE}; do typeset -A bundle; -antigen-parse-args 'bundle' ${=args} if [[ ! -d ${bundle[dir]} && $repositories[(I)${bundle[url]}] == 0 ]]; then WARN "Install in parallel ${bundle[name]}." PARALLEL echo "Installing ${bundle[name]}!..." # $bundle[url]'s format is "url|branch" as to create "$ANTIGEN_BUNDLES/bundle/name-branch", # this way you may require multiple branches from the same repository. -antigen-ensure-repo "${bundle[url]}" > /dev/null &! pids+=($!) else WARN "Bundle ${bundle[name]} already cloned locally." PARALLEL fi repositories+=(${bundle[url]}) done # Wait for all background processes to end while [[ $#pids > 0 ]]; do for pid in $pids; do # `ps` may diplay an error message such "Signal 18 (CONT) caught by ps # (procps-ng version 3.3.9).", see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732410 if [[ $(ps -o pid= -p $pid 2>/dev/null) == "" ]]; then pids[$pids[(I)$pid]]=() fi done sleep .5 done builtin local bundle &> /dev/null for bundle in ${_PARALLEL_BUNDLE[@]}; do antigen-bundle $bundle done WARN "Parallel install done" PARALLEL } # Hooks antigen-apply in order to release hooked functions antigen-apply-parallel () { WARN "Parallel pre-apply" PARALLEL PRE-APPLY #antigen-remove-hook antigen-pre-apply-parallel # Hooks antigen-bundle in order to parallel its execution. antigen-bundle-parallel () { TRACE "antigen-bundle-parallel: $@" PARALLEL _PARALLEL_BUNDLE+=("${(j: :)${@}}") } antigen-add-hook antigen-bundle antigen-bundle-parallel replace } antigen-add-hook antigen-apply antigen-apply-parallel pre once antigen-apply-parallel-execute () { WARN "Parallel replace-apply" PARALLEL REPLACE-APPLY antigen-remove-hook antigen-bundle-parallel # Process all parallel bundles. antigen-bundle-parallel-execute unset _PARALLEL_BUNDLE antigen-remove-hook antigen-apply-parallel-execute antigen-apply } antigen-add-hook antigen-apply antigen-apply-parallel-execute replace once } typeset -ga _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE typeset -g _ZCACHE_CAPTURE_PREFIX # Generates cache from listed bundles. # # Iterates over _ANTIGEN_BUNDLE_RECORD and join all needed sources into one, # if this is done through -antigen-load-list. # Result is stored in ANTIGEN_CACHE. # # _ANTIGEN_BUNDLE_RECORD and fpath is stored in cache. # # Usage # -zcache-generate-cache # # Returns # Nothing. Generates ANTIGEN_CACHE -antigen-cache-generate () { local -aU _fpath _PATH _sources local record LOG "Gonna generate cache for $_ZCACHE_BUNDLE_SOURCE" for record in $_ZCACHE_BUNDLE_SOURCE; do record=${record:A} # LOG "Caching $record" if [[ -f $record ]]; then # Adding $'\n' as a suffix as j:\n: doesn't work inside a heredoc. if [[ $_ANTIGEN_THEME_COMPAT == true && "$record" == *.zsh-theme* ]]; then local compat="${record:A}.antigen-compat" echo "# Generated by Antigen. Do not edit!" >! "$compat" cat $record | sed -Ee '/\{$/,/^\}/!{ s/^local // }' >>! "$compat" record="$compat" fi _sources+=("source '${record}';"$'\n') elif [[ -d $record ]]; then _PATH+=("${record}") _fpath+=("${record}") fi done cat > $ANTIGEN_CACHE <! "$ANTIGEN_RSRC" for rsrc in $ANTIGEN_CHECK_FILES; do zcompile $rsrc done } &! return true } # Initializes caching mechanism. # # Hooks `antigen-bundle` and `antigen-apply` in order to defer bundle install # and load. All bundles are loaded from generated cache rather than dynamically # as these are bundled. # # Usage # -antigen-cache-init # Returns # Nothing -antigen-cache-init () { if -antigen-interactive-mode; then return 1 fi _ZCACHE_CAPTURE_PREFIX=${_ZCACHE_CAPTURE_PREFIX:-"--zcache-"} _ZCACHE_BUNDLE_SOURCE=(); _ZCACHE_CAPTURE_BUNDLE=() # Cache auto config files to check for changes (.zshrc, .antigenrc etc) -antigen-set-default ANTIGEN_AUTO_CONFIG true # Default cache path. -antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh -antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources if [[ $ANTIGEN_CACHE == false ]]; then return 1 fi return 0 } -antigen-cache-execute () { # Main function. Deferred antigen-apply. antigen-apply-cached () { # TRACE "APPLYING CACHE" EXT # Auto determine check_files # There always should be 5 steps from original source as the correct way is to use # `antigen` wrapper not `antigen-apply` directly and it's called by an extension. LOG "TRACE: ${funcfiletrace}" if [[ $ANTIGEN_AUTO_CONFIG == true && $#ANTIGEN_CHECK_FILES -eq 0 ]]; then # Check common configuration file does exist. if [[ -f ${ZDOTDIR:-$HOME}/.zshrc ]]; then ANTIGEN_CHECK_FILES+=(${ZDOTDIR:-$HOME}/.zshrc) fi # TODO Fix: Fuzzy match shoud be replaced by a sane way to determine it. if [[ $#funcfiletrace -ge 6 ]]; then ANTIGEN_CHECK_FILES+=("${${funcfiletrace[6]%:*}##* }") fi fi # Generate and compile cache -antigen-cache-generate [[ -f "$ANTIGEN_CACHE" ]] && source "$ANTIGEN_CACHE"; # Commented out in order to have a working `cache-gen` command #unset _ZCACHE_BUNDLE_SOURCE unset _ZCACHE_CAPTURE_BUNDLE _ZCACHE_CAPTURE_FUNCTIONS # Release all hooked functions antigen-remove-hook -antigen-load-env-cached antigen-remove-hook -antigen-load-source-cached antigen-remove-hook antigen-bundle-cached } antigen-add-hook antigen-apply antigen-apply-cached post once # Defer antigen-bundle. antigen-bundle-cached () { _ZCACHE_CAPTURE_BUNDLE+=("${(j: :)${@}}") } antigen-add-hook antigen-bundle antigen-bundle-cached pre # Defer loading. -antigen-load-env-cached () { local bundle typeset -A bundle; bundle=($@) local location=${bundle[dir]}/${bundle[loc]} # Load to path if there is no sourceable if [[ ${bundle[loc]} == "/" ]]; then _ZCACHE_BUNDLE_SOURCE+=("${location}") return fi _ZCACHE_BUNDLE_SOURCE+=("${location}") } antigen-add-hook -antigen-load-env -antigen-load-env-cached replace # Defer sourcing. -antigen-load-source-cached () { _ZCACHE_BUNDLE_SOURCE+=($@) } antigen-add-hook -antigen-load-source -antigen-load-source-cached replace return 0 } # Generate static-cache file at $ANTIGEN_CACHE using currently loaded # bundles from $_ANTIGEN_BUNDLE_RECORD # # Usage # antigen-cache-gen # # Returns # Nothing antigen-cache-gen () { -antigen-cache-generate } #compdef _antigen # Setup antigen's autocompletion _antigen () { local -a _1st_arguments _1st_arguments=( 'apply:Load all bundle completions' 'bundle:Install and load the given plugin' 'bundles:Bulk define bundles' 'cleanup:Clean up the clones of repos which are not used by any bundles currently loaded' 'cache-gen:Generate cache' 'init:Load Antigen configuration from file' 'list:List out the currently loaded bundles' 'purge:Remove a cloned bundle from filesystem' 'reset:Clears cache' 'restore:Restore the bundles state as specified in the snapshot' 'revert:Revert the state of all bundles to how they were before the last antigen update' 'selfupdate:Update antigen itself' 'snapshot:Create a snapshot of all the active clones' 'theme:Switch the prompt theme' 'update:Update all bundles' 'use:Load any (supported) zsh pre-packaged framework' ); _1st_arguments+=( 'help:Show this message' 'version:Display Antigen version' ) __bundle() { _arguments \ '--loc[Path to the location ]' \ '--url[Path to the repository ]' \ '--branch[Git branch name]' \ '--no-local-clone[Do not create a clone]' } __list() { _arguments \ '--simple[Show only bundle name]' \ '--short[Show only bundle name and branch]' \ '--long[Show bundle records]' } __cleanup() { _arguments \ '--force[Do not ask for confirmation]' } _arguments '*:: :->command' if (( CURRENT == 1 )); then _describe -t commands "antigen command" _1st_arguments return fi local -a _command_args case "$words[1]" in bundle) __bundle ;; use) compadd "$@" "oh-my-zsh" "prezto" ;; cleanup) __cleanup ;; (update|purge) compadd $(type -f \-antigen-get-bundles &> /dev/null || antigen &> /dev/null; -antigen-get-bundles --simple 2> /dev/null) ;; theme) compadd $(type -f \-antigen-get-themes &> /dev/null || antigen &> /dev/null; -antigen-get-themes 2> /dev/null) ;; list) __list ;; esac } zmodload zsh/datetime ANTIGEN_DEBUG_LOG=${ANTIGEN_DEBUG_LOG:-${ADOTDIR:-$HOME/.antigen}/debug.log} LOG () { local PREFIX="[LOG][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG } ERR () { local PREFIX="[ERR][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG } WARN () { local PREFIX="[WRN][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG } TRACE () { local PREFIX="[TRA][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@\n${PREFIX} ${(j:\n:)funcstack}" >> $ANTIGEN_DEBUG_LOG } -antigen-env-setup antigen-2.2.3/configure000077500000000000000000000044001322326672200150550ustar00rootroot00000000000000#!/bin/zsh # vim: sw=2 ts=2 et! target=Makefile arguments="$@" typeset -A opts; opts=( with-debug yes with-extensions yes with-lock yes with-parallel yes with-cache yes with-defer yes with-completion yes ) if [[ $1 == "--help" || $1 == "-h" ]]; then cat >&1 <&2 exit 1 fi [[ $key = enable-* ]] && value=yes || value=no key="with-${key//enable-/}" key="${key//disable-/}" if [[ ! $opts[$key] ]]; then printf "Invalid option argument: %s (%s)\n" $argkey $key >&2 printf "Valid options are: %s\n" ${(kj:, :)opts} >&2 exit 1 fi # Disable all extentions if [[ $key == "with-extensions" && $value == "no" ]]; then opts[with-lock]=no opts[with-parallel]=no opts[with-cache]=no opts[with-defer]=no fi else if [[ $1 = *=* ]]; then value="${1#*=}" else value=$opts[$key] fi fi if [[ $opts[$key] != "" ]]; then opts[$key]=$value else printf "Invalid argument: %s (%s)\n" $key $1 >&2 exit 1 fi shift done BANNER_SEP=$(printf '%*s' 70 | tr ' ' '\#') cat > $target <> $target antigen-2.2.3/src/000077500000000000000000000000001322326672200137375ustar00rootroot00000000000000antigen-2.2.3/src/_antigen000066400000000000000000000041521322326672200154500ustar00rootroot00000000000000#compdef _antigen # Setup antigen's autocompletion _antigen () { local -a _1st_arguments _1st_arguments=( 'apply:Load all bundle completions' 'bundle:Install and load the given plugin' 'bundles:Bulk define bundles' 'cleanup:Clean up the clones of repos which are not used by any bundles currently loaded' 'cache-gen:Generate cache' 'init:Load Antigen configuration from file' 'list:List out the currently loaded bundles' 'purge:Remove a cloned bundle from filesystem' 'reset:Clears cache' 'restore:Restore the bundles state as specified in the snapshot' 'revert:Revert the state of all bundles to how they were before the last antigen update' 'selfupdate:Update antigen itself' 'snapshot:Create a snapshot of all the active clones' 'theme:Switch the prompt theme' 'update:Update all bundles' 'use:Load any (supported) zsh pre-packaged framework' ); _1st_arguments+=( 'help:Show this message' 'version:Display Antigen version' ) __bundle() { _arguments \ '--loc[Path to the location ]' \ '--url[Path to the repository ]' \ '--branch[Git branch name]' \ '--no-local-clone[Do not create a clone]' } __list() { _arguments \ '--simple[Show only bundle name]' \ '--short[Show only bundle name and branch]' \ '--long[Show bundle records]' } __cleanup() { _arguments \ '--force[Do not ask for confirmation]' } _arguments '*:: :->command' if (( CURRENT == 1 )); then _describe -t commands "antigen command" _1st_arguments return fi local -a _command_args case "$words[1]" in bundle) __bundle ;; use) compadd "$@" "oh-my-zsh" "prezto" ;; cleanup) __cleanup ;; (update|purge) compadd $(type -f \-antigen-get-bundles &> /dev/null || antigen &> /dev/null; -antigen-get-bundles --simple 2> /dev/null) ;; theme) compadd $(type -f \-antigen-get-themes &> /dev/null || antigen &> /dev/null; -antigen-get-themes 2> /dev/null) ;; list) __list ;; esac } antigen-2.2.3/src/antigen.zsh000066400000000000000000000020061322326672200161100ustar00rootroot00000000000000[[ -z "$_ANTIGEN_INSTALL_DIR" ]] && _ANTIGEN_INSTALL_DIR=${0:A:h} # Each line in this string has the following entries separated by a space # character. # , , , [[ $_ANTIGEN_CACHE_LOADED != true ]] && typeset -aU _ANTIGEN_BUNDLE_RECORD # Do not load anything if git is not available. if (( ! $+commands[git] )); then echo 'Antigen: Please install git to use Antigen.' >&2 return 1 fi # Used to defer compinit/compdef typeset -a __deferred_compdefs compdef () { __deferred_compdefs=($__deferred_compdefs "$*") } # A syntax sugar to avoid the `-` when calling antigen commands. With this # function, you can write `antigen-bundle` as `antigen bundle` and so on. antigen () { local cmd="$1" if [[ -z "$cmd" ]]; then echo 'Antigen: Please give a command to run.' >&2 return 1 fi shift if (( $+functions[antigen-$cmd] )); then "antigen-$cmd" "$@" return $? else echo "Antigen: Unknown command: $cmd" >&2 return 1 fi } antigen-2.2.3/src/boot.zsh000066400000000000000000000027361322326672200154400ustar00rootroot00000000000000zmodload zsh/parameter autoload -U is-at-least # While boot.zsh is part of the ext/cache functionallity it may be disabled # with ANTIGEN_CACHE flag, and it's always compiled with antigen.zsh if [[ $ANTIGEN_CACHE != false ]]; then ANTIGEN_CACHE="${ANTIGEN_CACHE:-${ADOTDIR:-$HOME/.antigen}/init.zsh}" ANTIGEN_RSRC="${ANTIGEN_RSRC:-${ADOTDIR:-$HOME/.antigen}/.resources}" # It may not be necessary to check ANTIGEN_AUTO_CONFIG. if [[ $ANTIGEN_AUTO_CONFIG != false && -f $ANTIGEN_RSRC ]]; then # Check the list of files for configuration changes (uses -nt comp) ANTIGEN_CHECK_FILES=$(cat $ANTIGEN_RSRC 2> /dev/null) ANTIGEN_CHECK_FILES=(${(@f)ANTIGEN_CHECK_FILES}) for config in $ANTIGEN_CHECK_FILES; do if [[ "$config" -nt "$config.zwc" ]]; then # Flag configuration file as newer { zcompile "$config" } &! # Kill cache file in order to force full loading (see a few lines below) [[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE" fi done fi # If there is a cache file do load from it if [[ -f $ANTIGEN_CACHE && ! $_ANTIGEN_CACHE_LOADED == true ]]; then # Wrap antigen in order to defer cache source until `antigen-apply` antigen() { if [[ $1 == "apply" ]]; then source "$ANTIGEN_CACHE" # Handle `antigen-init` command properly elif [[ $1 == "init" ]]; then source "$2" fi } # Do not continue loading antigen as cache bundle takes care of it. return 0 fi fi antigen-2.2.3/src/commands/000077500000000000000000000000001322326672200155405ustar00rootroot00000000000000antigen-2.2.3/src/commands/apply.zsh000066400000000000000000000010371322326672200174140ustar00rootroot00000000000000# Initialize completion antigen-apply () { LOG "Called antigen-apply" # Load the compinit module. This will readefine the `compdef` function to # the one that actually initializes completions. TRACE "Gonna create compdump file @ apply" COMPDUMP autoload -Uz compinit compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP" # Apply all `compinit`s that have been deferred. local cdef for cdef in "${__deferred_compdefs[@]}"; do compdef "$cdef" done { zcompile "$ANTIGEN_COMPDUMP" } &! unset __deferred_compdefs } antigen-2.2.3/src/commands/bundle.zsh000066400000000000000000000036461322326672200175500ustar00rootroot00000000000000# Syntaxes # antigen-bundle [=/] # Keyword only arguments: # branch - The branch of the repo to use for this bundle. antigen-bundle () { TRACE "Called antigen-bundle with $@" BUNDLE if [[ -z "$1" ]]; then printf "Antigen: Must provide a bundle url or name.\n" >&2 return 1 fi builtin typeset -A bundle; -antigen-parse-args 'bundle' ${=@} if [[ -z ${bundle[btype]} ]]; then bundle[btype]=bundle fi local record="${bundle[url]} ${bundle[loc]} ${bundle[btype]} ${bundle[make_local_clone]}" if [[ $_ANTIGEN_WARN_DUPLICATES == true && ! ${_ANTIGEN_BUNDLE_RECORD[(I)$record]} == 0 ]]; then printf "Seems %s is already installed!\n" ${bundle[name]} return 1 fi # Clone bundle if we haven't done do already. if [[ ! -d "${bundle[dir]}" ]]; then if ! -antigen-bundle-install ${(kv)bundle}; then return 1 fi fi # Load the plugin. if ! -antigen-load ${(kv)bundle}; then TRACE "-antigen-load failed to load ${bundle[name]}" BUNDLE printf "Antigen: Failed to load %s.\n" ${bundle[btype]} >&2 return 1 fi # Only add it to the record if it could be installed and loaded. _ANTIGEN_BUNDLE_RECORD+=("$record") } # # Usage: # -antigen-bundle-install # Returns: # 1 if it fails to install bundle -antigen-bundle-install () { typeset -A bundle; bundle=($@) # Ensure a clone exists for this repo, if needed. # Get the clone's directory as per the given repo url and branch. local bpath="${bundle[dir]}" # Clone if it doesn't already exist. local start=$(date +'%s') printf "Installing %s... " "${bundle[name]}" if ! -antigen-ensure-repo "${bundle[url]}"; then # Return immediately if there is an error cloning TRACE "-antigen-bundle-instal failed to clone ${bundle[url]}" BUNDLE printf "Error! Activate logging and try again.\n" >&2 return 1 fi local took=$(( $(date +'%s') - $start )) printf "Done. Took %ds.\n" $took } antigen-2.2.3/src/commands/bundles.zsh000066400000000000000000000006541322326672200177270ustar00rootroot00000000000000antigen-bundles () { # Bulk add many bundles at one go. Empty lines and lines starting with a `#` # are ignored. Everything else is given to `antigen-bundle` as is, no # quoting rules applied. local line setopt localoptions no_extended_glob # See https://github.com/zsh-users/antigen/issues/456 eval "$_ANTIGEN_GREP_COMMAND '^[[:space:]]*[^[:space:]#]'" | while read line; do antigen-bundle ${=line%#*} done } antigen-2.2.3/src/commands/cleanup.zsh000066400000000000000000000021601322326672200177140ustar00rootroot00000000000000# Cleanup unused repositories. antigen-cleanup () { local force=false if [[ $1 == --force ]]; then force=true fi if [[ ! -d "$ANTIGEN_BUNDLES" || -z "$(\ls -A "$ANTIGEN_BUNDLES")" ]]; then echo "You don't have any bundles." return 0 fi # Find directores in ANTIGEN_BUNDLES, that are not in the bundles record. typeset -a unused_clones clones local url record clone for record in $(-antigen-get-cloned-bundles); do url=${record% /*} clones+=("$(-antigen-get-clone-dir $url)") done for clone in $ANTIGEN_BUNDLES/*/*(/); do if [[ $clones[(I)$clone] == 0 ]]; then unused_clones+=($clone) fi done if [[ -z $unused_clones ]]; then echo "You don't have any unidentified bundles." return 0 fi echo 'You have clones for the following repos, but are not used.' echo "\n${(j:\n:)unused_clones}" if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then echo echo for clone in $unused_clones; do echo -n "Deleting clone \"$clone\"..." \rm -rf "$clone" echo ' done.' done else echo echo "Nothing deleted." fi } antigen-2.2.3/src/commands/help.zsh000066400000000000000000000022401322326672200172140ustar00rootroot00000000000000antigen-help () { antigen-version cat < [args] Commands: apply Must be called in the zshrc after all calls to 'antigen bundle'. bundle Install and load a plugin. cache-gen Generate Antigen's cache with currently loaded bundles. cleanup Remove clones of repos not used by any loaded plugins. init Use caching to quickly load bundles. list List currently loaded plugins. purge Remove a bundle from the filesystem. reset Clean the generated cache. restore Restore plugin state from a snapshot file. revert Revert plugins to their state prior to the last time 'antigen update' was run. selfupdate Update antigen. snapshot Create a snapshot of all active plugin repos and save it to a snapshot file. update Update plugins. use Load a supported zsh pre-packaged framework. For further details and complete documentation, visit the project's page at 'http://antigen.sharats.me'. EOF } antigen-2.2.3/src/commands/init.zsh000066400000000000000000000016661322326672200172420ustar00rootroot00000000000000# Antigen command to load antigen configuration # # This method is slighlty more performing than using various antigen-* methods. # # Usage # Referencing an antigen configuration file: # # antigen-init "/path/to/antigenrc" # # or using HEREDOCS: # # antigen-init <&2 return 1 fi fi # Otherwise we expect it to be a heredoc eval "$_ANTIGEN_GREP_COMMAND '^[[:space:]]*[^[:space:]#]'" | while read -r line; do eval $line done } antigen-2.2.3/src/commands/list.zsh000066400000000000000000000005721322326672200172450ustar00rootroot00000000000000# List instaled bundles either in long (record), short or simple format. # # Usage # antigen-list [--short|--long|--simple] # # Returns # List of bundles antigen-list () { local format=$1 # List all currently installed bundles. if [[ -z $_ANTIGEN_BUNDLE_RECORD ]]; then echo "You don't have any bundles." >&2 return 1 fi -antigen-get-bundles $format } antigen-2.2.3/src/commands/purge.zsh000066400000000000000000000027331322326672200174150ustar00rootroot00000000000000# Remove a bundle from filesystem # # Usage # antigen-purge example/bundle [--force] # # Returns # Nothing. Removes bundle from filesystem. antigen-purge () { local bundle=$1 local force=$2 if [[ $# -eq 0 ]]; then echo "Antigen: Missing argument." >&2 return 1 fi if -antigen-purge-bundle $bundle $force; then antigen-reset else return $? fi return 0 } # Remove a bundle from filesystem # # Usage # antigen-purge example/bundle [--force] # # Returns # Nothing. Removes bundle from filesystem. -antigen-purge-bundle () { local bundle=$1 local force=$2 local clone_dir="" local record="" local url="" local make_local_clone="" if [[ $# -eq 0 ]]; then echo "Antigen: Missing argument." >&2 return 1 fi # local keyword doesn't work on zsh <= 5.0.0 record=$(-antigen-find-record $bundle) if [[ ! -n "$record" ]]; then echo "Bundle not found in record. Try 'antigen bundle $bundle' first." >&2 return 1 fi url="$(echo "$record" | cut -d' ' -f1)" make_local_clone=$(echo "$record" | cut -d' ' -f4) if [[ $make_local_clone == "false" ]]; then echo "Bundle has no local clone. Will not be removed." >&2 return 1 fi clone_dir=$(-antigen-get-clone-dir "$url") if [[ $force == "--force" ]] || read -q "?Remove '$clone_dir'? (y/n) "; then # Need empty line after read -q [[ ! -n $force ]] && echo "" || echo "Removing '$clone_dir'."; rm -rf "$clone_dir" return $? fi return 1 } antigen-2.2.3/src/commands/reset.zsh000066400000000000000000000007611322326672200174140ustar00rootroot00000000000000# Removes cache payload and metadata if available # # Usage # antigen-reset # # Returns # Nothing antigen-reset () { [[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE" "$ANTIGEN_CACHE.zwc" 1> /dev/null [[ -f "$ANTIGEN_RSRC" ]] && rm -f "$ANTIGEN_RSRC" 1> /dev/null [[ -f "$ANTIGEN_COMPDUMP" ]] && rm -f "$ANTIGEN_COMPDUMP" "$ANTIGEN_COMPDUMP.zwc" 1> /dev/null [[ -f "$ANTIGEN_LOCK" ]] && rm -f "$ANTIGEN_LOCK" 1> /dev/null echo 'Done. Please open a new shell to see the changes.' } antigen-2.2.3/src/commands/restore.zsh000066400000000000000000000014671322326672200177610ustar00rootroot00000000000000antigen-restore () { local line if [[ $# == 0 ]]; then echo 'Please provide a snapshot file to restore from.' >&2 return 1 fi local snapshot_file="$1" # TODO: Before doing anything with the snapshot file, verify its checksum. # If it fails, notify this to the user and confirm if restore should # proceed. echo -n "Restoring from $snapshot_file..." sed -n '1!p' "$snapshot_file" | while read line; do local version_hash="${line%% *}" local url="${line##* }" local clone_dir="$(-antigen-get-clone-dir "$url")" if [[ ! -d $clone_dir ]]; then git clone "$url" "$clone_dir" &> /dev/null fi (\cd -q "$clone_dir" && git checkout $version_hash) &> /dev/null done echo ' done.' echo 'Please open a new shell to get the restored changes.' } antigen-2.2.3/src/commands/revert.zsh000066400000000000000000000010771322326672200176020ustar00rootroot00000000000000# Reads $ADORDIR/revert-info and restores bundles' revision antigen-revert () { local line if [[ -f $ADOTDIR/revert-info ]]; then cat $ADOTDIR/revert-info | sed -n '1!p' | while read line; do local dir="$(echo "$line" | cut -d: -f1)" git --git-dir="$dir/.git" --work-tree="$dir" \ checkout "$(echo "$line" | cut -d: -f2)" 2> /dev/null done echo "Reverted to state before running -update on $( cat $ADOTDIR/revert-info | sed -n '1p')." else echo 'No revert information available. Cannot revert.' >&2 return 1 fi } antigen-2.2.3/src/commands/self-update.zsh000066400000000000000000000012521322326672200204770ustar00rootroot00000000000000# Update (with `git pull`) antigen itself. # TODO: Once update is finished, show a summary of the new commits, as a kind of # "what's new" message. antigen-selfupdate () { (\cd -q $_ANTIGEN_INSTALL_DIR if [[ ! ( -d .git || -f .git ) ]]; then echo "Your copy of antigen doesn't appear to be a git clone. " \ "The 'selfupdate' command cannot work in this case." return 1 fi local head="$(git rev-parse --abbrev-ref HEAD)" if [[ $head == "HEAD" ]]; then # If current head is detached HEAD, checkout to master branch. git checkout master fi git pull # TODO Should be transparently hooked by zcache antigen-reset &>> /dev/null ) } antigen-2.2.3/src/commands/snapshot.zsh000066400000000000000000000025051322326672200201270ustar00rootroot00000000000000antigen-snapshot () { local snapshot_file="${1:-antigen-shapshot}" local urls url dir version_hash snapshot_content local -a bundles # The snapshot content lines are pairs of repo-url and git version hash, in # the form: # urls=$(-antigen-echo-record | awk '$4 == "true" {print $1}' | sort -u) for url in ${(f)urls}; do dir="$(-antigen-get-clone-dir "$url")" version_hash="$(\cd -q "$dir" && git rev-parse HEAD)" bundles+=("$version_hash $url"); done snapshot_content=${(j:\n:)bundles} { # The first line in the snapshot file is for metadata, in the form: # key='value'; key='value'; key='value'; # Where `key`s are valid shell variable names. # Snapshot version. Has no relation to antigen version. If the snapshot # file format changes, this number can be incremented. echo -n "version='1';" # Snapshot creation date+time. echo -n " created_on='$(date)';" # Add a checksum with the md5 checksum of all the snapshot lines. chksum() { (md5sum; test $? = 127 && md5) 2>/dev/null | cut -d' ' -f1 } local checksum="$(echo "$snapshot_content" | chksum)" unset -f chksum; echo -n " checksum='${checksum%% *}';" # A newline after the metadata and then the snapshot lines. echo "\n$snapshot_content" } > "$snapshot_file" } antigen-2.2.3/src/commands/theme.zsh000066400000000000000000000031601322326672200173700ustar00rootroot00000000000000# Loads a given theme. # # Shares the same syntax as antigen-bundle command. # # Usage # antigen-theme zsh/theme[.zsh-theme] # # Returns # 0 if everything was succesfully antigen-theme () { local name=$1 result=0 record local match mbegin mend MATCH MBEGIN MEND if [[ -z "$1" ]]; then printf "Antigen: Must provide a theme url or name.\n" >&2 return 1 fi -antigen-theme-reset-hooks record=$(-antigen-find-record "theme") if [[ "$1" != */* && "$1" != --* ]]; then # The first argument is just a name of the plugin, to be picked up from # the default repo. antigen-bundle --loc=themes/$name --btype=theme else antigen-bundle "$@" --btype=theme fi result=$? # Remove a theme from the record if the following conditions apply: # - there was no error in bundling the given theme # - there is a theme registered # - registered theme is not the same as the current one if [[ $result == 0 && -n $record ]]; then # http://zsh-workers.zsh.narkive.com/QwfCWpW8/what-s-wrong-with-this-expression if [[ "$record" =~ "$@" ]]; then return $result else _ANTIGEN_BUNDLE_RECORD[$_ANTIGEN_BUNDLE_RECORD[(I)$record]]=() fi fi return $result } -antigen-theme-reset-hooks () { # This is only needed on interactive mode autoload -U add-zsh-hook is-at-least local hook # Clear out prompts PROMPT="" if [[ -n $RPROMPT ]]; then RPROMPT="" fi for hook in chpwd precmd preexec periodic; do add-zsh-hook -D "${hook}" "prompt_*" # common in omz themes add-zsh-hook -D "${hook}" "*_${hook}" add-zsh-hook -d "${hook}" "vcs_info" done } antigen-2.2.3/src/commands/update.zsh000066400000000000000000000036111322326672200175510ustar00rootroot00000000000000# Updates the bundles or a single bundle. # # Usage # antigen-update [example/bundle] # # Returns # Nothing. Performs a `git pull`. antigen-update () { local bundle=$1 url # Clear log :> $ANTIGEN_LOG # Update revert-info data -antigen-revert-info # If no argument is given we update all bundles if [[ $# -eq 0 ]]; then # Here we're ignoring all non cloned bundles (ie, --no-local-clone) -antigen-get-cloned-bundles | while read url; do -antigen-update-bundle $url done # TODO next minor version # antigen-reset else if -antigen-update-bundle $bundle; then # TODO next minor version # antigen-reset else return $? fi fi } # Updates a bundle performing a `git pull`. # # Usage # -antigen-update-bundle example/bundle # # Returns # Nothing. Performs a `git pull`. -antigen-update-bundle () { local bundle="$1" local record="" local url="" local make_local_clone="" local start=$(date +'%s') if [[ $# -eq 0 ]]; then printf "Antigen: Missing argument.\n" >&2 return 1 fi record=$(-antigen-find-record $bundle) if [[ ! -n "$record" ]]; then printf "Bundle not found in record. Try 'antigen bundle %s' first.\n" $bundle >&2 return 1 fi url="$(echo "$record" | cut -d' ' -f1)" make_local_clone=$(echo "$record" | cut -d' ' -f4) local branch="master" if [[ $url == *\|* ]]; then branch="$(-antigen-parse-branch ${url%|*} ${url#*|})" fi printf "Updating %s... " $(-antigen-bundle-short-name "$url" "$branch") if [[ $make_local_clone == "false" ]]; then printf "Bundle has no local clone. Will not be updated.\n" >&2 return 1 fi # update=true verbose=false if ! -antigen-ensure-repo "$url" true false; then printf "Error! Activate logging and try again.\n" >&2 return 1 fi local took=$(( $(date +'%s') - $start )) printf "Done. Took %ds.\n" $took } antigen-2.2.3/src/commands/use.zsh000066400000000000000000000007031322326672200170620ustar00rootroot00000000000000antigen-use () { if [[ $1 == oh-my-zsh ]]; then -antigen-use-oh-my-zsh elif [[ $1 == prezto ]]; then -antigen-use-prezto elif [[ $1 != "" ]]; then ANTIGEN_DEFAULT_REPO_URL=$1 antigen-bundle $@ else echo 'Usage: antigen-use ' >&2 echo 'Where is any one of the following:' >&2 echo ' * oh-my-zsh' >&2 echo ' * prezto' >&2 echo ' is the full url.' >&2 return 1 fi } antigen-2.2.3/src/commands/version.zsh000066400000000000000000000006541322326672200177600ustar00rootroot00000000000000antigen-version () { local extensions printf "Antigen %s (%s)\nRevision date: %s\n" "{{ANTIGEN_VERSION}}" "{{ANTIGEN_REVISION}}" "{{ANTIGEN_REVISION_DATE}}" # Show extension information if any is available if (( $+functions[antigen-ext] )); then typeset -a extensions; extensions=($(antigen-ext-list)) if [[ $#extensions -gt 0 ]]; then printf "Extensions loaded: %s\n" ${(j:, :)extensions} fi fi } antigen-2.2.3/src/ext/000077500000000000000000000000001322326672200145375ustar00rootroot00000000000000antigen-2.2.3/src/ext/cache.zsh000066400000000000000000000134101322326672200163270ustar00rootroot00000000000000typeset -ga _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE typeset -g _ZCACHE_CAPTURE_PREFIX # Generates cache from listed bundles. # # Iterates over _ANTIGEN_BUNDLE_RECORD and join all needed sources into one, # if this is done through -antigen-load-list. # Result is stored in ANTIGEN_CACHE. # # _ANTIGEN_BUNDLE_RECORD and fpath is stored in cache. # # Usage # -zcache-generate-cache # # Returns # Nothing. Generates ANTIGEN_CACHE -antigen-cache-generate () { local -aU _fpath _PATH _sources local record LOG "Gonna generate cache for $_ZCACHE_BUNDLE_SOURCE" for record in $_ZCACHE_BUNDLE_SOURCE; do record=${record:A} # LOG "Caching $record" if [[ -f $record ]]; then # Adding $'\n' as a suffix as j:\n: doesn't work inside a heredoc. if [[ $_ANTIGEN_THEME_COMPAT == true && "$record" == *.zsh-theme* ]]; then local compat="${record:A}.antigen-compat" echo "# Generated by Antigen. Do not edit!" >! "$compat" cat $record | sed -Ee '/\{$/,/^\}/!{ s/^local // }' >>! "$compat" record="$compat" fi _sources+=("source '${record}';"$'\n') elif [[ -d $record ]]; then _PATH+=("${record}") _fpath+=("${record}") fi done cat > $ANTIGEN_CACHE <! "$ANTIGEN_RSRC" for rsrc in $ANTIGEN_CHECK_FILES; do zcompile $rsrc done } &! return true } # Initializes caching mechanism. # # Hooks `antigen-bundle` and `antigen-apply` in order to defer bundle install # and load. All bundles are loaded from generated cache rather than dynamically # as these are bundled. # # Usage # -antigen-cache-init # Returns # Nothing -antigen-cache-init () { if -antigen-interactive-mode; then return 1 fi _ZCACHE_CAPTURE_PREFIX=${_ZCACHE_CAPTURE_PREFIX:-"--zcache-"} _ZCACHE_BUNDLE_SOURCE=(); _ZCACHE_CAPTURE_BUNDLE=() # Cache auto config files to check for changes (.zshrc, .antigenrc etc) -antigen-set-default ANTIGEN_AUTO_CONFIG true # Default cache path. -antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh -antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources if [[ $ANTIGEN_CACHE == false ]]; then return 1 fi return 0 } -antigen-cache-execute () { # Main function. Deferred antigen-apply. antigen-apply-cached () { # TRACE "APPLYING CACHE" EXT # Auto determine check_files # There always should be 5 steps from original source as the correct way is to use # `antigen` wrapper not `antigen-apply` directly and it's called by an extension. LOG "TRACE: ${funcfiletrace}" if [[ $ANTIGEN_AUTO_CONFIG == true && $#ANTIGEN_CHECK_FILES -eq 0 ]]; then # Check common configuration file does exist. if [[ -f ${ZDOTDIR:-$HOME}/.zshrc ]]; then ANTIGEN_CHECK_FILES+=(${ZDOTDIR:-$HOME}/.zshrc) fi # TODO Fix: Fuzzy match shoud be replaced by a sane way to determine it. if [[ $#funcfiletrace -ge 6 ]]; then ANTIGEN_CHECK_FILES+=("${${funcfiletrace[6]%:*}##* }") fi fi # Generate and compile cache -antigen-cache-generate [[ -f "$ANTIGEN_CACHE" ]] && source "$ANTIGEN_CACHE"; # Commented out in order to have a working `cache-gen` command #unset _ZCACHE_BUNDLE_SOURCE unset _ZCACHE_CAPTURE_BUNDLE _ZCACHE_CAPTURE_FUNCTIONS # Release all hooked functions antigen-remove-hook -antigen-load-env-cached antigen-remove-hook -antigen-load-source-cached antigen-remove-hook antigen-bundle-cached } antigen-add-hook antigen-apply antigen-apply-cached post once # Defer antigen-bundle. antigen-bundle-cached () { _ZCACHE_CAPTURE_BUNDLE+=("${(j: :)${@}}") } antigen-add-hook antigen-bundle antigen-bundle-cached pre # Defer loading. -antigen-load-env-cached () { local bundle typeset -A bundle; bundle=($@) local location=${bundle[dir]}/${bundle[loc]} # Load to path if there is no sourceable if [[ ${bundle[loc]} == "/" ]]; then _ZCACHE_BUNDLE_SOURCE+=("${location}") return fi _ZCACHE_BUNDLE_SOURCE+=("${location}") } antigen-add-hook -antigen-load-env -antigen-load-env-cached replace # Defer sourcing. -antigen-load-source-cached () { _ZCACHE_BUNDLE_SOURCE+=($@) } antigen-add-hook -antigen-load-source -antigen-load-source-cached replace return 0 } # Generate static-cache file at $ANTIGEN_CACHE using currently loaded # bundles from $_ANTIGEN_BUNDLE_RECORD # # Usage # antigen-cache-gen # # Returns # Nothing antigen-cache-gen () { -antigen-cache-generate } antigen-2.2.3/src/ext/defer.zsh000066400000000000000000000015601322326672200163540ustar00rootroot00000000000000# Initialize defer lib -antigen-defer-init () { typeset -ga _DEFERRED_BUNDLE; _DEFERRED_BUNDLE=() if -antigen-interactive-mode; then return 1 fi } -antigen-defer-execute () { # Hooks antigen-bundle in order to defer its execution. antigen-bundle-defer () { _DEFERRED_BUNDLE+=("${(j: :)${@}}") return -1 # Stop right there } antigen-add-hook antigen-bundle antigen-bundle-defer replace # Hooks antigen-apply in order to release hooked functions antigen-apply-defer () { WARN "Defer pre-apply" DEFER PRE-APPLY antigen-remove-hook antigen-bundle-defer # Process all deferred bundles. local bundle for bundle in ${_DEFERRED_BUNDLE[@]}; do LOG "Processing deferred bundle: ${bundle}" DEFER antigen-bundle $bundle done unset _DEFERRED_BUNDLE } antigen-add-hook antigen-apply antigen-apply-defer pre once } antigen-2.2.3/src/ext/ext.zsh000066400000000000000000000131761322326672200160750ustar00rootroot00000000000000typeset -Ag _ANTIGEN_HOOKS; _ANTIGEN_HOOKS=() typeset -Ag _ANTIGEN_HOOKS_META; _ANTIGEN_HOOKS_META=() typeset -g _ANTIGEN_HOOK_PREFIX="-antigen-hook-" typeset -g _ANTIGEN_EXTENSIONS; _ANTIGEN_EXTENSIONS=() # -antigen-add-hook antigen-apply antigen-apply-hook replace # - Replaces hooked function with hook, do not call hooked function # - Return -1 to stop calling further hooks # -antigen-add-hook antigen-apply antigen-apply-hook pre (pre-call) # - By default it will call hooked function # -antigen-add-hook antigen-pply antigen-apply-hook post (post-call) # - Calls antigen-apply and then calls hook function # Usage: # -antigen-add-hook antigen-apply antigen-apply-hook ["replace"|"pre"|"post"] ["once"|"repeat"] antigen-add-hook () { local target="$1" hook="$2" type="$3" mode="${4:-repeat}" if (( ! $+functions[$target] )); then printf "Antigen: Function %s doesn't exist.\n" $target return 1 fi if (( ! $+functions[$hook] )); then printf "Antigen: Function %s doesn't exist.\n" $hook return 1 fi if [[ "${_ANTIGEN_HOOKS[$target]}" == "" ]]; then _ANTIGEN_HOOKS[$target]="${hook}" else _ANTIGEN_HOOKS[$target]="${_ANTIGEN_HOOKS[$target]}:${hook}" fi _ANTIGEN_HOOKS_META[$hook]="target $target type $type mode $mode called 0" # Do shadow for this function if there is none already local hook_function="${_ANTIGEN_HOOK_PREFIX}$target" if (( ! $+functions[$hook_function] )); then # Preserve hooked function eval "function ${_ANTIGEN_HOOK_PREFIX}$(functions -- $target)" # Create hook, call hook-handler to further process hook functions eval "function $target () { noglob -antigen-hook-handler $target \$@ return \$? }" fi return 0 } # Private function to handle multiple hooks in a central point. -antigen-hook-handler () { local target="$1" args hook called local hooks meta shift typeset -a args; args=(${@}) typeset -a pre_hooks replace_hooks post_hooks; typeset -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]}) typeset -A meta; for hook in $hooks; do meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]}) if [[ ${meta[mode]} == "once" && ${meta[called]} == 1 ]]; then WARN "Ignoring hook due to mode ${meta[mode]}: $hook" continue fi let called=${meta[called]}+1 meta[called]=$called _ANTIGEN_HOOKS_META[$hook]="${(kv)meta}" WARN "Updated meta: "${(kv)meta} case "${meta[type]}" in "pre") pre_hooks+=($hook) ;; "replace") replace_hooks+=($hook) ;; "post") post_hooks+=($hook) ;; esac done WARN "Processing hooks: ${hooks}" for hook in $pre_hooks; do WARN "Pre hook:" $hook $args noglob $hook $args [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret done # A replace hook will return inmediately local replace_hook=0 ret=0 for hook in $replace_hooks; do replace_hook=1 # Should not be needed if `antigen-remove-hook` removed unneeded hooks. if (( $+functions[$hook] )); then WARN "Replace hook:" $hook $args noglob $hook $args [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret fi done if [[ $replace_hook == 0 ]]; then WARN "${_ANTIGEN_HOOK_PREFIX}$target $args" noglob ${_ANTIGEN_HOOK_PREFIX}$target $args ret=$? else WARN "Replaced hooked function." fi for hook in $post_hooks; do WARN "Post hook:" $hook $args noglob $hook $args [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret done LOG "Return from hook ${target} with ${ret}" return $ret } # Usage: # -antigen-remove-hook antigen-apply-hook antigen-remove-hook () { local hook="$1" typeset -A meta; meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]}) local target="${meta[target]}" local -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]}) # Remove registered hook if [[ $#hooks > 0 ]]; then hooks[$hooks[(I)$hook]]=() fi _ANTIGEN_HOOKS[${target}]="${(j|:|)hooks}" if [[ $#hooks == 0 ]]; then # Destroy base hook eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)" if (( $+functions[${_ANTIGEN_HOOK_PREFIX}$target] )); then unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" fi fi unfunction -- $hook 2> /dev/null } # Remove all defined hooks. -antigen-reset-hooks () { local target for target in ${(k)_ANTIGEN_HOOKS}; do # Release all hooked functions eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)" unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" 2> /dev/null done _ANTIGEN_HOOKS=() _ANTIGEN_HOOKS_META=() _ANTIGEN_EXTENSIONS=() } # Initializes an extension # Usage: # antigen-ext ext-name antigen-ext () { local ext=$1 local func="-antigen-$ext-init" if (( $+functions[$func] && $_ANTIGEN_EXTENSIONS[(I)$ext] == 0 )); then eval $func local ret=$? WARN "$func return code was $ret" if (( $ret == 0 )); then LOG "LOADED EXTENSION $ext" EXT -antigen-$ext-execute && _ANTIGEN_EXTENSIONS+=($ext) else WARN "IGNORING EXTENSION $func" EXT return 1 fi else printf "Antigen: No extension defined or already loaded: %s\n" $func >&2 return 1 fi } # List installed extensions # Usage: # antigen ext-list antigen-ext-list () { echo $_ANTIGEN_EXTENSIONS } # Initializes built-in extensions # Usage: # antigen-ext-init antigen-ext-init () { # Initialize extensions. unless in interactive mode. local ext for ext in ${(s/ /)_ANTIGEN_BUILTIN_EXTENSIONS}; do # Check if extension is loaded before intializing it (( $+functions[-antigen-$ext-init] )) && antigen-ext $ext done } antigen-2.2.3/src/ext/lock.zsh000066400000000000000000000026761322326672200162300ustar00rootroot00000000000000# Initialize lock lib -antigen-lock-init () { # Default lock path. -antigen-set-default ANTIGEN_LOCK $ADOTDIR/.lock typeset -g _ANTIGEN_LOCK_PROCESS=false # Use env variable to determine if we should load this extension -antigen-set-default ANTIGEN_MUTEX true # Set ANTIGEN_MUTEX to false to avoid loading this extension if [[ $ANTIGEN_MUTEX == true ]]; then return 0; fi # Do not use mutex return 1; } -antigen-lock-execute () { # Hook antigen command in order to check/create a lock file. # This hook is only run once then releases itself. antigen-lock () { LOG "antigen-lock called" # If there is a lock set up then we won't process anything. if [[ -f $ANTIGEN_LOCK ]]; then # Set up flag do the message is not repeated for each antigen-* command [[ $_ANTIGEN_LOCK_PROCESS == false ]] && printf "Antigen: Another process in running.\n" _ANTIGEN_LOCK_PROCESS=true # Do not further process hooks. For this hook to properly work it # should be registered first. return -1 fi WARN "Creating antigen-lock file at $ANTIGEN_LOCK" touch $ANTIGEN_LOCK } antigen-add-hook antigen antigen-lock pre once # Hook antigen-apply in order to release .lock file. antigen-apply-lock () { WARN "Freeing antigen-lock file at $ANTIGEN_LOCK" unset _ANTIGEN_LOCK_PROCESS rm -f $ANTIGEN_LOCK &> /dev/null } antigen-add-hook antigen-apply antigen-apply-lock post once } antigen-2.2.3/src/ext/parallel.zsh000066400000000000000000000056631322326672200170730ustar00rootroot00000000000000# Initialize parallel lib -antigen-parallel-init () { WARN "Init parallel extension" PARALLEL typeset -ga _PARALLEL_BUNDLE; _PARALLEL_BUNDLE=() if -antigen-interactive-mode; then return 1 fi } -antigen-parallel-execute() { WARN "Exec parallel extension" PARALLEL # Install bundles in parallel antigen-bundle-parallel-execute () { WARN "Parallel antigen-bundle-parallel-execute" PARALLEL typeset -a pids; pids=() local args pid WARN "Gonna install in parallel ${#_PARALLEL_BUNDLE} bundles." PARALLEL # Do ensure-repo in parallel WARN "${_PARALLEL_BUNDLE}" PARALLEL typeset -Ua repositories # Used to keep track of cloned repositories to avoid # trying to clone it multiple times. for args in ${_PARALLEL_BUNDLE}; do typeset -A bundle; -antigen-parse-args 'bundle' ${=args} if [[ ! -d ${bundle[dir]} && $repositories[(I)${bundle[url]}] == 0 ]]; then WARN "Install in parallel ${bundle[name]}." PARALLEL echo "Installing ${bundle[name]}!..." # $bundle[url]'s format is "url|branch" as to create "$ANTIGEN_BUNDLES/bundle/name-branch", # this way you may require multiple branches from the same repository. -antigen-ensure-repo "${bundle[url]}" > /dev/null &! pids+=($!) else WARN "Bundle ${bundle[name]} already cloned locally." PARALLEL fi repositories+=(${bundle[url]}) done # Wait for all background processes to end while [[ $#pids > 0 ]]; do for pid in $pids; do # `ps` may diplay an error message such "Signal 18 (CONT) caught by ps # (procps-ng version 3.3.9).", see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732410 if [[ $(ps -o pid= -p $pid 2>/dev/null) == "" ]]; then pids[$pids[(I)$pid]]=() fi done sleep .5 done builtin local bundle &> /dev/null for bundle in ${_PARALLEL_BUNDLE[@]}; do antigen-bundle $bundle done WARN "Parallel install done" PARALLEL } # Hooks antigen-apply in order to release hooked functions antigen-apply-parallel () { WARN "Parallel pre-apply" PARALLEL PRE-APPLY #antigen-remove-hook antigen-pre-apply-parallel # Hooks antigen-bundle in order to parallel its execution. antigen-bundle-parallel () { TRACE "antigen-bundle-parallel: $@" PARALLEL _PARALLEL_BUNDLE+=("${(j: :)${@}}") } antigen-add-hook antigen-bundle antigen-bundle-parallel replace } antigen-add-hook antigen-apply antigen-apply-parallel pre once antigen-apply-parallel-execute () { WARN "Parallel replace-apply" PARALLEL REPLACE-APPLY antigen-remove-hook antigen-bundle-parallel # Process all parallel bundles. antigen-bundle-parallel-execute unset _PARALLEL_BUNDLE antigen-remove-hook antigen-apply-parallel-execute antigen-apply } antigen-add-hook antigen-apply antigen-apply-parallel-execute replace once } antigen-2.2.3/src/helpers/000077500000000000000000000000001322326672200154015ustar00rootroot00000000000000antigen-2.2.3/src/helpers/bundle-rev.zsh000066400000000000000000000014331322326672200201730ustar00rootroot00000000000000# Returns the bundle's git revision # # Usage # -antigen-bundle-rev bundle-name [is_local_clone] # # Returns # Bundle rev-parse output (branch name or short ref name) -antigen-bundle-rev () { local bundle=$1 local is_local_clone=$2 local bundle_path=$bundle # Get bunde path inside $ADOTDIR if bundle was effectively cloned if [[ "$is_local_clone" == "true" ]]; then bundle_path=$(-antigen-get-clone-dir $bundle) fi local ref ref=$(git --git-dir="$bundle_path/.git" rev-parse --abbrev-ref '@' 2>/dev/null) # Avoid 'HEAD' when in detached mode if [[ $ref == "HEAD" ]]; then ref=$(git --git-dir="$bundle_path/.git" describe --tags --exact-match 2>/dev/null \ || git --git-dir="$bundle_path/.git" rev-parse --short '@' 2>/dev/null || "-") fi echo $ref } antigen-2.2.3/src/helpers/bundle-short-name.zsh000066400000000000000000000007401322326672200214540ustar00rootroot00000000000000# Usage: # -antigen-bundle-short-name "https://github.com/user/repo.git[|*]" "[branch/name]" # Returns: # user/repo@branch/name -antigen-bundle-short-name () { local bundle_name="${1%|*}" local bundle_branch="$2" local match mbegin mend MATCH MBEGIN MEND [[ "$bundle_name" =~ '.*/(.*/.*).*$' ]] && bundle_name=$match[1] bundle_name="${bundle_name%.git*}" if [[ -n $bundle_branch ]]; then bundle_name="$bundle_name@$bundle_branch" fi echo $bundle_name } antigen-2.2.3/src/helpers/echo-record.zsh000066400000000000000000000002471322326672200203240ustar00rootroot00000000000000# Echo the bundle specs as in the record. The first line is not echoed since it # is a blank line. -antigen-echo-record () { echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} } antigen-2.2.3/src/helpers/find-bundle.zsh000066400000000000000000000003231322326672200203140ustar00rootroot00000000000000# Filters _ANTIGEN_BUNDLE_RECORD for $1 # # Usage # -antigen-find-bundle example/bundle # # Returns # String if bundle is found -antigen-find-bundle () { echo $(-antigen-find-record $1 | cut -d' ' -f1) } antigen-2.2.3/src/helpers/find-record.zsh000066400000000000000000000004641322326672200203270ustar00rootroot00000000000000# Filters _ANTIGEN_BUNDLE_RECORD for $1 # # Usage # -antigen-find-record example/bundle # # Returns # String if record is found -antigen-find-record () { local bundle=$1 if [[ $# -eq 0 ]]; then return 1 fi local record=${bundle/\|/\\\|} echo "${_ANTIGEN_BUNDLE_RECORD[(r)*$record*]}" } antigen-2.2.3/src/helpers/get-bundles.zsh000066400000000000000000000020411322326672200203350ustar00rootroot00000000000000# Returns bundle names from _ANTIGEN_BUNDLE_RECORD # # Usage # -antigen-get-bundles [--short|--simple|--long] # # Returns # List of bundles installed -antigen-get-bundles () { local mode revision url bundle_name bundle_entry loc no_local_clone local record bundle make_local_clone mode=${1:-"--short"} for record in $_ANTIGEN_BUNDLE_RECORD; do bundle=(${(@s/ /)record}) url=$bundle[1] loc=$bundle[2] make_local_clone=$bundle[4] bundle_name=$(-antigen-bundle-short-name $url) case "$mode" in --short) # Only check revision for bundle with a requested branch if [[ $url == *\|* ]]; then revision=$(-antigen-bundle-rev $url $make_local_clone) else revision="master" fi if [[ $loc != '/' ]]; then bundle_name="$bundle_name ~ $loc" fi echo "$bundle_name @ $revision" ;; --simple) echo "$bundle_name" ;; --long) echo "$record" ;; esac done } antigen-2.2.3/src/helpers/get-clone-dir.zsh000066400000000000000000000013001322326672200205520ustar00rootroot00000000000000# Usage: # -antigen-get-clone-dir "https://github.com/zsh-users/zsh-syntax-highlighting.git[|feature/branch]" # Returns: # $ANTIGEN_BUNDLES/zsh-users/zsh-syntax-highlighting[-feature-branch] -antigen-get-clone-dir () { local bundle="$1" local url="${bundle%|*}" local branch match mbegin mend MATCH MBEGIN MEND [[ "$bundle" =~ "\|" ]] && branch="${bundle#*|}" # Takes a repo url and mangles it, giving the path that this url will be # cloned to. Doesn't actually clone anything. local clone_dir="$ANTIGEN_BUNDLES" url=$(-antigen-bundle-short-name $url) # Suffix with branch/tag name [[ -n "$branch" ]] && url="$url-${branch//\//-}" url=${url//\*/x} echo "$clone_dir/$url" } antigen-2.2.3/src/helpers/get-cloned-bundles.zsh000066400000000000000000000003451322326672200216040ustar00rootroot00000000000000# Returns bundles flagged as make_local_clone # # Usage # -antigen-cloned-bundles # # Returns # Bundle metadata -antigen-get-cloned-bundles() { -antigen-echo-record | awk '$4 == "true" {print $1}' | sort -u } antigen-2.2.3/src/helpers/get-themes.zsh000066400000000000000000000007111322326672200201700ustar00rootroot00000000000000# Returns a list of themes from a default library (omz) # # Usage # -antigen-get-themes # # Returns # List of themes by name -antigen-get-themes () { local library='robbyrussell/oh-my-zsh' local bundle=$(-antigen-find-bundle $library) if [[ -n "$bundle" ]]; then local dir=$(-antigen-get-clone-dir $ANTIGEN_DEFAULT_REPO_URL) echo $(ls $dir/themes/ | eval "$_ANTIGEN_GREP_COMMAND '.zsh-theme$'" | sed 's/.zsh-theme//') fi return 0 } antigen-2.2.3/src/helpers/interactive-mode.zsh000066400000000000000000000010141322326672200213620ustar00rootroot00000000000000# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell. # # Usage # -antigen-interactive-mode # # Returns # Either true or false depending if we are running in interactive mode -antigen-interactive-mode () { WARN "-antigen-interactive-mode: $ZSH_EVAL_CONTEXT \$_ANTIGEN_INTERACTIVE = $_ANTIGEN_INTERACTIVE" if [[ $_ANTIGEN_INTERACTIVE != "" ]]; then [[ $_ANTIGEN_INTERACTIVE == true ]]; return fi [[ "$ZSH_EVAL_CONTEXT" == toplevel* || "$ZSH_EVAL_CONTEXT" == cmdarg* ]]; } antigen-2.2.3/src/helpers/parse-branch.zsh000066400000000000000000000013631322326672200204770ustar00rootroot00000000000000# Parses and retrieves a remote branch given a branch name. # # If the branch name contains '*' it will retrieve remote branches # and try to match against tags and heads, returning the latest matching. # # Usage # -antigen-parse-branch https://github.com/user/repo.git x.y.z # # Returns # Branch name -antigen-parse-branch () { local url="$1" branch="$2" branches local match mbegin mend MATCH MBEGIN MEND if [[ "$branch" =~ '\*' ]]; then branches=$(git ls-remote --tags -q "$url" "$branch"|cut -d'/' -f3|sort -n|tail -1) # There is no --refs flag in git 1.8 and below, this way we # emulate this flag -- also git 1.8 ref order is undefined. branch=${${branches#*/*/}%^*} # Why you are like this? fi echo $branch } antigen-2.2.3/src/helpers/update-repos.zsh000066400000000000000000000024001322326672200205330ustar00rootroot00000000000000-antigen-update-repos () { local repo bundle url target local log=/tmp/antigen-v2-migrate.log echo "It seems you have bundles cloned with Antigen v1.x." echo "We'll try to convert directory structure to v2." echo echo -n "Moving bundles to '\$ADOTDIR/bundles'... " # Migrate old repos -> bundles local errors=0 for repo in $ADOTDIR/repos/*; do bundle=${repo/$ADOTDIR\/repos\//} bundle=${bundle//-SLASH-/\/} bundle=${bundle//-COLON-/\:} bundle=${bundle//-STAR-/\*} url=${bundle//-PIPE-/\|} target=$(-antigen-get-clone-dir $url) mkdir -p "${target:A:h}" echo " ---> ${repo/$ADOTDIR\/} -> ${target/$ADOTDIR\/}" | tee > $log mv "$repo" "$target" &> $log if [[ $? != 0 ]]; then echo "Failed to migrate '$repo'!." errors+=1 fi done if [[ $errors == 0 ]]; then echo "Done." else echo "An error ocurred!" fi echo if [[ "$(ls -A $ADOTDIR/repos | wc -l | xargs)" == 0 ]]; then echo "You can safely remove \$ADOTDIR/repos." else echo "Some bundles couldn't be migrated. See \$ADOTDIR/repos." fi echo if [[ $errors == 0 ]]; then echo "Bundles migrated successfuly." rm $log else echo "Some errors occured. Review migration log in '$log'." fi antigen-reset } antigen-2.2.3/src/lib/000077500000000000000000000000001322326672200145055ustar00rootroot00000000000000antigen-2.2.3/src/lib/ensure-repo.zsh000066400000000000000000000044061322326672200175030ustar00rootroot00000000000000# Ensure that a clone exists for the given repo url and branch. If the first # argument is `update` and if a clone already exists for the given repo # and branch, it is pull-ed, i.e., updated. # # This function expects three arguments in order: # - 'url=' # - 'update=true|false' # - 'verbose=true|false' # # Returns true|false Whether cloning/pulling was succesful -antigen-ensure-repo () { # Argument defaults. Previously using ${1:?"missing url argument"} format # but it seems to mess up with cram if (( $# < 1 )); then echo "Antigen: Missing url argument." return 1 fi # The url. No sane default for this, so just empty. local url=$1 # Check if we have to update. local update=${2:-false} # Verbose output. local verbose=${3:-false} shift $# # Get the clone's directory as per the given repo url and branch. local clone_dir=$(-antigen-get-clone-dir $url) if [[ -d "$clone_dir" && $update == false ]]; then return true fi # A temporary function wrapping the `git` command with repeated arguments. --plugin-git () { (\cd -q "$clone_dir" && eval ${ANTIGEN_CLONE_ENV} git --git-dir="$clone_dir/.git" --no-pager "$@" &>>! $ANTIGEN_LOG) } local success=false # If its a specific branch that we want, checkout that branch. local branch="master" # TODO FIX THIS if [[ $url == *\|* ]]; then branch="$(-antigen-parse-branch ${url%|*} ${url#*|})" fi if [[ ! -d $clone_dir ]]; then eval ${ANTIGEN_CLONE_ENV} git clone ${=ANTIGEN_CLONE_OPTS} --branch "$branch" -- "${url%|*}" "$clone_dir" &>> $ANTIGEN_LOG success=$? elif $update; then # Save current revision. local old_rev="$(--plugin-git rev-parse HEAD)" # Pull changes if update requested. --plugin-git checkout "$branch" --plugin-git pull origin "$branch" success=$? # Update submodules. --plugin-git submodule update ${=ANTIGEN_SUBMODULE_OPTS} # Get the new revision. local new_rev="$(--plugin-git rev-parse HEAD)" fi if [[ -n $old_rev && $old_rev != $new_rev ]]; then echo Updated from $old_rev[0,7] to $new_rev[0,7]. if $verbose; then --plugin-git log --oneline --reverse --no-merges --stat '@{1}..' fi fi # Remove the temporary git wrapper function. unfunction -- --plugin-git return $success } antigen-2.2.3/src/lib/env-setup.zsh000066400000000000000000000043531322326672200171660ustar00rootroot00000000000000# Helper function: Same as `$1=$2`, but will only happen if the name # specified by `$1` is not already set. -antigen-set-default () { local arg_name="$1" local arg_value="$2" eval "test -z \"\$$arg_name\" && typeset -g $arg_name='$arg_value'" } -antigen-env-setup () { typeset -gU fpath path # Pre-startup initializations. -antigen-set-default ANTIGEN_OMZ_REPO_URL \ https://github.com/robbyrussell/oh-my-zsh.git -antigen-set-default ANTIGEN_PREZTO_REPO_URL \ https://github.com/sorin-ionescu/prezto.git -antigen-set-default ANTIGEN_DEFAULT_REPO_URL $ANTIGEN_OMZ_REPO_URL # Default Antigen directory. -antigen-set-default ADOTDIR $HOME/.antigen [[ ! -d $ADOTDIR ]] && mkdir -p $ADOTDIR # Defaults bundles directory. -antigen-set-default ANTIGEN_BUNDLES $ADOTDIR/bundles # If there is no bundles directory, create it. if [[ ! -d $ANTIGEN_BUNDLES ]]; then mkdir -p $ANTIGEN_BUNDLES # Check for v1 repos directory, transform it to v2 format. [[ -d $ADOTDIR/repos ]] && -antigen-update-repos fi -antigen-set-default ANTIGEN_COMPDUMP "${ADOTDIR:-$HOME}/.zcompdump" -antigen-set-default ANTIGEN_COMPINIT_OPTS "-i" -antigen-set-default ANTIGEN_LOG /dev/null # CLONE_OPTS uses ${=CLONE_OPTS} expansion so don't use spaces # for arguments that can be passed as `--key=value`. -antigen-set-default ANTIGEN_CLONE_ENV "GIT_TERMINAL_PROMPT=0" -antigen-set-default ANTIGEN_CLONE_OPTS "--single-branch --recursive --depth=1" -antigen-set-default ANTIGEN_SUBMODULE_OPTS "--recursive --depth=1" # Complain when a bundle is already installed. -antigen-set-default _ANTIGEN_WARN_DUPLICATES true # Compatibility with oh-my-zsh themes. -antigen-set-default _ANTIGEN_THEME_COMPAT true -antigen-set-default _ANTIGEN_GREP_COMMAND 'GREP_OPTIONS= command grep ' # Add default built-in extensions to load at start up -antigen-set-default _ANTIGEN_BUILTIN_EXTENSIONS 'lock parallel defer cache' # Setup antigen's own completion. if -antigen-interactive-mode; then TRACE "Gonna create compdump file @ env-setup" COMPDUMP autoload -Uz compinit compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP" compdef _antigen antigen else (( $+functions[antigen-ext-init] )) && antigen-ext-init fi } antigen-2.2.3/src/lib/load.zsh000066400000000000000000000047061322326672200161610ustar00rootroot00000000000000# Load a given bundle by sourcing it. # # The function also modifies fpath to add the bundle path. # # Usage # -antigen-load "bundle-url" ["location"] ["make_local_clone"] ["btype"] # # Returns # Integer. 0 if success 1 if an error ocurred. -antigen-load () { local bundle list typeset -A bundle; bundle=($@) typeset -Ua list; list=() local location="${bundle[dir]}/${bundle[loc]}" # Prioritize location when given. if [[ -f "${location}" ]]; then list=(${location}) else # Directory locations must be suffixed with slash location="$location/" # Prioritize theme with antigen-theme if [[ ${bundle[btype]} == "theme" ]]; then list=(${location}*.zsh-theme(N[1])) fi # Common frameworks if [[ $#list == 0 ]]; then # dot-plugin, init and functions support (omz, prezto) # Support prezto function loading. See https://github.com/zsh-users/antigen/pull/428 list=(${location}*.plugin.zsh(N[1]) ${location}init.zsh(N[1]) ${location}/functions(N[1])) fi # Default to zsh and sh if [[ $#list == 0 ]]; then list=(${location}*.zsh(N) ${location}*.sh(N)) fi fi -antigen-load-env ${(kv)bundle} # If there is any sourceable try to load it if ! -antigen-load-source "${list[@]}" && [[ ! -d ${location} ]]; then return 1 fi return 0 } -antigen-load-env () { typeset -A bundle; bundle=($@) local location=${bundle[dir]}/${bundle[loc]} # Load to path if there is no sourceable if [[ -d ${location} ]]; then PATH="$PATH:${location:A}" fpath+=("${location:A}") return fi PATH="$PATH:${location:A:h}" fpath+=("${location:A:h}") } -antigen-load-source () { typeset -a list list=($@) local src match mbegin mend MATCH MBEGIN MEND # Return error when we're given an empty list if [[ $#list == 0 ]]; then return 1 fi # Using a for rather than `source $list` as we need to check for zsh-themes # In order to create antigen-compat file. This is only needed for interactive-mode # theme switching, for static loading (cache) there is no need. for src in $list; do if [[ $_ANTIGEN_THEME_COMPAT == true && -f "$src" && "$src" == *.zsh-theme* ]]; then local compat="${src:A}.antigen-compat" echo "# Generated by Antigen. Do not edit!" >! "$compat" cat $src | sed -Ee '/\{$/,/^\}/!{ s/^local // }' >>! "$compat" src="$compat" fi if ! source "$src" 2>/dev/null; then return 1 fi done } antigen-2.2.3/src/lib/log.zsh000066400000000000000000000012041322326672200160110ustar00rootroot00000000000000zmodload zsh/datetime ANTIGEN_DEBUG_LOG=${ANTIGEN_DEBUG_LOG:-${ADOTDIR:-$HOME/.antigen}/debug.log} LOG () { local PREFIX="[LOG][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG } ERR () { local PREFIX="[ERR][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG } WARN () { local PREFIX="[WRN][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG } TRACE () { local PREFIX="[TRA][${EPOCHREALTIME}]" echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@\n${PREFIX} ${(j:\n:)funcstack}" >> $ANTIGEN_DEBUG_LOG } antigen-2.2.3/src/lib/parse-args.zsh000066400000000000000000000110171322326672200172770ustar00rootroot00000000000000# Usage: # -antigen-parse-args output_assoc_arr -antigen-parse-args () { local argkey key value index=0 args local match mbegin mend MATCH MBEGIN MEND local var=$1 shift # Bundle spec arguments' default values. #setopt XTRACE VERBOSE builtin typeset -A args args[url]="$ANTIGEN_DEFAULT_REPO_URL" #unsetopt XTRACE VERBOSE args[loc]=/ args[make_local_clone]=true args[btype]=plugin #args[branch]= # commented out as it may cause assoc array kv mismatch while [[ $# -gt 0 ]]; do argkey="${1%\=*}" key="${argkey//--/}" value="${1#*=}" case "$argkey" in --url|--loc|--branch|--btype) if [[ "$value" == "$argkey" ]]; then printf "Required argument for '%s' not provided.\n" $key >&2 else args[$key]="$value" fi ;; --no-local-clone) args[make_local_clone]=false ;; --*) printf "Unknown argument '%s'.\n" $key >&2 ;; *) value=$key case $index in 0) key=url local domain="" local url_path=$value # Full url with protocol or ssh github url (github.com:org/repo) if [[ "$value" =~ "://" || "$value" =~ ":" ]]; then if [[ "$value" =~ [@.][^/:]+[:]?[0-9]*[:/]?(.*)@?$ ]]; then url_path=$match[1] domain=${value/$url_path/} fi fi if [[ "$url_path" =~ '@' ]]; then args[branch]="${url_path#*@}" value="$domain${url_path%@*}" else value="$domain$url_path" fi ;; 1) key=loc ;; esac let index+=1 args[$key]="$value" ;; esac shift done # Check if url is just the plugin name. Super short syntax. if [[ "${args[url]}" != */* ]]; then case "$ANTIGEN_DEFAULT_REPO_URL" in "$ANTIGEN_OMZ_REPO_URL") args[loc]="plugins/${args[url]}" ;; "$ANTIGEN_PREZTO_REPO_URL") args[loc]="modules/${args[url]}" ;; *) args[loc]="${args[url]}" ;; esac args[url]="$ANTIGEN_DEFAULT_REPO_URL" fi # Resolve the url. # Expand short github url syntax: `username/reponame`. local url="${args[url]}" if [[ $url != git://* && $url != https://* && $url != http://* && $url != ssh://* && $url != /* && $url != *github.com:*/* ]]; then url="https://github.com/${url%.git}.git" fi args[url]="$url" # Ignore local clone if url given is not a git directory if [[ ${args[url]} == /* && ! -d ${args[url]}/.git ]]; then args[make_local_clone]=false fi # Add the branch information to the url if we need to create a local clone. # Format url in bundle-metadata format: url[|branch] if [[ ! -z "${args[branch]}" && ${args[make_local_clone]} == true ]]; then args[url]="${args[url]}|${args[branch]}" fi # Add the theme extension to `loc`, if this is a theme, but only # if it's especified, ie, --loc=theme-name, in case when it's not # specified antige-load-list will look for *.zsh-theme files if [[ ${args[btype]} == "theme" && ${args[loc]} != "/" && ${args[loc]} != *.zsh-theme ]]; then args[loc]="${args[loc]}.zsh-theme" fi local name="${args[url]%|*}" local branch="${args[branch]}" # Extract bundle name. if [[ "$name" =~ '.*/(.*/.*).*$' ]]; then name="${match[1]}" fi name="${name%.git*}" # Format bundle name with optional branch. if [[ -n "${branch}" ]]; then args[name]="${name}@${branch}" else args[name]="${name}" fi # Format bundle path. if [[ ${args[make_local_clone]} == true ]]; then local bpath="$name" # Suffix with branch/tag name if [[ -n "$branch" ]]; then # bpath is in the form of repo/name@version => repo/name-version # Replace / with - in bundle branch. local bbranch=${branch//\//-} # If branch/tag is semver-like do replace * by x. bbranch=${bbranch//\*/x} bpath="${name}-${bbranch}" fi bpath="$ANTIGEN_BUNDLES/$bpath" args[dir]="${(qq)bpath}" else # if it's local then path is just the "url" argument, loc remains the same args[dir]=${args[url]} fi # Escape url and branch (may contain semver-like and pipe characters) args[url]="${(qq)args[url]}" if [[ -n "${args[branch]}" ]]; then args[branch]="${(qq)args[branch]}" fi # Escape bundle name (may contain semver-like characters) args[name]="${(qq)args[name]}" eval "${var}=(${(kv)args})" return 0 } antigen-2.2.3/src/lib/revert-info.zsh000066400000000000000000000011151322326672200174710ustar00rootroot00000000000000# Updates revert-info data with git hash. # # This does process only cloned bundles. # # Usage # -antigen-revert-info # # Returns # Nothing. Generates/updates $ADOTDIR/revert-info. -antigen-revert-info() { local url # Update your bundles, i.e., `git pull` in all the plugin repos. date >! $ADOTDIR/revert-info -antigen-get-cloned-bundles | while read url; do local clone_dir="$(-antigen-get-clone-dir "$url")" if [[ -d "$clone_dir" ]]; then (echo -n "$clone_dir:" \cd -q "$clone_dir" git rev-parse HEAD) >> $ADOTDIR/revert-info fi done } antigen-2.2.3/src/lib/use-oh-my-zsh.zsh000066400000000000000000000004631322326672200176630ustar00rootroot00000000000000-antigen-use-oh-my-zsh () { typeset -g ZSH ZSH_CACHE_DIR ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_OMZ_REPO_URL if [[ -z "$ZSH" ]]; then ZSH="$(-antigen-get-clone-dir "$ANTIGEN_DEFAULT_REPO_URL")" fi if [[ -z "$ZSH_CACHE_DIR" ]]; then ZSH_CACHE_DIR="$ZSH/cache/" fi antigen-bundle --loc=lib } antigen-2.2.3/src/lib/use-prezto.zsh000066400000000000000000000001731322326672200173510ustar00rootroot00000000000000-antigen-use-prezto () { ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_PREZTO_REPO_URL antigen-bundle "$ANTIGEN_PREZTO_REPO_URL" } antigen-2.2.3/tests/000077500000000000000000000000001322326672200143125ustar00rootroot00000000000000antigen-2.2.3/tests/.antigenrc000066400000000000000000000016701322326672200162710ustar00rootroot00000000000000antigen use oh-my-zsh antigen bundles < "$PLUGIN_DIR"/aliases.zsh echo 'PS1="prompt>"' > "$PLUGIN_DIR"/silly.zsh-theme echo 'PS1=">"' > "$PLUGIN_DIR"/arrow.zsh-theme { pg init pg config user.name 'test' pg config user.email 'test@test.test' pg add . pg commit -m 'Initial commit' } > /dev/null # } # Another test plugin. PLUGIN_DIR2="$TESTDIR/test-plugin2" # { mkdir "$PLUGIN_DIR2" # A wrapper function over `git` to work with the test plugin repo. alias pg2='git --git-dir "$PLUGIN_DIR2/.git" --work-tree "$PLUGIN_DIR2"' echo 'alias hehe2="echo hehe2"' > "$PLUGIN_DIR2"/init.zsh echo -E 'alias prompt="\e]$ >\a\n"' >> "$PLUGIN_DIR2"/init.zsh echo 'local root=${0}' >> "$PLUGIN_DIR2"/init.zsh echo 'function root_source () { echo $root/$0 }' >> "$PLUGIN_DIR2"/init.zsh echo 'alias unsourced-alias="echo unsourced-alias"' > "$PLUGIN_DIR2"/aliases.zsh { pg2 init pg2 config user.name 'test' pg2 config user.email 'test@test.test' pg2 add . pg2 commit -m 'Initial commit' } > /dev/null # } # Another test plugin. PLUGIN_DIR3="$TESTDIR/test-plugin3" # { mkdir "$PLUGIN_DIR3" # A wrapper function over `git` to work with the test plugin repo. alias pg3='git --git-dir "$PLUGIN_DIR3/.git" --work-tree "$PLUGIN_DIR3"' echo "echo '######'" > "$PLUGIN_DIR3"/hr-plugin chmod u+x "$PLUGIN_DIR3"/hr-plugin { pg3 init pg3 config user.name 'test' pg3 config user.email 'test@test.test' pg3 add . pg3 commit -m 'Initial commit' } > /dev/null # } PLUGIN_DIR4="$TESTDIR/test-plugin4" # { mkdir "$PLUGIN_DIR4" echo "echo hello world" > "$PLUGIN_DIR4/hello-world" chmod u+x "$PLUGIN_DIR4/hello-world" # } # Another test plugin. PLUGIN_DIR5="$TESTDIR/test-plugin5" # { mkdir "$PLUGIN_DIR5" # A wrapper function over `git` to work with the test plugin repo. alias pg3='git --git-dir "$PLUGIN_DIR5/.git" --work-tree "$PLUGIN_DIR5"' { pg3 init pg3 config user.name 'test' pg3 config user.email 'test@test.test' echo "export VERSION='initial'" > "$PLUGIN_DIR5/version.zsh" pg3 add . pg3 commit -m 'Initial commit' pg3 branch stable echo "export VERSION='v0.0.1'" > "$PLUGIN_DIR5/version.zsh" pg3 add . pg3 commit -m 'v0.0.1' pg3 tag v0.0.1 echo "export VERSION='v0.0.2'" > "$PLUGIN_DIR5/version.zsh" pg3 add . pg3 commit -m 'v0.0.2' pg3 tag v0.0.2 echo "export VERSION='v1.0.3'" > "$PLUGIN_DIR5/version.zsh" pg3 add . pg3 commit -m 'v1.0.3' pg3 tag v1.0.3 echo "export VERSION='v1.1.4'" > "$PLUGIN_DIR5/version.zsh" pg3 add . pg3 commit -m 'v1.1.4' pg3 tag v1.1.4 echo "export VERSION='v3'" > "$PLUGIN_DIR5/version.zsh" pg3 add . pg3 commit -m 'v3' pg3 tag v3 } > /dev/null # } # Wrapper around \wc command to handle wc format differences between GNU and BSD # GNU: # echo 1 | wc -l # 1 # BSD: # echo 1 | wc -l # 1 # # Using this wrapper output from both implementations resembles GNU's. function wc () { command wc "$@" | xargs } antigen-2.2.3/tests/.zshrc000066400000000000000000000001031322326672200154360ustar00rootroot00000000000000source /antigen/antigen.zsh antigen init /antigen/tests/.antigenrc antigen-2.2.3/tests/antigen-wrapper.t000066400000000000000000000004211322326672200175770ustar00rootroot00000000000000Create a dummy antigen command. $ antigen-dummy () { > echo me dummy > } Check the normal way of calling it $ antigen-dummy me dummy Call with the wrapper syntax. $ antigen dummy me dummy Call with an alias $ alias a=antigen $ a dummy me dummy antigen-2.2.3/tests/apply.t000066400000000000000000000003631322326672200156260ustar00rootroot00000000000000Can use antigen-apply and antigen apply interchangably. $ hehe &> /dev/null [127] $ antigen bundle $PLUGIN_DIR &> /dev/null $ antigen theme $PLUGIN_DIR silly $ antigen apply &> /dev/null $ hehe hehe $ echo "$PS1" prompt> antigen-2.2.3/tests/arg-parser.t000066400000000000000000000057031322326672200165470ustar00rootroot00000000000000Helper alias. $ typeset -A bundle $ parse () { > bundle=() > -antigen-parse-args bundle "$@" > } No arguments (since all are specified as optional). $ parse One positional argument. $ parse plugin/url $ echo ${bundle[url]} https://github.com/plugin/url.git Two arguments. $ parse plugin/url location $ echo ${bundle[url]} https://github.com/plugin/url.git $ echo ${bundle[loc]} location Three arguments. $ parse plugin/url location crap $ echo ${bundle[url]} https://github.com/plugin/url.git $ echo ${bundle[loc]} location Keywordo magic. $ parse plugin/url location --btype=1 --no-local-clone $ echo ${bundle[url]} https://github.com/plugin/url.git $ echo ${bundle[loc]} location $ echo ${bundle[btype]} 1 $ echo ${bundle[make_local_clone]} false Unknown keyword argument. $ parse --me=genius Unknown argument 'me'. Missed value for keyword argument. $ parse --btype Required argument for 'btype' not provided. Provide value for keyword argument, but it's ignored. $ parse --no-local-clone=yes $ echo ${bundle[make_local_clone]} false Positional argument as a keyword argument. $ parse --url=plugin/url $ echo ${bundle[url]} https://github.com/plugin/url.git Repeated keyword arguments. $ parse --url=plugin/url --url=plugin/url2 $ echo ${bundle[url]} https://github.com/plugin/url2.git Repeated, once as positional and once more as keyword. $ parse plugin/url --url=plugin/url2 $ echo ${bundle[url]} https://github.com/plugin/url2.git Supports bundle name with branch/version. $ parse plugin/url@version $ echo ${bundle[url]} https://github.com/plugin/url.git|version $ echo ${bundle[branch]} version Supports branch/version flag $ parse plugin/url --branch=version $ echo ${bundle[url]} https://github.com/plugin/url.git|version $ echo ${bundle[branch]} version Flag `--branch` overwrites `@`-name. $ parse plugin/url@b1 --branch=b2 $ echo ${bundle[url]} https://github.com/plugin/url.git|b2 $ echo ${bundle[branch]} b2 Private git urls. $ parse ssh://git@domain.local:1234/repository/name.git $ echo ${bundle[url]} ssh://git@domain.local:1234/repository/name.git Private git urls with branch short format. $ parse ssh://git@domain.local:1234/repository/name.git@example-branch/name $ echo ${bundle[url]} ssh://git@domain.local:1234/repository/name.git|example-branch/name $ echo ${bundle[branch]} example-branch/name Private git urls with branch argument format. $ parse ssh://git@domain.local:1234/repository/name.git --branch=example-branch/name $ echo ${bundle[url]} ssh://git@domain.local:1234/repository/name.git|example-branch/name $ echo ${bundle[branch]} example-branch/name SSH github url. $ parse github.com:reem/watch.git $ echo ${bundle[url]} github.com:reem/watch.git Long SSH github url. $ parse git@github.com:zsh-users/antigen.git $ echo ${bundle[url]} git@github.com:zsh-users/antigen.git antigen-2.2.3/tests/branch-bundle.t000066400000000000000000000012031322326672200171770ustar00rootroot00000000000000Branch b1. $ pg branch b1 $ pg checkout b1 Switched to branch 'b1' $ cat > $PLUGIN_DIR/aliases.zsh < alias hehe='echo hehe from b1' > EOF $ pg commit -am 'Change for b1' \[b1 [a-f0-9]{7}\] Change for b1 (re) 1 file changed, 1 insertion(+), 1 deletion(-) Go back to master. $ pg checkout master Switched to branch 'master' Load plugin from b1. $ antigen bundle $PLUGIN_DIR --branch=b1 &> /dev/null $ hehe hehe from b1 Does not say 'Already on b1' on each session startup. $ antigen-bundle $PLUGIN_DIR --branch=b1 Load plugin from master. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ hehe hehe antigen-2.2.3/tests/bundle-syntaxes.t000066400000000000000000000041731322326672200176310ustar00rootroot00000000000000Test helper and mock functions. $ ANTIGEN_DEFAULT_REPO_URL=gh-user/repo $ ANTIGEN_WARN_DUPLICATES=false $ b () { > antigen-bundle "$@" | tail -3 > } $ -antigen-ensure-repo () {} $ -antigen-load () { > typeset -A bundle; bundle=($@) > echo "url: ${bundle[url]}" > echo "dir: ${bundle[loc]}" > echo "clone?: ${bundle[make_local_clone]}" > } Short and sweet. $ b lol url: https://github.com/gh-user/repo.git dir: lol clone?: true Short repo url. $ b github-username/repo-name url: https://github.com/github-username/repo-name.git dir: / clone?: true Short repo url with `.git` suffix. $ b github-username/repo-name.git url: https://github.com/github-username/repo-name.git dir: / clone?: true Long repo url. $ b https://github.com/user/repo.git url: https://github.com/user/repo.git dir: / clone?: true Long repo url with missing `.git` suffix (should'nt add the suffix). $ b https://github.com/user/repo url: https://github.com/user/repo dir: / clone?: true Short repo with location. $ b user/plugin path/to/plugin url: https://github.com/user/plugin.git dir: path/to/plugin clone?: true Keyword arguments, in respective places. $ b --url=user/repo --loc=path/of/plugin url: https://github.com/user/repo.git dir: path/of/plugin clone?: true Keyword arguments, in respective places, with full repo url. $ b --url=https://github.com/user/repo.git --loc=plugin/path url: https://github.com/user/repo.git dir: plugin/path clone?: true Keyword arguments, in reversed order. $ b --loc=path/of/plugin --url=user/repo url: https://github.com/user/repo.git dir: path/of/plugin clone?: true Mixed positional and keyword arguments, and skip `loc`. $ b user/repo --loc=plugin/loc url: https://github.com/user/repo.git dir: plugin/loc clone?: true Just `loc`, using keyword arguments. $ b --loc=plugin/path url: https://github.com/gh-user/repo.git dir: plugin/path clone?: true TODO: Error reporting with erroneous arguments or usage with incorrect syntax. antigen-2.2.3/tests/bundle.t000066400000000000000000000055701322326672200157570ustar00rootroot00000000000000Should get a complain if no bundle is given as argument. $ antigen-bundle Antigen: Must provide a bundle url or name. [1] Load plugin from master. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ hehe hehe Load the plugin again. Just to see nothing happens. $ antigen-bundle $PLUGIN_DIR $ hehe hehe Try to load an unexisting plugin from a cloned bundle. $ antigen-bundle $PLUGIN_DIR wrong Antigen: Failed to load plugin. [1] Try to install an unexisting bundle. $ antigen-bundle https://127.0.0.1/bundle/unexisting.git Installing bundle/unexisting... Error! Activate logging and try again. [1] $ echo $fpath | grep -co test-plugin 1 Confirm bundle/unexisting does not exists (parent directory will not be removed). $ ls $ANTIGEN_BUNDLES/bundle/ | wc -l 0 Load a prezto style module. Should only source the `init.zsh` present in the module. $ antigen-bundle $PLUGIN_DIR2 &> /dev/null $ hehe2 hehe2 The alias defined in the other zsh file should not be available. $ unsourced-alias zsh: command not found: unsourced-alias [127] Fpath should be updated correctly. $ echo ${(j:\n:)fpath} .*/site-functions (re) .*/functions (re) .*/test-plugin (re) .*/test-plugin2 (re) Load plugin multiple times, doesn't cluters _ANTIGEN_BUNDLE_RECORD $ antigen-bundle $PLUGIN_DIR $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | wc -l 2 $ antigen-bundle $PLUGIN_DIR $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | wc -l 2 Bundle short names. $ -antigen-bundle-short-name "https://github.com/example/bundle.git" example/bundle Branch name is not display with short names. $ -antigen-bundle-short-name "https://github.com/example/bundle.git|branch" example/bundle $ -antigen-bundle-short-name "https://github.com/example/bundle.git|feature/branch/git" example/bundle $ -antigen-bundle-short-name "https://github.com/example/bundle.git" "feature/branch/git" example/bundle@feature/branch/git $ -antigen-bundle-short-name "example/bundle.git" "feature/branch.git" example/bundle@feature/branch.git $ -antigen-bundle-short-name "example/bundle" "feature/branch.git" example/bundle@feature/branch.git Handle shorter syntax. $ -antigen-bundle-short-name "github.com/example/bundle" example/bundle Handle local bundles (--no-local-clone). $ -antigen-bundle-short-name "/home/user/local-bundle" user/local-bundle Load a binary bundle. $ antigen-bundle $PLUGIN_DIR3 &> /dev/null $ hr-plugin ###### $ echo $PATH | grep test-plugin3 *plugin3* (glob) Warns about duplicate bundle. $ antigen-bundle $PLUGIN_DIR3 &> /dev/null $ _ANTIGEN_WARN_DUPLICATES=true $ antigen-bundle $PLUGIN_DIR3 Seems .* is already installed! (re) [1] $ _ANTIGEN_WARN_DUPLICATES=false $ antigen-theme $PLUGIN_DIR silly &> /dev/null $ _ANTIGEN_WARN_DUPLICATES=true $ antigen-theme $PLUGIN_DIR silly Seems .* is already installed! (re) [1] antigen-2.2.3/tests/bundles.t000066400000000000000000000015711322326672200161370ustar00rootroot00000000000000Save env variables to test for leaks. $ prev=$(env) Add multiple bundles. $ echo "$PLUGIN_DIR\n$PLUGIN_DIR2" | antigen-bundles &> /dev/null Check if they are both applied. $ hehe hehe $ hehe2 hehe2 Should not leak Antigen or OMZ environment variables. $ diff <(env) <(echo $prev) | sed -e 's/\=.*//' | grep -i antigen | wc -l 0 $ diff <(env) <(echo $prev) | sed -e 's/\=.*//' | grep -i zsh | wc -l 0 Clean it all up. $ _ANTIGEN_BUNDLE_RECORD=() $ antigen-cleanup --force &> /dev/null Specify with indentation. $ echo " $PLUGIN_DIR\n $PLUGIN_DIR2" | antigen-bundles &> /dev/null Again, check if they are both applied. $ hehe hehe $ hehe2 hehe2 Handle GREP_OPTIONS gracefully. $ GREP_OPTIONS="--color=always " $ echo " $PLUGIN_DIR\n $PLUGIN_DIR2" | antigen-bundles Check if they are both applied. $ hehe hehe $ hehe2 hehe2 antigen-2.2.3/tests/cache.t000066400000000000000000000006711322326672200155460ustar00rootroot00000000000000Enable extension. $ export _ANTIGEN_INTERACTIVE=false $ antigen ext cache $ antigen ext-list cache $ ANTIGEN_CACHE=$ADOTDIR/init.zsh $ prev=$(env) $ antigen reset Done. Please open a new shell to see the changes. $ antigen list You don't have any bundles. [1] Can programatically generate cache. $ antigen reset &> /dev/null $ antigen cache-gen $ ls $ADOTDIR/init* .*init.zsh.* (re) .*init.zsh.zwc* (re) antigen-2.2.3/tests/cleanup.t000066400000000000000000000027421322326672200161330ustar00rootroot00000000000000Firstly, no plugins, nothing to cleanup. $ antigen-cleanup --force You don't have any bundles. Load the plugins. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ antigen-bundle $PLUGIN_DIR2 &> /dev/null Check the listing. $ antigen-list .*/test-plugin @ master (re) .*/test-plugin2 @ master (re) Nothing should be available for cleanup. $ antigen-cleanup --force You don't have any unidentified bundles. Clear out the bundles record. $ _ANTIGEN_BUNDLE_RECORD=() Check the listing, after clearing the record. $ antigen-list You don't have any bundles. [1] Confirm the plugin directory exists. $ ls $ANTIGEN_BUNDLES | wc -l 1 Do the cleanup. $ antigen-cleanup --force You have clones for the following repos, but are not used. .*/test-plugin (re) .*/test-plugin2 (re) Deleting clone "*/test-plugin"... done. (glob) Deleting clone "*/test-plugin2"... done. (glob) Check the listing, after cleanup. $ antigen-list You don't have any bundles. [1] Confirm the plugin directory does not exist after cleanup. $ ls $ANTIGEN_BUNDLES/cram-testdir-* | wc -l 0 # TODO # Do not remove local bundles (--no-local-clone). # # $ ls $ANTIGEN_BUNDLES # # $ _ANTIGEN_BUNDLE_RECORD=() # $ antigen list &> /dev/null # [1] # $ antigen bundle $PLUGIN_DIR --no-local-clone # $ antigen apply &> /dev/null # $ antigen list --long # .*cleanup.t/test-plugin / plugin false (re) # # $ antigen cleanup --force # You don't have any bundles. antigen-2.2.3/tests/clone-dir.t000066400000000000000000000034101322326672200163510ustar00rootroot00000000000000Set up functions and env variables: $ ANTIGEN_LOG=/dev/stdout # We wanna see debug output $ function git() { echo "\ngit $@\n" } # Wrap git to avoid the network Bundles branches are stored in their own paths. $ -antigen-load () {} $ antigen bundle zsh-users/zsh-syntax-highlighting@example/branch Installing zsh-users/zsh-syntax-highlighting@example/branch... git clone .* --branch example/branch -- https://github.com/zsh-users/zsh-syntax-highlighting.git .*/bundles/zsh-users/zsh-syntax-highlighting-example-branch (re) Done. Took *s. (glob) There may be a dot-git suffix in branches names. $ antigen bundle https://github.com/user-name/zsh-bundle.git@feature/make-it-work.git Installing user-name/zsh-bundle@feature/make-it-work.git... git clone .* --branch feature/make-it-work.git -- https://github.com/user-name/zsh-bundle.git .*/bundles/user-name/zsh-bundle-feature-make-it-work.git (re) Done. Took *s. (glob) You may use a plugin from a library on an specific tag/branch. $ antigen bundle git@v1.2.3-1 Installing robbyrussell/oh-my-zsh@v1.2.3-1... git clone .* --branch v1.2.3-1 -- https://github.com/robbyrussell/oh-my-zsh.git .*/bundles/robbyrussell/oh-my-zsh-v1.2.3-1 (re) Done. Took *s. (glob) Naturally handle --branch flag. $ antigen bundle rupa/z --branch=0.0-1.x Installing rupa/z@0.0-1.x... git clone .* --branch 0.0-1.x -- https://github.com/rupa/z.git .*/bundles/rupa/z-0.0-1.x (re) Done. Took *s. (glob) There may be a dot-git suffix in bundle name. $ antigen bundle zsh/git-completions.git@git/v1.8.git Installing zsh/git-completions@git/v1.8.git... git clone .* --branch git/v1.8.git -- https://github.com/zsh/git-completions.git .*/bundles/zsh/git-completions-git-v1.8.git (re) Done. Took *s. (glob) antigen-2.2.3/tests/ensure-repo.t000066400000000000000000000023121322326672200167410ustar00rootroot00000000000000Set up functions and env variables: $ ANTIGEN_LOG=/dev/stdout # We wanna see debug output $ function git() { echo "git $@" } # Wrap git to avoid the network $ REPO_NAME=user/repo $ REPO_URL=https://github.com/$REPO_NAME.git Ensure repo default args missing url: $ -antigen-ensure-repo 2>&1 Antigen: Missing url argument. [1] Clones a repository if it's not cloned already: $ -antigen-ensure-repo $REPO_URL git clone .* --branch master -- https://github.com/user/repo.git .*user/repo (re) Ignore update argument if there is no repo cloned: $ -antigen-ensure-repo $REPO_URL true git clone .* --branch master -- https://github.com/user/repo.git .*user/repo (re) Effectively update a repository already cloned: $ mkdir -p $(-antigen-get-clone-dir $REPO_URL) # Fake repository clone $ -antigen-ensure-repo $REPO_URL true git --git-dir=.*/user/repo/.git .* checkout master (re) git --git-dir=.*/user/repo/.git .* pull origin master (re) git --git-dir=.*/user/repo/.git .* submodule update .* (re) Clone especific branch if required: $ rm -r $ANTIGEN_BUNDLES $ -antigen-ensure-repo "$REPO_URL|v5.0" git clone .* --branch v5.0 -- https://github.com/user/repo.git .*user/repo-v5.0 (re) antigen-2.2.3/tests/ext.t000066400000000000000000000047711322326672200153100ustar00rootroot00000000000000Set up $ alias hook=antigen-add-hook Call hook any function. $ hello () { > echo Hello. > } $ hello-fr () { > echo Bonjour. > } $ hook hello hello-fr replace $ hello Bonjour. Fail to create hook function if hooked function doesn't exists. $ help-fr () { > echo Help. > } $ hook help help-fr replace Antigen: Function help doesn't exist. [1] $ help zsh: command not found: help [127] Fail to create hook function if hook function doesn't exists. $ help () { > echo Help. > } $ hook help help-de replace Antigen: Function help-de doesn't exist. [1] $ help Help. Can create pre hook functions. $ hola () { > echo Hola. > } $ hola-en () { > echo Hello. > } $ hook hola hola-en pre $ hola Hello. Hola. Can create post hook functions. $ hola-pr () { > echo Olá. > } $ hook hola hola-pr post $ hola Hello. Hola. Olá. Can reset all hooks functions. $ -antigen-reset-hooks $ hola Hola. $ hook hola hola-en pre $ hola Hello. Hola. Can add multiple pre/post hook functions. $ -antigen-reset-hooks $ antigen-bundle () { > echo called antigen-bundle with $@ > } $ antigen-bundle desyncr/zsh-ctrlp --no-local-clone called antigen-bundle with desyncr/zsh-ctrlp --no-local-clone $ antigen-bundle-hook () { > echo "pre-hook: $@" > } $ hook antigen-bundle antigen-bundle-hook pre $ antigen-bundle-hook2 () { > echo "pre-hook2: $@" > } $ hook antigen-bundle antigen-bundle-hook2 pre $ antigen-bundle-hook-post () { > echo "post-hook: $@" > } $ hook antigen-bundle antigen-bundle-hook-post post $ antigen-bundle-hook-post2 () { > echo "post-hook2: $@" > } $ hook antigen-bundle antigen-bundle-hook-post2 post $ antigen-bundle example/bundle pre-hook: example/bundle pre-hook2: example/bundle called antigen-bundle with example/bundle post-hook: example/bundle post-hook2: example/bundle Example deferred function with hook. $ -antigen-reset-hooks $ typeset -a _bundle_deferred; _bundle_deferred=() $ antigen-bundle-deferred () { > _bundle_deferred+=($@) > } $ hook antigen-bundle antigen-bundle-deferred replace $ antigen-bundle zsh-users/zsh-syntax-highlighting $ antigen-bundle zsh-users/zsh-autocompletions $ echo $_bundle_deferred zsh-users/zsh-syntax-highlighting zsh-users/zsh-autocompletions $ antigen-remove-hook antigen-bundle-deferred $ antigen-bundle zsh-users/zsh-completions called antigen-bundle with zsh-users/zsh-completions antigen-2.2.3/tests/find-record.t000066400000000000000000000022071322326672200166740ustar00rootroot00000000000000Finds a given record with branch name. $ _ANTIGEN_BUNDLE_RECORD=('https://github.com/rupa/z.git|952f01375a2e28463a8abbaa54b4a038c74c8d82 / plugin true' > 'https://github.com/desyncr/watch.git|develop / plugin true' > 'https://github.com/zsh-users/zsh-autosuggestions.git / plugin true' > 'https://github.com/zsh-users/zsh-syntax-highlighting.git|0.5.* / plugin true 0.5.*') $ -antigen-find-record 'https://github.com/zsh-users/zsh-syntax-highlighting.git|0.5.*' https://github.com/zsh-users/zsh-syntax-highlighting.git|0.5.* / plugin true 0.5.* $ -antigen-find-record zsh-syntax-highlighting https://github.com/zsh-users/zsh-syntax-highlighting.git|0.5.* / plugin true 0.5.* $ -antigen-find-record 'syntax' https://github.com/zsh-users/zsh-syntax-highlighting.git|0.5.* / plugin true 0.5.* $ -antigen-find-record '0.5.*' https://github.com/zsh-users/zsh-syntax-highlighting.git|0.5.* / plugin true 0.5.* $ -antigen-find-record 'zsh-users' https://github.com/zsh-users/zsh-autosuggestions.git / plugin true $ -antigen-find-record 'true' https://github.com/rupa/z.git|952f01375a2e28463a8abbaa54b4a038c74c8d82 / plugin true antigen-2.2.3/tests/init.t000066400000000000000000000010641322326672200154430ustar00rootroot00000000000000Can source an dot-antigenrc file: $ zcache-cache-exists () { false } $ source () { echo $1 } $ antigen-init $ANTIGEN/tests/.antigenrc .*/.antigenrc (re) Returns error if non-existing file is given: $ zcache-cache-exists () { false } $ antigen-init /non-existing/file.zsh Antigen: invalid argument provided. [1] Can handle heredocs: $ zcache-cache-exists () { false } $ antigen () { echo $@ } $ antigen-init < antigen use library > antigen bundle bundle/name > antigen apply > EOB use library bundle bundle/name apply antigen-2.2.3/tests/list.t000066400000000000000000000035041322326672200154540ustar00rootroot00000000000000Empty initial listing. $ antigen-list You don't have any bundles. [1] Add a bundle. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ antigen-list .*/test-plugin @ master (re) Add same bundle and check uniqueness. $ antigen-bundle $PLUGIN_DIR $ antigen-list .*/test-plugin @ .* (re) Add another bundle. $ antigen-bundle $PLUGIN_DIR2 &> /dev/null $ antigen-list .*/test-plugin @ master (re) .*/test-plugin2 @ master (re) List command supports short format flag. $ antigen-list .*/test-plugin @ master (re) .*/test-plugin2 @ master (re) $ antigen-list --short .*/test-plugin @ master (re) .*/test-plugin2 @ master (re) $ antigen-list --long .*/test-plugin / plugin true (re) .*/test-plugin2 / plugin true (re) Can display feature branches. $ cd $PLUGIN_DIR2 $ git checkout -b feature-branch &> /dev/null $ git rev-parse --abbrev-ref '@' feature-branch $ antigen-list --short .*/test-plugin @ master (re) .*/test-plugin2 @ .* (re) $ antigen-list --long .*/test-plugin / plugin true (re) .*/test-plugin2 / plugin true (re) Find bundle/record internal function. $ -antigen-find-record [1] $ -antigen-find-record nonexisting $ -antigen-find-record test *test-plugin* (glob) $ -antigen-find-record test-plugin *test-plugin* (glob) $ -antigen-find-record test-plugin2 *test-plugin2* (glob) $ -antigen-find-record plugin2 *test-plugin2* (glob) $ -antigen-find-record test-plugin *test-plugin* (glob) $ -antigen-find-record test-plugin2 *test-plugin2* (glob) $ -antigen-find-record 'cram-testdir-*/test-plugin2' *cram-testdir-*/test-plugin2* (glob) List bundle no git repo. $ antigen bundle $PLUGIN_DIR4 $ antigen list *test-plugin @ master (glob) *test-plugin2 @ master (glob) *test-plugin4 @ master (glob) $ hello-world hello world antigen-2.2.3/tests/load.t000066400000000000000000000045661322326672200154310ustar00rootroot00000000000000Should respect load spec. $ -antigen-load-source () { > echo ${(j:\n:)list} > } Must load all .zsh found: $ antigen bundle $PLUGIN_DIR Installing .*/test-plugin... Done. Took .*s. (re) *aliases.zsh (glob) $ echo ${(j:\n:)PATH} .*/test-plugin (re) Must load all single .zsh: $ antigen bundle $PLUGIN_DIR aliases.zsh *aliases.zsh (glob) $ echo ${(j:\n:)PATH} .*/test-plugin (re) Must load single theme: $ antigen bundle $PLUGIN_DIR silly.zsh-theme *silly.zsh-theme (glob) $ echo ${(j:\n:)PATH} .*/test-plugin (re) Must load single init.zsh: $ antigen bundle $PLUGIN_DIR2 Installing .*/test-plugin2... Done. Took .*s. (re) *init.zsh (glob) $ echo ${(j:\n:)PATH} .*/test-plugin2 (re) Must add plugin directory to PATH: $ antigen bundle $PLUGIN_DIR3 Installing .*/test-plugin3... Done. Took .*s. (re) $ echo ${(j:\n:)PATH} .*/test-plugin3 (re) Handle non-git plugin: $ antigen bundle $PLUGIN_DIR4 $ echo ${(j:\n:)PATH} .*/test-plugin4 (re) Can load from version: $ -antigen-load-source () { > echo ${(j:\n:)list} > source ${list} > } $ antigen bundle "$PLUGIN_DIR5@v1.*" Installing .*/test-plugin5@v1.*... Done. Took .*s. (re) .*test-plugin5-v1.x///version.zsh (re) $ echo ${(j:\n:)PATH} .*/test-plugin5-v1.* (re) $ echo $VERSION v1.1.4 $ antigen bundle "$PLUGIN_DIR5@v0.0.*" Installing .*/test-plugin5@v0.0.*... Done. Took .*s. (re) .*test-plugin5-v0.0.x///version.zsh (re) $ echo ${(j:\n:)PATH} .*/test-plugin5-v0.0.x (re) $ echo $VERSION v0.0.2 $ antigen bundle "$PLUGIN_DIR5@v*" Installing .*/test-plugin5@v.*... Done. Took .*s. (re) .*test-plugin5-vx///version.zsh (re) $ echo ${(j:\n:)PATH} .*/test-plugin5-vx (re) $ echo $VERSION v3 $ antigen bundle "$PLUGIN_DIR5@v0.0.1" Installing .*/test-plugin5@v0.0.1... Done. Took .*s. (re) .*test-plugin5-v0.0.1///version.zsh (re) $ echo ${(j:\n:)PATH} .*/test-plugin5-v0.0.1 (re) $ echo $VERSION v0.0.1 $ antigen bundle "$PLUGIN_DIR5@stable" Installing .*/test-plugin5@stable... Done. Took .*s. (re) .*test-plugin5-stable///version.zsh (re) $ echo ${(j:\n:)PATH} .*/test-plugin5-stable (re) $ echo $VERSION initial $ antigen bundle "$PLUGIN_DIR5" Installing .*/test-plugin5... Done. Took .*s. (re) .*test-plugin5///version.zsh (re) $ echo ${(j:\n:)PATH} .*/test-plugin5 (re) $ echo $VERSION v3 antigen-2.2.3/tests/no_local_clone.t000066400000000000000000000016451322326672200174530ustar00rootroot00000000000000Load the plugin with no local clone. $ antigen-bundle $PLUGIN_DIR --no-local-clone Check if the plugin is loaded correctly. $ hehe hehe Confirm no clone is made. $ ls $ANTIGEN_BUNDLES Load the plugin with a clone. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ ls $ANTIGEN_BUNDLES cram-testdir-* (glob) Empty the record. $ _ANTIGEN_BUNDLE_RECORD=() $ antigen-list You don't have any bundles. [1] Load the plugin again with no local clone. $ antigen-bundle $PLUGIN_DIR --no-local-clone $ antigen list cram-testdir-*/test-plugin @ master (glob) $ ls $ANTIGEN_BUNDLES cram-testdir-* (glob) The cleanup should list the bundle's clone. $ _ANTIGEN_BUNDLE_RECORD=() $ antigen-cache-gen $ antigen-cleanup --force You have clones for the following repos, but are not used. .*/test-plugin (re) Deleting clone ".*/test-plugin"... done. (re) $ ls $ANTIGEN_BUNDLES/cram-testdir-* antigen-2.2.3/tests/purge.t000066400000000000000000000010631322326672200156210ustar00rootroot00000000000000Purge command removes a bundle from filesystem. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ antigen-list | grep test-plugin *test-plugin* (glob) $ antigen-purge test-plugin --force Removing '*test-plugin'. (glob) Done. Please open a new shell to see the changes. Purge command without arguments returns an error message. $ antigen-purge Antigen: Missing argument. [1] Purge command return an error if bundle is not found. $ antigen-purge unexisting-bundle Bundle not found in record. Try 'antigen bundle unexisting-bundle' first. [1] antigen-2.2.3/tests/revert-update.t000066400000000000000000000021031322326672200172620ustar00rootroot00000000000000Load and test plugin. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ hehe hehe Save the current HEAD of the plugin. $ old_version="$(pg rev-parse HEAD)" Modify the plugin. $ cat > $PLUGIN_DIR/aliases.zsh < alias hehe='echo hehe, updated' > EOF $ pg commit -am 'Updated message' \[master [a-f0-9]{7}\] Updated message (re) 1 file changed, 1 insertion(+), 1 deletion(-) Save the new HEAD of the plugin. $ new_version="$(pg rev-parse HEAD)" Define a convenience function to get the current version. $ current-version () {(cd $ANTIGEN_BUNDLES/*/* && git rev-parse HEAD)} Confirm we currently have the old version. $ [[ $(current-version) == $old_version ]] Run antigen's update. $ antigen-update Updating */test-plugin@master... Done. Took *s. (glob) Confirm we have the new version. $ [[ $(current-version) == $new_version ]] Run update again, with no changes in the origin repo. $ antigen-revert Reverted to state before running -update on *. (glob) Confirm we have the old version again. $ [[ $(current-version) == $old_version ]] antigen-2.2.3/tests/selfupdate.t000066400000000000000000000037461322326672200166450ustar00rootroot00000000000000Set environment variables for this test case $ TEST_DIR=$PWD $ TEST_HOST=$TEST_DIR/host $ TEST_NORMAL=$TEST_DIR/client $ TEST_SUBMODULE=$TEST_DIR/submodule Create fake host repository $ mkdir -p $TEST_HOST $ cd $TEST_HOST $ git init Initialized empty Git repository in * (glob) $ git config user.name 'test' $ git config user.email 'test@test.test' $ echo 1 > ver $ git add ver $ git commit -m "1" [master (root-commit) ???????] 1 (glob) 1 file changed, 1 insertion(+) create mode 100644 ver Create a normal repository cloning from host $ git clone $TEST_HOST $TEST_NORMAL &> /dev/null Create a submodule repository cloning from host $ mkdir -p $TEST_SUBMODULE $ cd $TEST_SUBMODULE $ git init Initialized empty Git repository in * (glob) $ git config user.name 'test' $ git config user.email 'test@test.test' $ git submodule add $TEST_HOST antigen &> /dev/null $ git commit -m "1" [master (root-commit) ???????] 1 (glob) 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 antigen Update host repository $ cd $TEST_HOST $ echo 2 > ver $ git add ver $ git commit -m "2" [master ???????] 2 (glob) 1 file changed, 1 insertion(+), 1 deletion(-) Use selfupdate from normal repository $ _ANTIGEN_INSTALL_DIR=$TEST_NORMAL antigen-selfupdate From * (glob) ???????..??????? master -> origin/master (glob) Updating ???????..??????? (glob) Fast-forward ver |*2 +- (glob) 1 file changed, 1 insertion(+), 1 deletion(-) $ _ANTIGEN_INSTALL_DIR=$TEST_NORMAL antigen-selfupdate Already up-to-date. Use selfupdate from submodule repository $ _ANTIGEN_INSTALL_DIR=$TEST_SUBMODULE/antigen antigen-selfupdate From * (glob) ???????..??????? master -> origin/master (glob) Updating ???????..??????? (glob) Fast-forward ver |*2 +- (glob) 1 file changed, 1 insertion(+), 1 deletion(-) $ _ANTIGEN_INSTALL_DIR=$TEST_SUBMODULE/antigen antigen-selfupdate Already up-to-date. antigen-2.2.3/tests/snapshots.t000066400000000000000000000014401322326672200165200ustar00rootroot00000000000000Load a couple of plugins. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ antigen-bundle $PLUGIN_DIR2 &> /dev/null Create a snapshot file. $ test -f snapshot-file [1] $ antigen-snapshot snapshot-file $ test -f snapshot-file See the contents of the snapshot file. $ cat snapshot-file version='1'; created_on='*'; checksum='*'; (glob) .{40} .*/test-plugin (re) .{40} .*/test-plugin2 (re) Reset the antigen's bundle record and run cleanup. $ unset _ANTIGEN_BUNDLE_RECORD $ antigen-cleanup --force | grep '^Deleting' | wc -l 2 Restore from the snapshot. $ ls $ANTIGEN_BUNDLES/cram-testdir-* | wc -l 0 $ antigen-restore snapshot-file Restoring from snapshot-file... done. Please open a new shell to get the restored changes. $ ls $ANTIGEN_BUNDLES/* | wc -l 2 antigen-2.2.3/tests/theme.t000066400000000000000000000030261322326672200156020ustar00rootroot00000000000000Load the theme explicitly. $ antigen-theme $PLUGIN_DIR silly &> /dev/null $ echo "$PS1" prompt> $ antigen-theme $PLUGIN_DIR wrong Antigen: Failed to load theme. [1] Theme should be listed correctly in antigen-list. $ antigen-list | wc -l 1 Should be registered correctly in BUNDLE_RECORD. $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | grep theme | wc -l 1 $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | grep theme *silly.zsh-theme* (glob) Load a second theme in the same session. $ antigen-theme $PLUGIN_DIR arrow &> /dev/null $ echo "$PS1" > Second theme is listed as expected in antigen-list. $ antigen-list | wc -l 1 $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | grep theme *arrow* (glob) Should be registered correctly in BUNDLE_RECORD. $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | grep theme | wc -l 1 $ echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} | grep theme *arrow.zsh-theme* (glob) Using the same theme does not change anything. $ antigen-theme $PLUGIN_DIR arrow $ antigen-list --long *arrow* (glob) $ antigen-theme $PLUGIN_DIR arrow &> /dev/null $ antigen-list --long | grep arrow *arrow* (glob) Can load a theme without specifying a theme name: $ antigen-theme $PLUGIN_DIR $ antigen-list --long | grep arrow *arrow* (glob) Do not change current directory. $ cd /tmp/ $ antigen-theme $PLUGIN_DIR $ antigen-list --long | grep arrow *arrow* (glob) $ pwd /tmp Do not provide a default theme name value. $ antigen-theme Antigen: Must provide a theme url or name. [1] antigen-2.2.3/tests/update.t000066400000000000000000000024571322326672200157710ustar00rootroot00000000000000Load plugin. $ antigen-bundle $PLUGIN_DIR &> /dev/null $ hehe hehe Update the plugin. $ cat > $PLUGIN_DIR/aliases.zsh < alias hehe='echo hehe, updated' > EOF $ pg commit -am 'Updated message' \[master [a-f0-9]{7}\] Updated message (re) 1 file changed, 1 insertion(+), 1 deletion(-) Run antigen's update. $ antigen-update Updating */test-plugin@master... Done. Took *s. (glob) Confirm there is still only one repository. $ ls $ANTIGEN_BUNDLES | wc -l 1 The new alias should not activate. $ hehe hehe Run update again, with no changes in the origin repo. $ antigen-update Updating */test-plugin@master... Done. Took *s. (glob) Load another bundle. $ antigen-bundle $PLUGIN_DIR2 &> /dev/null Run antigen's update for the bundle. $ antigen-update $PLUGIN_DIR Updating */test-plugin@master... Done. Took *s. (glob) $ antigen-update $PLUGIN_DIR2 Updating */test-plugin2@master... Done. Took *s. (glob) Run update again, should update both bundles. $ antigen-update Updating */test-plugin@master... Done. Took *s. (glob) Updating */test-plugin2@master... Done. Took *s. (glob) Trying to update an unexisting bundle gives an error. $ antigen-update /tmp/example/non-existing-bundle Bundle not found in record. Try 'antigen bundle *' first. (glob) [1] antigen-2.2.3/tests/url-resolver.t000066400000000000000000000017301322326672200171410ustar00rootroot00000000000000Helper alias. $ resolve () {typeset -A response; -antigen-parse-args 'response' $1; echo "${response[url]}" } Complete urls. $ resolve https://github.com/zsh-users/antigen.git https://github.com/zsh-users/antigen.git $ resolve git://github.com/zsh-users/antigen.git git://github.com/zsh-users/antigen.git $ resolve git@github.com:zsh-users/antigen.git git@github.com:zsh-users/antigen.git Complete github urls, missing the `.git` suffix. $ resolve https://github.com/zsh-users/antigen https://github.com/zsh-users/antigen $ resolve git://github.com/zsh-users/antigen git://github.com/zsh-users/antigen $ resolve git@github.com:zsh-users/antigen git@github.com:zsh-users/antigen Just username and repo name. $ resolve zsh-users/antigen https://github.com/zsh-users/antigen.git $ resolve zsh-users/antigen.git https://github.com/zsh-users/antigen.git Local absolute file path. $ resolve /path/to/a/local/git/repo /path/to/a/local/git/repo antigen-2.2.3/tests/use.t000066400000000000000000000046221322326672200152770ustar00rootroot00000000000000Use url library. $ antigen-bundle () { echo $@ } $ antigen-use https://github.com/zsh-users/prezto.git https://github.com/zsh-users/prezto.git $ echo $ANTIGEN_DEFAULT_REPO_URL https://github.com/zsh-users/prezto.git Accept antigen-bundle semantics. $ antigen-bundle () { echo $@ } $ antigen-use https://github.com/zsh-users/prezto.git --loc=lib https://github.com/zsh-users/prezto.git --loc=lib Missing argument. $ antigen-use Usage: antigen-use Where is any one of the following: * oh-my-zsh * prezto is the full url. [1] Mock out the library loading functions. $ -antigen-use-oh-my-zsh () { echo Using oh-my-zsh. } $ -antigen-use-prezto () { echo Using prezto. } Note: We lack tests for these internal functions. I'm not sure how feasible testing them is given they most certainly use the network. Use oh-my-zsh library. $ prev=$(env) $ antigen-use oh-my-zsh Using oh-my-zsh. Should not leak Antigen or OMZ environment variables. $ diff <(env) <(echo $prev) | sed -e 's/\=.*//' | grep -i antigen | wc -l 0 $ diff <(env) <(echo $prev) | sed -e 's/\=.*//' | grep -i zsh | wc -l 0 Use prezto library. $ antigen-use prezto Using prezto. Test load from oh-my-zsh: $ unset ANTIGEN_DEFAULT_REPO_URL $ source $ANTIGEN/antigen.zsh $ -antigen-bundle-install () {} $ -antigen-load () {} $ antigen use oh-my-zsh $ antigen bundle wd $ antigen bundle other/plugin $ antigen apply $ antigen list --long https://github.com/robbyrussell/oh-my-zsh.git lib plugin true https://github.com/robbyrussell/oh-my-zsh.git plugins/wd plugin true https://github.com/other/plugin.git / plugin true Test load from prezto: $ _ANTIGEN_BUNDLE_RECORD=() $ antigen use prezto $ antigen bundle editor $ antigen bundle other/plugin $ antigen apply $ antigen list --long https://github.com/sorin-ionescu/prezto.git / plugin true https://github.com/sorin-ionescu/prezto.git modules/editor plugin true https://github.com/other/plugin.git / plugin true Test load from custom library: $ _ANTIGEN_BUNDLE_RECORD=() $ antigen use https://github.com/custom/library.git $ antigen bundle editor $ antigen bundle other/plugin $ antigen apply $ antigen list --long https://github.com/custom/library.git / plugin true https://github.com/custom/library.git editor plugin true https://github.com/other/plugin.git / plugin true antigen-2.2.3/tests/version.t000066400000000000000000000002351322326672200161640ustar00rootroot00000000000000Antigen version command. $ antigen-version Antigen * (glob) Revision date: * (glob) $ antigen version Antigen * (glob) Revision date: * (glob) antigen-2.2.3/tools/000077500000000000000000000000001322326672200143105ustar00rootroot00000000000000antigen-2.2.3/tools/builder000077500000000000000000000034031322326672200156640ustar00rootroot00000000000000#!/usr/bin/env zsh # vim: ts=2 sw=2 et typeset -g ZSH_REMOTE_URL; ZSH_REMOTE_URL=https://github.com/zsh-users/zsh.git typeset -g ZSH_SOURCE_LOCATION; ZSH_SOURCE_LOCATION=/usr/local/share/zsh typeset -g ZSH_BIN_LOCATION; ZSH_BIN_LOCATION=/usr/local/bin/zsh # Build and install zsh version from source function builder/usage () { echo "Usage: $0 --source /path/to/source --target /path/to/target --version ZSH_VERSION" } function builder/main () { zparseopts -A opts s:=src -source:=src \ v:=version -version:=version t=target -target=target || builder/usage local src=$src[2] if [[ -z $src ]]; then src="${ZSH_SOURCE_LOCATION}" fi local version=$version[2] local target=$target[2] if [[ -z $target ]]; then target="${ZSH_BIN_LOCATION}-$version" fi builder/exec $src $target $version } function builder/exec () { local src=$1 local target=$2 local version=$3 # zsh source already exists if [[ ! -d $src/.git ]]; then echo "No zsh source found. Cloning from $ZSH_REMOTE_URL" git clone $ZSH_REMOTE_URL $src fi # Get the code. Should cache it. builder/compile $src $target $version } function builder/compile () { local src=$1 local target=$2 local version=$3 echo "Compiling zsh version: $version from $src to $target" cd $src || exit 1 # Build version # Be sure to clean everything make clean git clean -fd git checkout -- . # Check out with branch to build, ie: master, zsh-5.0.1, etc git checkout $version || exit 1 # Make configure ./Util/preconfig if [[ ! -d $target ]]; then mkdir -p $target fi # Configure bindir for this branch ./configure --bindir="$target/$version" --prefix="$target/$version"--without-tcsetpgrp # Make make -j5 make install cd - } builder/main $@ antigen-2.2.3/tools/jail000077500000000000000000000051271322326672200151620ustar00rootroot00000000000000#!/usr/bin/env zsh # vim: sw=2 ts=2 et JAIL=${1:-/tmp/jail-gen} JAIL_WRAPPER='chroot $jail sh -c "%s"' function jail/configure () { if [[ -n $(unshare -V 2>/dev/null | grep '2.28.*') ]]; then JAIL_WRAPPER="unshare -r sh -c 'chroot $jail sh -c \"%s\"'" fi } function jail/usage () { echo "Usage: $0 [-j|--jail] /path/to/jail [-i|--install|-c|--create|-k|--kill] [-e|--exec] exec" } function jail/main () { zparseopts -A opts j:=jail -jail:=jail \ e:=exec -exec:=exec c=create -create=create k=kill -kill=kill \ i=install -install=install local jail=$jail[2] local exec=$exec[2] local create=$create local kill=$kill local install=$install jail/configure if [[ -n $create ]]; then jail/create $jail elif [[ -n $kill ]]; then jail/kill $jail elif [[ -n $exec ]]; then jail/exec $jail "$exec" elif [[ -n $install ]]; then jail/install else echo Missing arguments. jail/usage exit 1 fi return 0 } function jail/create () { local jail=$1 if [[ -d $jail ]]; then echo Jail directory already exists. Abort. exit 1 fi # Create jail if there is none available jailing --root $jail --bind /usr/local if (( $? != 0 )); then echo Failed to create jail. exit 1 fi # add zsh builds on travis if [[ -d /home/travis/.zsh-builds ]]; then echo Custom zsh-build found. Binding. jailing --root $jail --bind /home/travis/.zsh-builds:/builds jailing --root $jail --bind /home/travis/.zsh-builds else echo No custom zsh-build found. Ignoring. fi echo Fix access to dev/null. echo --\> rm $jail/dev/null rm $jail/dev/null && cp /dev/null $jail/dev/null chmod a+rwx $jail/dev/null echo Mount missing /proc echo --\> mkdir -p $jail/proc mkdir -p $jail/proc && mount -t proc proc $jail/proc echo Add root user configs mkdir -p $jail/root && cp ${0:A:h:h}/tests/.gitconfig $jail/root/ echo Creating antigen dir echo --\> chmod a+rwx $jail/antigen/ mkdir $jail/antigen/ && chmod a+rwx $jail/antigen/ echo Done! exit 0 } function jail/kill () { local jail=$1 jailing --root $jail --umount } function jail/exec () { local jail=$1 eval $(printf $JAIL_WRAPPER "export HOME=/root; export ZDOTDIR=/antigen/tests; $2") } function jail/install () { if [[ ! -f /usr/bin/jailing ]]; then sudo git clone https://github.com/kazuho/jailing /usr/local/share/jailing || echo "Error creating jailing clone." cd /usr/local/share/jailing || exit 1 perl Makefile.PL make && make install echo Jailing installed. else echo Jailing bin already exists. Abort. fi } jail/main "$@" antigen-2.2.3/tools/stats000077500000000000000000000052301322326672200153740ustar00rootroot00000000000000#!/usr/bin/env zsh # vim: sw=2 ts=2 et #set -x typeset -g ITERATIONS; ITERATIONS=20 function stats/usage () { echo "Usage: $0 --zsh /path/to/zsh --antigen /path/to/antigen" } # Usage: # stats/main $@ function stats/main () { zparseopts -A opts z:=zsh -zsh:=zsh \ a:=antigen -antigen:=antigen || stats/usage local zsh=$zsh[2] local antigen=$antigen[2] if [[ ! -f "$zsh" ]]; then if (( ! $+commands[zsh] )); then echo "Define the path to ZSH binary with '--zsh' argument. Given: $zsh" exit 1 fi fi if [[ ! -d "$antigen" ]]; then echo "Define a path to Antigen with '--antigen' argument. Given: $antigen" exit 1 fi echo "Using zsh: $zsh ($($zsh --version))" echo "Using Antigen from: $antigen ($(cat $antigen/VERSION || echo unknown))" local antigenrc=$(mktemp -d /tmp/dot-antigen-stats-XXXXXX) local mtime=$antigenrc/stats-time.log stats/configure $antigenrc $antigen stats/exec $zsh $mtime $ITERATIONS stats/parse $mtime } # Usage # stats/configure $ADOTDIR /path/to/zshrc_antigenrc function stats/configure () { export ADOTDIR=$1 local configs=$2 export ZDOTDIR=$ADOTDIR mkdir -p $ADOTDIR cp $configs/tests/.antigenrc $ADOTDIR # Fix path for non-container based stats sed -e "s|/antigen/tests|$ADOTDIR|" -e "s|/antigen|$configs|" $configs/tests/.zshrc > $ADOTDIR/.zshrc echo "Antigen configuration path: $ADOTDIR" echo "Using zsh configuration from: $ADOTDIR/.zshrc" echo "System information:" uname -a lscpu echo echo "Configuration:" echo ">>>>" cat $ADOTDIR/.zshrc echo "<<<<" echo echo "Antigen configuration:" echo ">>>>" cat $ADOTDIR/.antigenrc echo "<<<<" echo } # Usage: # stats/exec $path_to_zsh $path_to_output_file $iterations_count function stats/exec() { local zsh=$1 local output=$2 local iterations=${3:-20} export ANTIGEN=$ADOTDIR echo Installing bundles... if [[ -d $ADOTDIR/bundles || -d $ADOTDIR/repos ]]; then echo Bundles present in ADOTDIR. fi $zsh -ic 'exit' if [[ $? != 0 ]]; then exit 1 fi echo echo Installed bundles: $zsh -ic 'antigen list' if [[ $? != 0 ]]; then exit 1 fi echo echo Performance testing... :> $output for x in $(seq 1 $iterations); do (time $zsh -ic exit) 2>&1 | tr "\n" ' ' &>> $output echo &>> $output tail -1 $output done } # Usage: # stats/parse $path_to_output_file function stats/parse() { local data=$1 awk '{ sub("m","",$7); total += $7; sub("m","", $1); user += $1; sub("m", "", $3); sys += $3; count++ } END { printf "\nAverage:\ntotal %.3fs user %.3fs sys %.3fs\n", total/count, user/count, sys/count }' $data } stats/main $@