Showing preview only (233K chars total). Download the full file or copy to clipboard to get everything.
Repository: zsh-users/antigen
Branch: develop
Commit: 64de2dcd95d6
Files: 90
Total size: 214.1 KB
Directory structure:
gitextract_aery0qe1/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── LICENSE
├── Makefile
├── Makefile.in
├── README.mkd
├── VERSION
├── antigen.zsh
├── bin/
│ └── antigen.zsh
├── configure
├── src/
│ ├── _antigen
│ ├── antigen.zsh
│ ├── boot.zsh
│ ├── commands/
│ │ ├── apply.zsh
│ │ ├── bundle.zsh
│ │ ├── bundles.zsh
│ │ ├── cleanup.zsh
│ │ ├── help.zsh
│ │ ├── init.zsh
│ │ ├── list.zsh
│ │ ├── purge.zsh
│ │ ├── reset.zsh
│ │ ├── restore.zsh
│ │ ├── revert.zsh
│ │ ├── self-update.zsh
│ │ ├── snapshot.zsh
│ │ ├── theme.zsh
│ │ ├── update.zsh
│ │ ├── use.zsh
│ │ └── version.zsh
│ ├── ext/
│ │ ├── cache.zsh
│ │ ├── defer.zsh
│ │ ├── ext.zsh
│ │ ├── lock.zsh
│ │ └── parallel.zsh
│ ├── helpers/
│ │ ├── bundle-rev.zsh
│ │ ├── bundle-short-name.zsh
│ │ ├── echo-record.zsh
│ │ ├── find-bundle.zsh
│ │ ├── find-record.zsh
│ │ ├── get-bundles.zsh
│ │ ├── get-clone-dir.zsh
│ │ ├── get-cloned-bundles.zsh
│ │ ├── get-themes.zsh
│ │ ├── interactive-mode.zsh
│ │ ├── parse-branch.zsh
│ │ └── update-repos.zsh
│ └── lib/
│ ├── ensure-repo.zsh
│ ├── env-setup.zsh
│ ├── load.zsh
│ ├── log.zsh
│ ├── parse-args.zsh
│ ├── revert-info.zsh
│ ├── use-oh-my-zsh.zsh
│ └── use-prezto.zsh
├── tests/
│ ├── .gitconfig
│ ├── .zshenv
│ ├── antigen-wrapper.t
│ ├── apply.t
│ ├── arg-parser.t
│ ├── branch-bundle.t
│ ├── bundle-syntaxes.t
│ ├── bundle.t
│ ├── bundles.t
│ ├── cache.t
│ ├── cleanup.t
│ ├── clone-dir.t
│ ├── ensure-repo.t
│ ├── ext.t
│ ├── find-record.t
│ ├── init.t
│ ├── list.t
│ ├── load.t
│ ├── no_local_clone.t
│ ├── purge.t
│ ├── revert-update.t
│ ├── selfupdate.t
│ ├── snapshots.t
│ ├── theme.t
│ ├── update.t
│ ├── url-resolver.t
│ ├── use.t
│ └── version.t
└── tools/
├── builder
├── jail
└── stats
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# 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
================================================
FILE: .travis.yml
================================================
sudo: required
dist: trusty
language: generic
services:
- docker
cache:
pip: true
env:
global:
- USE_CONTAINER=docker
matrix:
include:
- os: linux
env: ZSH_VERSION=zsh-5.7
- os: linux
env: ZSH_VERSION=zsh-5.6
- os: linux
env: ZSH_VERSION=zsh-5.5
- 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"
================================================
FILE: CHANGELOG.md
================================================
# 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
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# 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/)
================================================
FILE: CONTRIBUTING.md
================================================
# 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.
>
> `<url>` - 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/<your-username>/<repo-name>
# Navigate to the newly cloned directory
cd <repo-name>
# 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 <dev-branch>
git pull upstream <dev-branch>
```
3. Create a new topic branch (off the main project development branch `develop`) to
contain your feature, change, or fix:
```bash
git checkout -b <topic-branch-name>
```
> Please use `documentation/<descriptive-branch-name>`, `feature/<descriptive-branch-name>` or `bugfix/<descriptive-branch-name>` 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 <dev-branch>
```
6. Push your topic branch up to your fork:
```bash
git push origin <topic-branch-name>
```
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.
================================================
FILE: ISSUE_TEMPLATE.md
================================================
Description
-----------
Small paragraph to describe the issue/bug.
Steps to reproduce
------------------
Minimal steps to reproduce this behavior. Example:
1 - Open terminal
2 - cd<TAB>
3 - 'compinit not found...' is displayed
Expected behavior:
- Tab completion of `cd` command.
## Software version
- `antigen version`
- `zsh --version`
- `uname -a`
## Configuration
- gist of `.antigenrc`
- gist of `.zshrc`
## More information
Screenshot or any other information you may find relevant to troubleshoot the issue.
================================================
FILE: LICENSE
================================================
The 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.
================================================
FILE: Makefile
================================================
######################################################################
# 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 <https://github.com/zsh-users/antigen/contributors>\n\
\# Homepage: http://antigen.sharats.me\n\
\# License: MIT License <mitl.sharats.me>\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
================================================
FILE: Makefile.in
================================================
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 <https://github.com/zsh-users/antigen/contributors>\n\
\# Homepage: http://antigen.sharats.me\n\
\# License: MIT License <mitl.sharats.me>\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
================================================
FILE: README.mkd
================================================
<h1 align="center">
<a href="https://github.com/zsh-users/antigen"><img src="antigen.png" alt="Antigen"></a>
<br>
Antigen <sup>v2</sup>
</h1>
<h4 align="center">The plugin manager for zsh.</h2>
<p align="center">
<a href="https://github.com/zsh-users/antigen/releases/latest"><img src="https://img.shields.io/github/release/zsh-users/antigen.svg?label=latest" alt="Latest"></a> <a href="http://travis-ci.org/zsh-users/antigen"><img src="https://img.shields.io/travis/zsh-users/antigen/develop.svg?label=develop" alt="Build Status"></a> <a href="http://travis-ci.org/zsh-users/antigen"><img src="https://img.shields.io/travis/zsh-users/antigen/next.svg?label=next" alt="Build Status"></a>
</p>
<p align="center">
<a href="#installation">Installation</a> | <a href="https://github.com/zsh-users/antigen/wiki">Documentation</a> | <a href="https://github.com/zsh-users/antigen/issues">Bug tracker</a> | <a href="https://trello.com/b/P0xrGgfT/antigen">Roadmap</a> | <a href="https://gitter.im/antigen-zsh/develop">Chat</a> | <a href="http://mit.sharats.me/">License</a>
</p>
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.
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
================================================
FILE: VERSION
================================================
develop
================================================
FILE: antigen.zsh
================================================
_ANTIGEN_INSTALL_DIR=${0:A:h}
source $_ANTIGEN_INSTALL_DIR/bin/antigen.zsh
================================================
FILE: bin/antigen.zsh
================================================
######################################################################
# This file was autogenerated by `make`. Do not edit it directly!
######################################################################
# Antigen: A simple plugin manager for zsh
# Authors: Shrikant Sharat Kandula
# and Contributors <https://github.com/zsh-users/antigen/contributors>
# Homepage: http://antigen.sharats.me
# License: MIT License <mitl.sharats.me>
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.
# <repo-url>, <plugin-location>, <bundle-type>, <has-local-clone>
[[ $_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
antigen-help >&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=<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'
# Set up configured theme
-antigen-set-default _ANTIGEN_THEME ''
# 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 <args...>
-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 <url> [<loc>=/]
# 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 <record>
# 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 <<EOF
Antigen is a plugin management system for zsh. It makes it easy to grab awesome
shell scripts and utilities, put up on Github.
Usage: antigen <command> [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 <<EOBUNDLES
# antigen use oh-my-zsh
#
# antigen bundle zsh/bundle
# antigen bundle zsh/example
#
# antigen theme zsh/theme
#
# antigen apply
# EOBUNDLES
#
# Returns
# Nothing
antigen-init () {
local src="$1" line
# If we're given an argument it should be a path to a file
if [[ -n "$src" ]]; then
if [[ -f "$src" ]]; then
source "$src"
return
else
printf "Antigen: invalid argument provided.\n" >&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:
# <version-hash> <repo-url>
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 [path] [zsh/theme[.zsh-theme]]
#
# Returns
# 0 if everything was succesfully
antigen-theme () {
local name=$1 result=0 record=$1
# Verify arguments are passed properly.
if [[ -z "$name" ]]; then
printf "Antigen: Must provide a theme url or name.\n" >&2
return 1
fi
# Generate record name based off path and name for themes loaded from local paths,
# this also supports themes loaded from the same repository.
if [[ $name = */* ]]; then
record="$1 ${2:-/}"
fi
local match mbegin mend MATCH MBEGIN MEND
# Verify theme hasn't been loaded previously.
if [[ "$_ANTIGEN_THEME" == "$record" ]]; then
printf "Antigen: Theme \"%s\" is already active.\n" $name >&2
return 1
fi
# Remove currently active hooks, this may leave the prompt broken if the
# new theme is not found/can not be loaded. We should have a way to test if
# a theme/bundle can be loaded/exists.
#-antigen-theme-reset-hooks
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=$?
# Do remove theme record if we're successful at loading this one.
if [[ $result == 0 ]]; then
# Remove theme from record if there was one registered.
if [[ "$_ANTIGEN_THEME" != "" && $_ANTIGEN_BUNDLE_RECORD[(I)*$_ANTIGEN_THEME*] > 0 ]]; then
_ANTIGEN_BUNDLE_RECORD[$_ANTIGEN_BUNDLE_RECORD[(I)*$_ANTIGEN_THEME*]]=()
fi
# Set new theme as active.
_ANTIGEN_THEME=$record
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 <library-name|url>' >&2
echo 'Where <library-name> is any one of the following:' >&2
echo ' * oh-my-zsh' >&2
echo ' * prezto' >&2
echo '<url> is the full url.' >&2
return 1
fi
}
antigen-version () {
local extensions
printf "Antigen %s (%s)\nRevision date: %s\n" "develop" "d1dd78b" "2018-01-15 14:37:21 -0300"
# 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 <<EOC
#-- START ZCACHE GENERATED FILE
#-- GENERATED: $(date)
#-- ANTIGEN develop
$(functions -- _antigen)
antigen () {
local MATCH MBEGIN MEND
[[ "\$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "\$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] && source "$_ANTIGEN_INSTALL_DIR/antigen.zsh" && eval antigen \$@;
return 0;
}
typeset -gaU fpath path
fpath+=(${_fpath[@]}) path+=(${_PATH[@]})
_antigen_compinit () {
autoload -Uz compinit; compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP"; compdef _antigen antigen
add-zsh-hook -D precmd _antigen_compinit
}
autoload -Uz add-zsh-hook; add-zsh-hook precmd _antigen_compinit
compdef () {}
if [[ -n "$ZSH" ]]; then
ZSH="$ZSH"; ZSH_CACHE_DIR="$ZSH_CACHE_DIR"
fi
#--- BUNDLES BEGIN
${(j::)_sources}
#--- BUNDLES END
typeset -gaU _ANTIGEN_BUNDLE_RECORD; _ANTIGEN_BUNDLE_RECORD=($(print ${(qq)_ANTIGEN_BUNDLE_RECORD}))
typeset -g _ANTIGEN_CACHE_LOADED; _ANTIGEN_CACHE_LOADED=true
typeset -ga _ZCACHE_BUNDLE_SOURCE; _ZCACHE_BUNDLE_SOURCE=($(print ${(qq)_ZCACHE_BUNDLE_SOURCE}))
typeset -g _ANTIGEN_CACHE_VERSION; _ANTIGEN_CACHE_VERSION='develop'
typeset -g _ANTIGEN_THEME; _ANTIGEN_THEME='$_ANTIGEN_THEME'
#-- END ZCACHE GENERATED FILE
EOC
{ zcompile "$ANTIGEN_CACHE" } &!
# Compile config files, if any
LOG "CHECK_FILES $ANTIGEN_CHECK_FILES"
[[ $ANTIGEN_AUTO_CONFIG == true && -n $ANTIGEN_CHECK_FILES ]] && {
echo ${(j:\n:)ANTIGEN_CHECK_FILES} >! "$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 () {
# Return an error is not bundle name/url is passed or a heredoc is misused,
# see https://github.com/zsh-users/antigen/issues/602
if [[ $# -eq 0 ]]; then
printf "Antigen: Must provide a bundle url or name.\n" >&2
return 1
fi
_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 <path-to/location>]' \
'--url[Path to the repository <github-account/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
================================================
FILE: configure
================================================
#!/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 <<EOH
Usage:
./configure --with-option[=[yes|no]] --[enable|disable]-option
Available options:
- debug - Enable/disable debug library
- extensions - Enable/disable lock, parallel, cache and defer options
- lock - Enable/disable lock
- parallel - Enable/disable parallel
- cache - Enable/disable cache
- defer - Enable/disable defer
- completion - Enable/disable completion
All options are enabled by default.
Example:
# Disable lock, parallel, cache and defer
./configure --disable-extensions
# Disable completion
./configure --disable-completion
# Enable debug
./configure --with-debug
EOH
exit 0
fi
while [[ $# -gt 0 ]]; do
argkey="${1%\=*}"
key="${argkey//--/}"
if [[ $key = enable-* || $key = disable-* ]]; then
if [[ $1 = *=* ]]; then
printf "No options required for: %s (%s)\n" $argkey $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 <<EOM
${BANNER_SEP}
# This file was autogenerated by 'configure'. Do not edit it directly!
# Invocation was: $0 $arguments
${BANNER_SEP}
EOM
{
for config in ${(k)opts}; do
echo "${${config:u}//-/_}=${opts[$config]}"
done
echo ${BANNER_SEP}
cat Makefile.in
} >> $target
================================================
FILE: src/_antigen
================================================
#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 <path-to/location>]' \
'--url[Path to the repository <github-account/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
}
================================================
FILE: src/antigen.zsh
================================================
[[ -z "$_ANTIGEN_INSTALL_DIR" ]] && _ANTIGEN_INSTALL_DIR=${0:A:h}
# Each line in this string has the following entries separated by a space
# character.
# <repo-url>, <plugin-location>, <bundle-type>, <has-local-clone>
[[ $_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
antigen-help >&2
return 1
fi
shift
if (( $+functions[antigen-$cmd] )); then
"antigen-$cmd" "$@"
return $?
else
echo "Antigen: Unknown command: $cmd" >&2
return 1
fi
}
================================================
FILE: src/boot.zsh
================================================
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
================================================
FILE: src/commands/apply.zsh
================================================
# 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
}
================================================
FILE: src/commands/bundle.zsh
================================================
# Syntaxes
# antigen-bundle <url> [<loc>=/]
# 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 <record>
# 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
}
================================================
FILE: src/commands/bundles.zsh
================================================
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
}
================================================
FILE: src/commands/cleanup.zsh
================================================
# 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
}
================================================
FILE: src/commands/help.zsh
================================================
antigen-help () {
antigen-version
cat <<EOF
Antigen is a plugin management system for zsh. It makes it easy to grab awesome
shell scripts and utilities, put up on Github.
Usage: antigen <command> [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
}
================================================
FILE: src/commands/init.zsh
================================================
# 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 <<EOBUNDLES
# antigen use oh-my-zsh
#
# antigen bundle zsh/bundle
# antigen bundle zsh/example
#
# antigen theme zsh/theme
#
# antigen apply
# EOBUNDLES
#
# Returns
# Nothing
antigen-init () {
local src="$1" line
# If we're given an argument it should be a path to a file
if [[ -n "$src" ]]; then
if [[ -f "$src" ]]; then
source "$src"
return
else
printf "Antigen: invalid argument provided.\n" >&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
}
================================================
FILE: src/commands/list.zsh
================================================
# 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
}
================================================
FILE: src/commands/purge.zsh
================================================
# 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
}
================================================
FILE: src/commands/reset.zsh
================================================
# 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.'
}
================================================
FILE: src/commands/restore.zsh
================================================
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.'
}
================================================
FILE: src/commands/revert.zsh
================================================
# 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
}
================================================
FILE: src/commands/self-update.zsh
================================================
# 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
)
}
================================================
FILE: src/commands/snapshot.zsh
================================================
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:
# <version-hash> <repo-url>
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"
}
================================================
FILE: src/commands/theme.zsh
================================================
# Loads a given theme.
#
# Shares the same syntax as antigen-bundle command.
#
# Usage
# antigen-theme [path] [zsh/theme[.zsh-theme]]
#
# Returns
# 0 if everything was succesfully
antigen-theme () {
local name=$1 result=0 record=$1
# Verify arguments are passed properly.
if [[ -z "$name" ]]; then
printf "Antigen: Must provide a theme url or name.\n" >&2
return 1
fi
# Generate record name based off path and name for themes loaded from local paths,
# this also supports themes loaded from the same repository.
if [[ $name = */* ]]; then
record="$1 ${2:-/}"
fi
local match mbegin mend MATCH MBEGIN MEND
# Verify theme hasn't been loaded previously.
if [[ "$_ANTIGEN_THEME" == "$record" ]]; then
printf "Antigen: Theme \"%s\" is already active.\n" $name >&2
return 1
fi
# Remove currently active hooks, this may leave the prompt broken if the
# new theme is not found/can not be loaded. We should have a way to test if
# a theme/bundle can be loaded/exists.
#-antigen-theme-reset-hooks
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=$?
# Do remove theme record if we're successful at loading this one.
if [[ $result == 0 ]]; then
# Remove theme from record if there was one registered.
if [[ "$_ANTIGEN_THEME" != "" && $_ANTIGEN_BUNDLE_RECORD[(I)*$_ANTIGEN_THEME*] > 0 ]]; then
_ANTIGEN_BUNDLE_RECORD[$_ANTIGEN_BUNDLE_RECORD[(I)*$_ANTIGEN_THEME*]]=()
fi
# Set new theme as active.
_ANTIGEN_THEME=$record
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
}
================================================
FILE: src/commands/update.zsh
================================================
# 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
}
================================================
FILE: src/commands/use.zsh
================================================
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 <library-name|url>' >&2
echo 'Where <library-name> is any one of the following:' >&2
echo ' * oh-my-zsh' >&2
echo ' * prezto' >&2
echo '<url> is the full url.' >&2
return 1
fi
}
================================================
FILE: src/commands/version.zsh
================================================
antigen-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
}
================================================
FILE: src/ext/cache.zsh
================================================
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 <<EOC
#-- START ZCACHE GENERATED FILE
#-- GENERATED: $(date)
#-- ANTIGEN {{ANTIGEN_VERSION}}
$(functions -- _antigen)
antigen () {
local MATCH MBEGIN MEND
[[ "\$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "\$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] && source "$_ANTIGEN_INSTALL_DIR/antigen.zsh" && eval antigen \$@;
return 0;
}
typeset -gaU fpath path
fpath+=(${_fpath[@]}) path+=(${_PATH[@]})
_antigen_compinit () {
autoload -Uz compinit; compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP"; compdef _antigen antigen
add-zsh-hook -D precmd _antigen_compinit
}
autoload -Uz add-zsh-hook; add-zsh-hook precmd _antigen_compinit
compdef () {}
if [[ -n "$ZSH" ]]; then
ZSH="$ZSH"; ZSH_CACHE_DIR="$ZSH_CACHE_DIR"
fi
#--- BUNDLES BEGIN
${(j::)_sources}
#--- BUNDLES END
typeset -gaU _ANTIGEN_BUNDLE_RECORD; _ANTIGEN_BUNDLE_RECORD=($(print ${(qq)_ANTIGEN_BUNDLE_RECORD}))
typeset -g _ANTIGEN_CACHE_LOADED; _ANTIGEN_CACHE_LOADED=true
typeset -ga _ZCACHE_BUNDLE_SOURCE; _ZCACHE_BUNDLE_SOURCE=($(print ${(qq)_ZCACHE_BUNDLE_SOURCE}))
typeset -g _ANTIGEN_CACHE_VERSION; _ANTIGEN_CACHE_VERSION='{{ANTIGEN_VERSION}}'
typeset -g _ANTIGEN_THEME; _ANTIGEN_THEME='$_ANTIGEN_THEME'
#-- END ZCACHE GENERATED FILE
EOC
{ zcompile "$ANTIGEN_CACHE" } &!
# Compile config files, if any
LOG "CHECK_FILES $ANTIGEN_CHECK_FILES"
[[ $ANTIGEN_AUTO_CONFIG == true && -n $ANTIGEN_CHECK_FILES ]] && {
echo ${(j:\n:)ANTIGEN_CHECK_FILES} >! "$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 () {
# Return an error is not bundle name/url is passed or a heredoc is misused,
# see https://github.com/zsh-users/antigen/issues/602
if [[ $# -eq 0 ]]; then
printf "Antigen: Must provide a bundle url or name.\n" >&2
return 1
fi
_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
}
================================================
FILE: src/ext/defer.zsh
================================================
# 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
}
================================================
FILE: src/ext/ext.zsh
================================================
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
}
================================================
FILE: src/ext/lock.zsh
================================================
# 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
}
================================================
FILE: src/ext/parallel.zsh
================================================
# 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
}
================================================
FILE: src/helpers/bundle-rev.zsh
================================================
# 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
}
================================================
FILE: src/helpers/bundle-short-name.zsh
================================================
# 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
}
================================================
FILE: src/helpers/echo-record.zsh
================================================
# 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}
}
================================================
FILE: src/helpers/find-bundle.zsh
================================================
# 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)
}
================================================
FILE: src/helpers/find-record.zsh
================================================
# 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*]}"
}
================================================
FILE: src/helpers/get-bundles.zsh
================================================
# 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
}
================================================
FILE: src/helpers/get-clone-dir.zsh
================================================
# 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"
}
================================================
FILE: src/helpers/get-cloned-bundles.zsh
================================================
# 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
}
================================================
FILE: src/helpers/get-themes.zsh
================================================
# 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
}
================================================
FILE: src/helpers/interactive-mode.zsh
================================================
# 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* ]];
}
================================================
FILE: src/helpers/parse-branch.zsh
================================================
# 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
}
================================================
FILE: src/helpers/update-repos.zsh
================================================
-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
}
================================================
FILE: src/lib/ensure-repo.zsh
================================================
# 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=<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
}
================================================
FILE: src/lib/env-setup.zsh
================================================
# 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'
# Set up configured theme
-antigen-set-default _ANTIGEN_THEME ''
# 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
}
================================================
FILE: src/lib/load.zsh
================================================
# 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
}
================================================
FILE: src/lib/log.zsh
================================================
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
}
================================================
FILE: src/lib/parse-args.zsh
================================================
# Usage:
# -antigen-parse-args output_assoc_arr <args...>
-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
}
================================================
FILE: src/lib/revert-info.zsh
================================================
# 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
}
================================================
FILE: src/lib/use-oh-my-zsh.zsh
================================================
-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
}
================================================
FILE: src/lib/use-prezto.zsh
================================================
-antigen-use-prezto () {
ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_PREZTO_REPO_URL
antigen-bundle "$ANTIGEN_PREZTO_REPO_URL"
}
================================================
FILE: tests/.gitconfig
================================================
[user]
name=test
email=test@test.test
================================================
FILE: tests/.zshenv
================================================
# Display all globally defined variables from functions
setopt localoptions warncreateglobal
# zshrc file written for antigen's tests. Might not be a good one for daily use.
# See cram's documentation for some of the variables used below.
export ADOTDIR=$(mktemp -du "/tmp/dot-antigen-tmp-XXXXX")
[[ ! -d "$ADOTDIR" ]] && mkdir -p "$ADOTDIR"
export ANTIGEN=${ANTIGEN:-"/antigen"}
export ANTIGEN_AUTO_CONFIG=false
# Commented out due to tests/cache.t
#export ANTIGEN_CACHE=false
export ANTIGEN_RSRC=$ADOTDIR/.resources
export _ANTIGEN_WARN_DUPLICATES=false
export _ANTIGEN_INTERACTIVE=true
# Comment/uncomment this line to be able to see detailed debug logs on
# the tests output (tests naturally will fail)
# export ANTIGEN_DEBUG_LOG=/dev/stdout
export TESTDIR=$(mktemp -d "/tmp/cram-testdir-XXXXX" || /tmp/cram-testdir)
test -f "$TESTDIR/.zcompdump" && rm "$TESTDIR/.zcompdump"
source "$ANTIGEN/antigen.zsh"
# A test plugin repository to test out antigen with.
PLUGIN_DIR="$TESTDIR/test-plugin"
# {
mkdir "$PLUGIN_DIR"
# A wrapper function over `git` to work with the test plugin repo.
alias pg='git --git-dir "$PLUGIN_DIR/.git" --work-tree "$PLUGIN_DIR"'
echo 'alias hehe="echo hehe"' > "$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
}
================================================
FILE: tests/antigen-wrapper.t
================================================
Create 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
Call without arguments should exit with error.
$ antigen 2>/dev/null
[1]
Call without arguments should display help message.
$ antigen 2>&1 | head -n 4
Antigen .* (re)
Revision .* (re)
Antigen is a .* (re)
================================================
FILE: tests/apply.t
================================================
Can 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>
================================================
FILE: tests/arg-parser.t
================================================
Helper 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
================================================
FILE: tests/branch-bundle.t
================================================
Branch b1.
$ pg branch b1
$ pg checkout b1
Switched to branch 'b1'
$ cat > $PLUGIN_DIR/aliases.zsh <<EOF
> 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
================================================
FILE: tests/bundle-syntaxes.t
================================================
Test 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.
================================================
FILE: tests/bundle.t
================================================
Should 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]
================================================
FILE: tests/bundles.t
================================================
Save 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
================================================
FILE: tests/cache.t
================================================
Enable 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)
================================================
FILE: tests/cleanup.t
================================================
Firstly, 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.
================================================
FILE: tests/clone-dir.t
================================================
Set 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)
================================================
FILE: tests/ensure-repo.t
================================================
Set 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
gitextract_aery0qe1/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── LICENSE
├── Makefile
├── Makefile.in
├── README.mkd
├── VERSION
├── antigen.zsh
├── bin/
│ └── antigen.zsh
├── configure
├── src/
│ ├── _antigen
│ ├── antigen.zsh
│ ├── boot.zsh
│ ├── commands/
│ │ ├── apply.zsh
│ │ ├── bundle.zsh
│ │ ├── bundles.zsh
│ │ ├── cleanup.zsh
│ │ ├── help.zsh
│ │ ├── init.zsh
│ │ ├── list.zsh
│ │ ├── purge.zsh
│ │ ├── reset.zsh
│ │ ├── restore.zsh
│ │ ├── revert.zsh
│ │ ├── self-update.zsh
│ │ ├── snapshot.zsh
│ │ ├── theme.zsh
│ │ ├── update.zsh
│ │ ├── use.zsh
│ │ └── version.zsh
│ ├── ext/
│ │ ├── cache.zsh
│ │ ├── defer.zsh
│ │ ├── ext.zsh
│ │ ├── lock.zsh
│ │ └── parallel.zsh
│ ├── helpers/
│ │ ├── bundle-rev.zsh
│ │ ├── bundle-short-name.zsh
│ │ ├── echo-record.zsh
│ │ ├── find-bundle.zsh
│ │ ├── find-record.zsh
│ │ ├── get-bundles.zsh
│ │ ├── get-clone-dir.zsh
│ │ ├── get-cloned-bundles.zsh
│ │ ├── get-themes.zsh
│ │ ├── interactive-mode.zsh
│ │ ├── parse-branch.zsh
│ │ └── update-repos.zsh
│ └── lib/
│ ├── ensure-repo.zsh
│ ├── env-setup.zsh
│ ├── load.zsh
│ ├── log.zsh
│ ├── parse-args.zsh
│ ├── revert-info.zsh
│ ├── use-oh-my-zsh.zsh
│ └── use-prezto.zsh
├── tests/
│ ├── .gitconfig
│ ├── .zshenv
│ ├── antigen-wrapper.t
│ ├── apply.t
│ ├── arg-parser.t
│ ├── branch-bundle.t
│ ├── bundle-syntaxes.t
│ ├── bundle.t
│ ├── bundles.t
│ ├── cache.t
│ ├── cleanup.t
│ ├── clone-dir.t
│ ├── ensure-repo.t
│ ├── ext.t
│ ├── find-record.t
│ ├── init.t
│ ├── list.t
│ ├── load.t
│ ├── no_local_clone.t
│ ├── purge.t
│ ├── revert-update.t
│ ├── selfupdate.t
│ ├── snapshots.t
│ ├── theme.t
│ ├── update.t
│ ├── url-resolver.t
│ ├── use.t
│ └── version.t
└── tools/
├── builder
├── jail
└── stats
Condensed preview — 90 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (234K chars).
[
{
"path": ".gitignore",
"chars": 562,
"preview": "# Running tests creates this completion dump file.\n.zcompdump*\n\n# Test failure reports\ntests/*.t.err\n\n# If the $ADOTDIR "
},
{
"path": ".travis.yml",
"chars": 1513,
"preview": "sudo: required\ndist: trusty\nlanguage: generic\nservices:\n - docker\ncache:\n pip: true\nenv:\n global:\n - USE_CONTAINER"
},
{
"path": "CHANGELOG.md",
"chars": 19770,
"preview": "# CHANGELOG\n\nAll notable changes to this project will be documented in this file.\nThis project adheres to [Semantic Vers"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 5457,
"preview": "# Code of Conduct\n\n## 1. Purpose\n\nA primary goal of Antigen is to be inclusive to the largest number of contributors, wi"
},
{
"path": "CONTRIBUTING.md",
"chars": 5374,
"preview": "# Contributing to this project\n\nPlease take a moment to review this document in order to make the contribution\nprocess e"
},
{
"path": "ISSUE_TEMPLATE.md",
"chars": 546,
"preview": "Description\n-----------\n\nSmall paragraph to describe the issue/bug.\n\n\nSteps to reproduce\n------------------\n\nMinimal ste"
},
{
"path": "LICENSE",
"chars": 1103,
"preview": "The MIT License (MIT)\n\nCopyright © Shrikant Sharat Kandula, http://sharats.me.\n\nPermission is hereby granted, free of ch"
},
{
"path": "Makefile",
"chars": 4944,
"preview": "######################################################################\n# This file was autogenerated by 'configure'. Do "
},
{
"path": "Makefile.in",
"chars": 4512,
"preview": "SHELL ?= sh\nPREFIX ?= /usr/local\n\nCRAM_OPTS ?= -v\n\nPROJECT ?= $(CURDIR)\nBIN ?= ${PROJECT}/bin\nSRC ?"
},
{
"path": "README.mkd",
"chars": 6518,
"preview": "<h1 align=\"center\">\n <a href=\"https://github.com/zsh-users/antigen\"><img src=\"antigen.png\" alt=\"Antigen\"></a>\n <br>\n "
},
{
"path": "VERSION",
"chars": 8,
"preview": "develop\n"
},
{
"path": "antigen.zsh",
"chars": 75,
"preview": "_ANTIGEN_INSTALL_DIR=${0:A:h}\nsource $_ANTIGEN_INSTALL_DIR/bin/antigen.zsh\n"
},
{
"path": "bin/antigen.zsh",
"chars": 59774,
"preview": "######################################################################\n# This file was autogenerated by `make`. Do not e"
},
{
"path": "configure",
"chars": 2304,
"preview": "#!/bin/zsh\n# vim: sw=2 ts=2 et!\ntarget=Makefile\narguments=\"$@\"\ntypeset -A opts;\nopts=(\nwith-debug yes\nwith-extensio"
},
{
"path": "src/_antigen",
"chars": 2154,
"preview": "#compdef _antigen\n# Setup antigen's autocompletion\n_antigen () {\n local -a _1st_arguments\n _1st_arguments=(\n 'apply"
},
{
"path": "src/antigen.zsh",
"chars": 997,
"preview": "[[ -z \"$_ANTIGEN_INSTALL_DIR\" ]] && _ANTIGEN_INSTALL_DIR=${0:A:h}\n\n# Each line in this string has the following entries "
},
{
"path": "src/boot.zsh",
"chars": 1502,
"preview": "zmodload zsh/parameter\nautoload -U is-at-least\n\n# While boot.zsh is part of the ext/cache functionallity it may be disab"
},
{
"path": "src/commands/apply.zsh",
"chars": 543,
"preview": "# Initialize completion\nantigen-apply () {\n LOG \"Called antigen-apply\"\n\n # Load the compinit module. This will readefi"
},
{
"path": "src/commands/bundle.zsh",
"chars": 1958,
"preview": "# Syntaxes\n# antigen-bundle <url> [<loc>=/]\n# Keyword only arguments:\n# branch - The branch of the repo to use for t"
},
{
"path": "src/commands/bundles.zsh",
"chars": 428,
"preview": "antigen-bundles () {\n # Bulk add many bundles at one go. Empty lines and lines starting with a `#`\n # are ignored. Eve"
},
{
"path": "src/commands/cleanup.zsh",
"chars": 1136,
"preview": "# Cleanup unused repositories.\nantigen-cleanup () {\n local force=false\n if [[ $1 == --force ]]; then\n force=true\n "
},
{
"path": "src/commands/help.zsh",
"chars": 1184,
"preview": "antigen-help () {\n antigen-version\n\n cat <<EOF\n\nAntigen is a plugin management system for zsh. It makes it easy to gra"
},
{
"path": "src/commands/init.zsh",
"chars": 950,
"preview": "# Antigen command to load antigen configuration\n#\n# This method is slighlty more performing than using various antigen-*"
},
{
"path": "src/commands/list.zsh",
"chars": 378,
"preview": "# List instaled bundles either in long (record), short or simple format.\n#\n# Usage\n# antigen-list [--short|--long|--s"
},
{
"path": "src/commands/purge.zsh",
"chars": 1499,
"preview": "# Remove a bundle from filesystem\n#\n# Usage\n# antigen-purge example/bundle [--force]\n#\n# Returns\n# Nothing. Removes "
},
{
"path": "src/commands/reset.zsh",
"chars": 497,
"preview": "# Removes cache payload and metadata if available\n#\n# Usage\n# antigen-reset\n#\n# Returns\n# Nothing\nantigen-reset () {"
},
{
"path": "src/commands/restore.zsh",
"chars": 823,
"preview": "antigen-restore () {\n local line\n if [[ $# == 0 ]]; then\n echo 'Please provide a snapshot file to restore from.' >&"
},
{
"path": "src/commands/revert.zsh",
"chars": 575,
"preview": "# Reads $ADORDIR/revert-info and restores bundles' revision\nantigen-revert () {\n local line\n if [[ -f $ADOTDIR/revert-"
},
{
"path": "src/commands/self-update.zsh",
"chars": 682,
"preview": "# Update (with `git pull`) antigen itself.\n# TODO: Once update is finished, show a summary of the new commits, as a kind"
},
{
"path": "src/commands/snapshot.zsh",
"chars": 1349,
"preview": "antigen-snapshot () {\n local snapshot_file=\"${1:-antigen-shapshot}\"\n local urls url dir version_hash snapshot_content\n"
},
{
"path": "src/commands/theme.zsh",
"chars": 2160,
"preview": "# Loads a given theme.\n#\n# Shares the same syntax as antigen-bundle command.\n#\n# Usage\n# antigen-theme [path] [zsh/the"
},
{
"path": "src/commands/update.zsh",
"chars": 1929,
"preview": "# Updates the bundles or a single bundle.\n#\n# Usage\n# antigen-update [example/bundle]\n#\n# Returns\n# Nothing. Perfo"
},
{
"path": "src/commands/use.zsh",
"chars": 451,
"preview": "antigen-use () {\n if [[ $1 == oh-my-zsh ]]; then\n -antigen-use-oh-my-zsh\n elif [[ $1 == prezto ]]; then\n -antige"
},
{
"path": "src/commands/version.zsh",
"chars": 428,
"preview": "antigen-version () {\n local extensions\n\n printf \"Antigen %s (%s)\\nRevision date: %s\\n\" \"{{ANTIGEN_VERSION}}\" \"{{ANTIGE"
},
{
"path": "src/ext/cache.zsh",
"chars": 6209,
"preview": "typeset -ga _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE\ntypeset -g _ZCACHE_CAPTURE_PREFIX\n\n# Generates cache from liste"
},
{
"path": "src/ext/defer.zsh",
"chars": 880,
"preview": "# Initialize defer lib\n-antigen-defer-init () {\n typeset -ga _DEFERRED_BUNDLE; _DEFERRED_BUNDLE=()\n if -antigen-intera"
},
{
"path": "src/ext/ext.zsh",
"chars": 5758,
"preview": "typeset -Ag _ANTIGEN_HOOKS; _ANTIGEN_HOOKS=()\ntypeset -Ag _ANTIGEN_HOOKS_META; _ANTIGEN_HOOKS_META=()\ntypeset -g _ANTIGE"
},
{
"path": "src/ext/lock.zsh",
"chars": 1470,
"preview": "# Initialize lock lib\n-antigen-lock-init () {\n # Default lock path.\n -antigen-set-default ANTIGEN_LOCK $ADOTDIR/.lock\n"
},
{
"path": "src/ext/parallel.zsh",
"chars": 2995,
"preview": "# Initialize parallel lib\n-antigen-parallel-init () {\n WARN \"Init parallel extension\" PARALLEL\n typeset -ga _PARALLEL_"
},
{
"path": "src/helpers/bundle-rev.zsh",
"chars": 795,
"preview": "# Returns the bundle's git revision\n#\n# Usage\n# -antigen-bundle-rev bundle-name [is_local_clone]\n#\n# Returns\n# Bundl"
},
{
"path": "src/helpers/bundle-short-name.zsh",
"chars": 480,
"preview": "# Usage:\n# -antigen-bundle-short-name \"https://github.com/user/repo.git[|*]\" \"[branch/name]\"\n# Returns:\n# user/repo@"
},
{
"path": "src/helpers/echo-record.zsh",
"chars": 167,
"preview": "# Echo the bundle specs as in the record. The first line is not echoed since it\n# is a blank line.\n-antigen-echo-record "
},
{
"path": "src/helpers/find-bundle.zsh",
"chars": 211,
"preview": "# Filters _ANTIGEN_BUNDLE_RECORD for $1\n#\n# Usage\n# -antigen-find-bundle example/bundle\n#\n# Returns\n# String if bund"
},
{
"path": "src/helpers/find-record.zsh",
"chars": 308,
"preview": "# Filters _ANTIGEN_BUNDLE_RECORD for $1\n#\n# Usage\n# -antigen-find-record example/bundle\n#\n# Returns\n# String if reco"
},
{
"path": "src/helpers/get-bundles.zsh",
"chars": 1057,
"preview": "# Returns bundle names from _ANTIGEN_BUNDLE_RECORD\n#\n# Usage\n# -antigen-get-bundles [--short|--simple|--long]\n#\n# Retu"
},
{
"path": "src/helpers/get-clone-dir.zsh",
"chars": 704,
"preview": "# Usage:\n# -antigen-get-clone-dir \"https://github.com/zsh-users/zsh-syntax-highlighting.git[|feature/branch]\"\n# Returns"
},
{
"path": "src/helpers/get-cloned-bundles.zsh",
"chars": 229,
"preview": "# Returns bundles flagged as make_local_clone\n#\n# Usage\n# -antigen-cloned-bundles\n#\n# Returns\n# Bundle metadata\n-a"
},
{
"path": "src/helpers/get-themes.zsh",
"chars": 457,
"preview": "# Returns a list of themes from a default library (omz)\n#\n# Usage\n# -antigen-get-themes\n#\n# Returns\n# List of themes"
},
{
"path": "src/helpers/interactive-mode.zsh",
"chars": 524,
"preview": "# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell. \n#\n# Usage\n# -antigen-interactive"
},
{
"path": "src/helpers/parse-branch.zsh",
"chars": 755,
"preview": "# Parses and retrieves a remote branch given a branch name.\n#\n# If the branch name contains '*' it will retrieve remote "
},
{
"path": "src/helpers/update-repos.zsh",
"chars": 1280,
"preview": "-antigen-update-repos () {\n local repo bundle url target\n local log=/tmp/antigen-v2-migrate.log\n\n echo \"It seems you "
},
{
"path": "src/lib/ensure-repo.zsh",
"chars": 2310,
"preview": "# Ensure that a clone exists for the given repo url and branch. If the first\n# argument is `update` and if a clone alrea"
},
{
"path": "src/lib/env-setup.zsh",
"chars": 2355,
"preview": "# Helper function: Same as `$1=$2`, but will only happen if the name\n# specified by `$1` is not already set.\n-antigen-se"
},
{
"path": "src/lib/load.zsh",
"chars": 2502,
"preview": "# Load a given bundle by sourcing it.\n#\n# The function also modifies fpath to add the bundle path.\n#\n# Usage\n# -antige"
},
{
"path": "src/lib/log.zsh",
"chars": 644,
"preview": "zmodload zsh/datetime\nANTIGEN_DEBUG_LOG=${ANTIGEN_DEBUG_LOG:-${ADOTDIR:-$HOME/.antigen}/debug.log}\nLOG () {\n local PREF"
},
{
"path": "src/lib/parse-args.zsh",
"chars": 4623,
"preview": "# Usage:\n# -antigen-parse-args output_assoc_arr <args...>\n-antigen-parse-args () {\n local argkey key value index=0 ar"
},
{
"path": "src/lib/revert-info.zsh",
"chars": 589,
"preview": "# Updates revert-info data with git hash.\n#\n# This does process only cloned bundles.\n#\n# Usage\n# -antigen-revert-info"
},
{
"path": "src/lib/use-oh-my-zsh.zsh",
"chars": 307,
"preview": "-antigen-use-oh-my-zsh () {\n typeset -g ZSH ZSH_CACHE_DIR\n ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_OMZ_REPO_URL\n if [[ -z \""
},
{
"path": "src/lib/use-prezto.zsh",
"chars": 123,
"preview": "-antigen-use-prezto () {\n ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_PREZTO_REPO_URL\n antigen-bundle \"$ANTIGEN_PREZTO_REPO_URL\""
},
{
"path": "tests/.gitconfig",
"chars": 40,
"preview": "[user]\n\tname=test\n\temail=test@test.test\n"
},
{
"path": "tests/.zshenv",
"chars": 4364,
"preview": "# Display all globally defined variables from functions\nsetopt localoptions warncreateglobal\n\n# zshrc file written for a"
},
{
"path": "tests/antigen-wrapper.t",
"chars": 498,
"preview": "Create a dummy antigen command.\n\n $ antigen-dummy () {\n > echo me dummy\n > }\n\nCheck the normal way of calling it\n\n "
},
{
"path": "tests/apply.t",
"chars": 243,
"preview": "Can use antigen-apply and antigen apply interchangably.\n\n $ hehe &> /dev/null\n [127]\n\n $ antigen bundle $PLUGIN_DIR &"
},
{
"path": "tests/arg-parser.t",
"chars": 3011,
"preview": "Helper alias.\n\n $ typeset -A bundle\n $ parse () {\n > bundle=()\n > -antigen-parse-args bundle \"$@\"\n > }\n\nNo arg"
},
{
"path": "tests/branch-bundle.t",
"chars": 643,
"preview": "Branch b1.\n\n $ pg branch b1\n $ pg checkout b1\n Switched to branch 'b1'\n $ cat > $PLUGIN_DIR/aliases.zsh <<EOF\n > al"
},
{
"path": "tests/bundle-syntaxes.t",
"chars": 2171,
"preview": "Test helper and mock functions.\n\n $ ANTIGEN_DEFAULT_REPO_URL=gh-user/repo\n $ ANTIGEN_WARN_DUPLICATES=false\n\n $ b () {"
},
{
"path": "tests/bundle.t",
"chars": 2737,
"preview": "Should get a complain if no bundle is given as argument.\n\n $ antigen-bundle\n Antigen: Must provide a bundle url or nam"
},
{
"path": "tests/bundles.t",
"chars": 889,
"preview": "Save env variables to test for leaks.\n\n $ prev=$(env)\n\nAdd multiple bundles.\n\n $ echo \"$PLUGIN_DIR\\n$PLUGIN_DIR2\" | an"
},
{
"path": "tests/cache.t",
"chars": 441,
"preview": "Enable extension.\n\n $ export _ANTIGEN_INTERACTIVE=false\n $ antigen ext cache\n $ antigen ext-list\n cache\n $ ANTIGEN_"
},
{
"path": "tests/cleanup.t",
"chars": 1506,
"preview": "Firstly, no plugins, nothing to cleanup.\n\n $ antigen-cleanup --force\n You don't have any bundles.\n\nLoad the plugins.\n\n"
},
{
"path": "tests/clone-dir.t",
"chars": 1800,
"preview": "Set up functions and env variables:\n\n $ ANTIGEN_LOG=/dev/stdout # We wanna see debug output\n $ function git() { echo \""
},
{
"path": "tests/ensure-repo.t",
"chars": 1226,
"preview": "Set up functions and env variables:\n\n $ ANTIGEN_LOG=/dev/stdout # We wanna see debug output\n $ function git() { echo \""
},
{
"path": "tests/ext.t",
"chars": 2551,
"preview": "Set up\n\n $ alias hook=antigen-add-hook\n\nCall hook any function.\n\n $ hello () {\n > echo Hello.\n > }\n $ hello-fr ()"
},
{
"path": "tests/find-record.t",
"chars": 1159,
"preview": "Finds a given record with branch name.\n\n $ _ANTIGEN_BUNDLE_RECORD=('https://github.com/rupa/z.git|952f01375a2e28463a8ab"
},
{
"path": "tests/init.t",
"chars": 564,
"preview": "Can source an dot-antigenrc file:\n\n $ zcache-cache-exists () { false }\n $ source () { echo $1 }\n $ antigen-init $ANTI"
},
{
"path": "tests/list.t",
"chars": 1860,
"preview": "Empty initial listing.\n\n $ antigen-list\n You don't have any bundles.\n [1]\n\nAdd a bundle.\n\n $ antigen-bundle $PLUGIN_"
},
{
"path": "tests/load.t",
"chars": 2422,
"preview": "Should respect load spec.\n\n $ -antigen-load-source () {\n > echo ${(j:\\n:)list}\n > }\n\nMust load all .zsh found:\n\n $ "
},
{
"path": "tests/no_local_clone.t",
"chars": 933,
"preview": "Load the plugin with no local clone.\n\n $ antigen-bundle $PLUGIN_DIR --no-local-clone\n\nCheck if the plugin is loaded cor"
},
{
"path": "tests/purge.t",
"chars": 563,
"preview": "Purge command removes a bundle from filesystem.\n $ antigen-bundle $PLUGIN_DIR &> /dev/null\n $ antigen-list | grep test"
},
{
"path": "tests/revert-update.t",
"chars": 1091,
"preview": "Load and test plugin.\n\n $ antigen-bundle $PLUGIN_DIR &> /dev/null\n $ hehe\n hehe\n\nSave the current HEAD of the plugin."
},
{
"path": "tests/selfupdate.t",
"chars": 2022,
"preview": "Set environment variables for this test case\n\n $ TEST_DIR=$PWD\n $ TEST_HOST=$TEST_DIR/host\n $ TEST_NORMAL=$TEST_DIR/c"
},
{
"path": "tests/snapshots.t",
"chars": 800,
"preview": "Load a couple of plugins.\n\n $ antigen-bundle $PLUGIN_DIR &> /dev/null\n $ antigen-bundle $PLUGIN_DIR2 &> /dev/null\n\nCre"
},
{
"path": "tests/theme.t",
"chars": 1797,
"preview": "Load the theme explicitly.\n\n $ antigen-theme $PLUGIN_DIR silly &> /dev/null\n $ echo \"$PS1\"\n prompt>\n\n $ antigen-them"
},
{
"path": "tests/update.t",
"chars": 1327,
"preview": "Load plugin.\n\n $ antigen-bundle $PLUGIN_DIR &> /dev/null\n $ hehe\n hehe\n\nUpdate the plugin.\n\n $ cat > $PLUGIN_DIR/ali"
},
{
"path": "tests/url-resolver.t",
"chars": 984,
"preview": "Helper alias.\n\n $ resolve () {typeset -A response; -antigen-parse-args 'response' $1; echo \"${response[url]}\" }\n\nComple"
},
{
"path": "tests/use.t",
"chars": 2450,
"preview": "Use url library.\n $ antigen-bundle () { echo $@ }\n $ antigen-use https://github.com/zsh-users/prezto.git\n https://git"
},
{
"path": "tests/version.t",
"chars": 157,
"preview": "Antigen version command.\n\n $ antigen-version\n Antigen * (glob)\n Revision date: * (glob)\n\n $ antigen version\n Antige"
},
{
"path": "tools/builder",
"chars": 1795,
"preview": "#!/usr/bin/env zsh\n# vim: ts=2 sw=2 et\ntypeset -g ZSH_REMOTE_URL; ZSH_REMOTE_URL=https://github.com/zsh-users/zsh.git\nty"
},
{
"path": "tools/jail",
"chars": 2647,
"preview": "#!/usr/bin/env zsh\n# vim: sw=2 ts=2 et\nJAIL=${1:-/tmp/jail-gen}\nJAIL_WRAPPER='chroot $jail sh -c \"%s\"'\n\nfunction jail/co"
},
{
"path": "tools/stats",
"chars": 2712,
"preview": "#!/usr/bin/env zsh\n# vim: sw=2 ts=2 et\n#set -x\ntypeset -g ITERATIONS; ITERATIONS=20\n\nfunction stats/usage () {\n echo \"U"
}
]
About this extraction
This page contains the full source code of the zsh-users/antigen GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 90 files (214.1 KB), approximately 66.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.