Commit 6f15acd80ec23dd19e32911b1c43fc25cfa1e08f
1 parent
85dd7a5dd3
Exists in
master
and in
2 other branches
[IMP] REMOVE REMOTE: zsh-users/antigen
Showing 24 changed files with 0 additions and 2136 deletions Inline Diff
- repos/zsh-users/antigen/.gitignore
- repos/zsh-users/antigen/.travis.yml
- repos/zsh-users/antigen/Makefile
- repos/zsh-users/antigen/README.mkd
- repos/zsh-users/antigen/antigen.zsh
- repos/zsh-users/antigen/requirements.txt
- repos/zsh-users/antigen/tests/.zshenv
- repos/zsh-users/antigen/tests/antigen-wrapper.t
- repos/zsh-users/antigen/tests/arg-parser.t
- repos/zsh-users/antigen/tests/branch-bundle.t
- repos/zsh-users/antigen/tests/bundle-syntaxes.t
- repos/zsh-users/antigen/tests/bundle.t
- repos/zsh-users/antigen/tests/bundles.t
- repos/zsh-users/antigen/tests/cleanup.t
- repos/zsh-users/antigen/tests/list.t
- repos/zsh-users/antigen/tests/no_local_clone.t
- repos/zsh-users/antigen/tests/revert-update.t
- repos/zsh-users/antigen/tests/selfupdate.t
- repos/zsh-users/antigen/tests/snapshots.t
- repos/zsh-users/antigen/tests/theme.t
- repos/zsh-users/antigen/tests/update.t
- repos/zsh-users/antigen/tests/url-resolver.t
- repos/zsh-users/antigen/tests/use.t
- repos/zsh-users/antigen/travis-ppa.sh
repos/zsh-users/antigen/.gitignore
1 | # Running tests creates this completion dump file. | File was deleted | |
2 | tests/.zcompdump | ||
3 | |||
4 | # Test failure reports | ||
5 | tests/*.t.err | ||
6 | |||
7 | # If the $ADOTDIR is the same as the antigen's clone directory itself, the | ||
8 | # following would be shown as untracked. | ||
9 | repos/ | ||
10 | revert-info | ||
11 | 1 | # Running tests creates this completion dump file. |
repos/zsh-users/antigen/.travis.yml
1 | # Using python for running the tests, using the `cram` test framework. | File was deleted | |
2 | language: python | ||
3 | |||
4 | # Python version to run tests with. | ||
5 | python: | ||
6 | - "2.7" | ||
7 | |||
8 | env: | ||
9 | # Default zsh | ||
10 | - PPA="none" | ||
11 | # zsh 5 PPA | ||
12 | - PPA="ppa:brainpower/testing" | ||
13 | |||
14 | before_script: | ||
15 | |||
16 | # Show the git version being used to test. | ||
17 | - "git --version" | ||
18 | |||
19 | # Show the zsh version being used to test. | ||
20 | - "zsh --version" | ||
21 | |||
22 | # Test config for git. | ||
23 | - "git config --global user.name test" | ||
24 | - "git config --global user.email test@test.test" | ||
25 | |||
26 | install: | ||
27 | # Add PPA if needed | ||
28 | - "./travis-ppa.sh" | ||
29 | # Install python requirements. | ||
30 | - "pip install -r requirements.txt --use-mirrors" | ||
31 | # Install zsh. | ||
32 | - "sudo apt-get install zsh" | ||
33 | |||
34 | # Run the tests. | ||
35 | script: "make tests PYENV=" | ||
36 | 1 | # Using python for running the tests, using the `cram` test framework. |
repos/zsh-users/antigen/Makefile
1 | .PHONY: itests tests | File was deleted | |
2 | |||
3 | PYENV ?= . .pyenv/bin/activate && | ||
4 | TESTS ?= tests | ||
5 | |||
6 | itests: | ||
7 | ${MAKE} tests CRAM_OPTS=-i | ||
8 | |||
9 | tests: | ||
10 | ${PYENV} ZDOTDIR="${PWD}/tests" cram ${CRAM_OPTS} --shell=zsh ${TESTS} | ||
11 | 1 | .PHONY: itests tests |
repos/zsh-users/antigen/README.mkd
1 | # Antigen <sup>v1</sup> | File was deleted | |
2 | |||
3 | [](http://travis-ci.org/zsh-users/antigen) | ||
4 | |||
5 | Antigen is a small set of functions that help you easily manage your shell (zsh) | ||
6 | plugins, called bundles. The concept is pretty much the same as bundles in a | ||
7 | typical vim+pathogen setup. Antigen is to zsh, what [Vundle][] is to vim. | ||
8 | |||
9 | > [Donate to Antigen](https://gum.co/antigen) | ||
10 | |||
11 | Antigen has reached a certain level of stability and has been used in the wild | ||
12 | for around a couple of years. If you face any problems, please open an issue. | ||
13 | |||
14 | Note: Please read the commit comments of the changesets when you pull a new | ||
15 | version of antigen. | ||
16 | |||
17 | ## Show off | ||
18 | |||
19 | > Enough talk. Let's fight! | ||
20 | > -- Po, Kung-fu Panda. | ||
21 | |||
22 | You're going to experience antigen right in your open shell. No `.zshrc` | ||
23 | tweaking and reading the rest of this documentation. Kinda like an ice-cream | ||
24 | sample, if you will. | ||
25 | |||
26 | Get and load antigen. | ||
27 | |||
28 | curl -L https://raw.githubusercontent.com/zsh-users/antigen/master/antigen.zsh > antigen.zsh | ||
29 | source antigen.zsh | ||
30 | |||
31 | There. You now have all the antigen goodies. Let's try install some plugins. How | ||
32 | about some color to start with. Get the [syntax highlighting plugin][] by | ||
33 | running | ||
34 | |||
35 | antigen bundle zsh-users/zsh-syntax-highlighting | ||
36 | |||
37 | Now let it do its thing and once you're back at your prompt, try and type a | ||
38 | command. See that? Colors! | ||
39 | |||
40 | So, you do git? ruby? git and ruby? There are lots of awesome plugins over at | ||
41 | oh-my-zsh. Treat yourself to some. | ||
42 | |||
43 | antigen bundle robbyrussell/oh-my-zsh plugins/ruby | ||
44 | # Or for the lazy, | ||
45 | antigen bundle git | ||
46 | |||
47 | There are lots of plugins out there in the wild and people are writing zsh | ||
48 | utilities as small scripts all the time. Antigen is compatible with all of them. | ||
49 | The plugins and scripts don't need any special handling to be compatible with | ||
50 | antigen. | ||
51 | |||
52 | Another example, [kennethreitz's autoenv][autoenv] (or [my fork][f-autoenv] of | ||
53 | it). Just a bundle command away. | ||
54 | |||
55 | antigen bundle sharat87/autoenv | ||
56 | |||
57 | And boom! you have all the autoenv goodness. Just remember how you used to do | ||
58 | these before antigen, clone it, modify your zshrc to source it, load a new | ||
59 | terminal, all just to test it out. Duh! | ||
60 | |||
61 | A subtle aspect of this is that you can tell antigen to grab just about anything | ||
62 | from anyone's `dotfiles` repo, as long as it is in a directory under any repo on | ||
63 | github. | ||
64 | |||
65 | And themes? How would you like a fancy new prompt for yourself? | ||
66 | |||
67 | antigen theme funky | ||
68 | |||
69 | No? Not your taste? There are many themes available to you, check out the | ||
70 | oh-my-zsh's [page on themes][]. | ||
71 | |||
72 | You can install themes from unofficial repos too! | ||
73 | |||
74 | antigen theme XsErG/zsh-themes themes/lazyuser | ||
75 | |||
76 | See? It's easy! To see how that works, refer to [the section on the | ||
77 | `antigen theme` command further down](#antigen-theme). | ||
78 | |||
79 | Note: Many of those plugins and especially themes, assume you have the core | ||
80 | library of oh-my-zsh loaded. So, if you want to experiment further, issue a | ||
81 | |||
82 | antigen use oh-my-zsh | ||
83 | |||
84 | and continue until you're tired. At which point you can come back to this page | ||
85 | ;) | ||
86 | |||
87 | ## Usage | ||
88 | |||
89 | So, now that you're here, I suppose you are convinced and want antigen running | ||
90 | your shell all the time. Sweet. Let's do it. | ||
91 | |||
92 | First, clone this repo, probably as a submodule if you have your dotfiles in a | ||
93 | git repo, | ||
94 | |||
95 | git clone https://github.com/zsh-users/antigen.git | ||
96 | |||
97 | The usage should be very familiar to you if you use Vundle. A typical `.zshrc` | ||
98 | might look like this | ||
99 | |||
100 | source /path-to-antigen-clone/antigen.zsh | ||
101 | |||
102 | # Load the oh-my-zsh's library. | ||
103 | antigen use oh-my-zsh | ||
104 | |||
105 | # Bundles from the default repo (robbyrussell's oh-my-zsh). | ||
106 | antigen bundle git | ||
107 | antigen bundle heroku | ||
108 | antigen bundle pip | ||
109 | antigen bundle lein | ||
110 | antigen bundle command-not-found | ||
111 | |||
112 | # Syntax highlighting bundle. | ||
113 | antigen bundle zsh-users/zsh-syntax-highlighting | ||
114 | |||
115 | # Load the theme. | ||
116 | antigen theme robbyrussell | ||
117 | |||
118 | # Tell antigen that you're done. | ||
119 | antigen apply | ||
120 | |||
121 | Open your zsh with this zshrc and you should see all the bundles you defined | ||
122 | here, getting installed. Once its done, you are ready to roll. The complete | ||
123 | syntax for the `antigen bundle` command is discussed further down on this page. | ||
124 | |||
125 | You can find more examples in the wiki: [Antigen in the wild][wild]. | ||
126 | |||
127 | ## Motivation | ||
128 | |||
129 | If you use zsh and [oh-my-zsh][], you know that having many different plugins | ||
130 | that are developed by many different authors in a single (sub)repo is not very | ||
131 | easy to maintain. There are some really fantastic plugins and utilities in | ||
132 | oh-my-zsh, but having them all in a single repo doesn't really scale well. And I | ||
133 | admire robbyrussell's efforts for reviewing and merging the gigantic number of | ||
134 | pull requests the project gets. We need a better way of plugin management. | ||
135 | |||
136 | This was discussed on [a][1] [few][2] [issues][3], but it doesn't look like | ||
137 | there was any progress made. So, I'm trying to start this off with antigen, | ||
138 | hoping to better this situation. Please note that I'm by no means a zsh or any | ||
139 | shell script expert (far from it). | ||
140 | |||
141 | [1]: https://github.com/robbyrussell/oh-my-zsh/issues/465 | ||
142 | [2]: https://github.com/robbyrussell/oh-my-zsh/issues/377 | ||
143 | [3]: https://github.com/robbyrussell/oh-my-zsh/issues/1014 | ||
144 | |||
145 | Inspired by vundle, antigen can pull oh-my-zsh style plugins from various github | ||
146 | repositories. You are not limited to use plugins from the oh-my-zsh repository | ||
147 | only and you don't need to maintain your own fork and pull from upstream every | ||
148 | now and then. I actually encourage you to grab plugins and scripts from various | ||
149 | sources, straight from the authors, before they even submit it to oh-my-zsh as a | ||
150 | pull request. | ||
151 | |||
152 | Antigen also lets you switch the prompt theme with one command, just like that | ||
153 | |||
154 | antigen theme candy | ||
155 | |||
156 | and your prompt is changed, just for this session of course (unless you put this | ||
157 | line in your `.zshrc`). | ||
158 | |||
159 | ## Commands | ||
160 | |||
161 | ### antigen bundle | ||
162 | |||
163 | This command tells antigen to install (if not already installed) and load the | ||
164 | given plugin. The simplest usage follows the following syntax. | ||
165 | |||
166 | antigen bundle <plugin-name> | ||
167 | |||
168 | This will install and load the `plugins/<name>` directory from [robbyrussell's | ||
169 | oh-my-zsh][oh-my-zsh] (can be changed by setting `ANTIGEN_DEFAULT_REPO_URL`). | ||
170 | |||
171 | However, the above is just syntax sugar for the extended syntax of the | ||
172 | `antigen bundle` command. | ||
173 | |||
174 | antigen bundle [<url> [<loc>]] | ||
175 | |||
176 | where `<url>` is the repository url and it defaults to [robbyrussell's | ||
177 | oh-my-zsh][oh-my-zsh] repo (can be changed by setting `ANTIGEN_DEFAULT_REPO_URL` | ||
178 | discussed further down). `<loc>` is the path under this repository which has the | ||
179 | zsh plugin. This is typically the directory that contains a `*.plugin.zsh` file, | ||
180 | but it could contain a completion file or just many `*.zsh` files to be sourced, | ||
181 | or it could simply be a file (with any extension) that you want to source. | ||
182 | `<loc>` defaults to `/`, which indicates the repository itself is a plugin. | ||
183 | |||
184 | An example invocation would be | ||
185 | |||
186 | # The following is the same as `antigen bundle ant`. But for demonstration | ||
187 | # purposes, we use the extended syntax here. | ||
188 | antigen bundle https://github.com/robbyrussell/oh-my-zsh.git plugins/ant | ||
189 | |||
190 | This would install the ant plugin from robbyrussell's oh-my-zsh repo. Of course, | ||
191 | github url's can be shortened. | ||
192 | |||
193 | antigen bundle robbyrussell/oh-my-zsh plugins/ant | ||
194 | |||
195 | And since this repo is the default, even that isn't necessary. But we can't | ||
196 | specify the `loc` without giving the first argument. | ||
197 | |||
198 | For this and a few other reasons, `antigen bundle` also supports a simple | ||
199 | keyword argument syntax, using which we can rewrite the above as | ||
200 | |||
201 | antigen bundle --loc=plugins/ant | ||
202 | |||
203 | Which picks up the default for the `url` argument, and uses the `loc` given to | ||
204 | it. | ||
205 | |||
206 | *Note* that you can mix and match positional and keyword arguments. But you | ||
207 | can't have positional arguments after keyword arguments. | ||
208 | |||
209 | antigen bundle robbyrussell/oh-my-zsh --loc=plugins/ant | ||
210 | |||
211 | And keyword arguments don't care about the order in which the arguments are | ||
212 | specified. The following is perfectly valid. | ||
213 | |||
214 | antigen bundle --loc=plugins/ant --url=robbyrussell/oh-my-zsh | ||
215 | |||
216 | You can also specify a local directory on your file system as a bundle. In this | ||
217 | case, make sure the path you give is the absolute path (i.e., starts with a | ||
218 | `/`). Relative paths are not supported. If the repo you gave is a local | ||
219 | directory path, then it is not necessary that this path is a git repo. Please | ||
220 | refer to the notes on `--no-local-clone` below. | ||
221 | |||
222 | This command can also be used from your shell environment. This allows you to | ||
223 | install plugins on the fly and try them out. Of course if you want a bundle to | ||
224 | be available every time you open a shell, put it in your `.zshrc`. | ||
225 | |||
226 | Other keyword-only arguments accepted: | ||
227 | |||
228 | `--branch={git-branch-name}` — Specify the branch of the git repo to be | ||
229 | used for this bundle (without the braces of course). The default is whatever | ||
230 | branch the clone comes with, which is usually `master`. For example, | ||
231 | |||
232 | antigen bundle github-user/repo --branch=develop | ||
233 | |||
234 | This will get the plugin as in the branch `develop`. | ||
235 | |||
236 | Note that if you specify two plugins to be loaded from the same git repo, but | ||
237 | different branches, then two separate clones of this repo will be maintained. | ||
238 | This is a small implementation detail and shouldn't influence you in any way. | ||
239 | |||
240 | `--no-local-clone` — This command can be useful if you are developing a | ||
241 | plugin and already have a clone on your local file system. If this argument is | ||
242 | not given, even if the given repo url is a local path, a clone is made in the | ||
243 | `$ADOTDIR/repos`, and the plugin is loaded from that clone. But, if you give | ||
244 | this argument, the plugin is sourced straight from the repo location, without | ||
245 | creating a clone. For example, | ||
246 | |||
247 | antigen bundle /absolute/path/to/the/plugin --no-local-clone | ||
248 | |||
249 | Note that if the repo url is *not* an absolute local path or a branch has been | ||
250 | specified with the `--branch` option, this argument has no effect. That is, | ||
251 | for this option to have any affect, the repo url must be an absolute local path | ||
252 | and no `--branch` should be specified. | ||
253 | |||
254 | Also, if the local path given as the url is not a git repo, then this | ||
255 | argument is forced as it doesn't makes sense to *clone* something that's not a | ||
256 | git repo. This property can be used to load any utility scripts you have in your | ||
257 | dotfiles repo. For example, | ||
258 | |||
259 | antigen bundle $HOME/dotfiles/oh-my-zsh/custom | ||
260 | |||
261 | In addition to the above discussed arguments, `antigen bundle` also takes a | ||
262 | `btype` keyword-only argument, that is used internally. You shouldn't be | ||
263 | concerned with this argument, its only used internally and will probably go away | ||
264 | in the future. It indicates whether the bundle is a theme or a simple plugin. | ||
265 | |||
266 | ### antigen bundles | ||
267 | |||
268 | If you have a fair number of bundles, using the `antigen bundle` command can | ||
269 | look cumbersome. You can use the `antigen bundles` command to *bulk* define | ||
270 | bundles instead of individual calls to `antigen bundle`. | ||
271 | |||
272 | Usage is pretty straightforward. Just pipe the bundle specifications, just as | ||
273 | you would give to the `antigen bundle` command, one per line, into the | ||
274 | `antigen bundles` command. The easiest way to do this, is using the heredoc | ||
275 | syntax. | ||
276 | |||
277 | antigen bundles <<EOBUNDLES | ||
278 | # Guess what to install when running an unknown command. | ||
279 | command-not-found | ||
280 | |||
281 | # The heroku tool helper plugin. | ||
282 | heroku | ||
283 | EOBUNDLES | ||
284 | |||
285 | This is equivalent to | ||
286 | |||
287 | antigen bundle command-not-found | ||
288 | antigen bundle heroku | ||
289 | |||
290 | Of course, as you can see, from the lines piped to `antigen bundles`, empty | ||
291 | lines and those starting with a `#` are ignored. The rest are passed to | ||
292 | `antigen bundle` without any quoting rules applied. They are actually `eval`-ed | ||
293 | with the `antigen bundle` command. See the source if you want to really | ||
294 | understand how it works. Its a very small function. | ||
295 | |||
296 | *Note*: Indenting the contents inside the EOBUNDLES heredoc is not required for | ||
297 | antigen-bundles to work. Its allowed (and encouraged) to improve readability. | ||
298 | |||
299 | ### antigen update | ||
300 | |||
301 | This is something you might not want to put in your `.zshrc`. Instead, run it | ||
302 | occasionally to update all your plugins. It doesn't take any arguments. | ||
303 | |||
304 | antigen update | ||
305 | |||
306 | Please note that the updates that are downloaded are not immediately available. | ||
307 | You have to open a new shell to be able to see the changes. This is a limitation | ||
308 | by design since reloading all the plugins *might* have some nasty side effects | ||
309 | that may not be immediately apparent. Let's just say it can make your shell act | ||
310 | real quirky. | ||
311 | |||
312 | **Please note**: This command is not for updating *antigen* itself. Its for | ||
313 | updating the bundles you are using with antigen. To update your copy of antigen, | ||
314 | use the `selfupdate` command described further below. | ||
315 | |||
316 | ### antigen revert <sup>α</sup> | ||
317 | |||
318 | Reverts the state of all your plugins to how they were before the last | ||
319 | `antigen update`. This command is currently experimental, so don't rely too much | ||
320 | on it. There is a test for it, and it passes, so it should work fine though. | ||
321 | |||
322 | Takes no options. | ||
323 | |||
324 | Insider detail: The information for reverting is stored in | ||
325 | `$ADOTDIR/revert-info` file. If its not present, reverting is not possible. | ||
326 | |||
327 | ### antigen list | ||
328 | |||
329 | Use this command to list out the currently *loaded* plugins. Keep in mind that | ||
330 | this includes any bundles installed on-the-fly. | ||
331 | |||
332 | Takes no arguments. Gives out four entries per line of output, denoting the | ||
333 | following fields of each bundle. | ||
334 | |||
335 | <repo-url> <loc> <btype> <has-local-clone?> | ||
336 | |||
337 | The `btype` field is an internal detail, that specifies if the bundle is a | ||
338 | `plugin` or a `theme`. | ||
339 | |||
340 | The final field is `true` or `false` reflecting whether there is a local clone | ||
341 | for this bundle. | ||
342 | |||
343 | ### antigen cleanup | ||
344 | |||
345 | Used to clean up the clones of repos which are not used by any plugins currently | ||
346 | loaded. It takes no arguments. When run, it lists out the repo-clones that are | ||
347 | available but are not used by any plugin *currently loaded*. | ||
348 | |||
349 | This command, by default asks for confirmation before deleting the unused | ||
350 | clones. If the `--force` argument is given, then this confirmation is not asked. | ||
351 | It straight away deletes all the unused clones. This option makes this command | ||
352 | usable in a non-interactive fashion. | ||
353 | |||
354 | ### antigen use | ||
355 | |||
356 | This command lets you load any (supported) zsh pre-packaged framework, like | ||
357 | oh-my-zsh. Usage is | ||
358 | |||
359 | antigen use oh-my-zsh | ||
360 | |||
361 | Additional arguments may be present depending on the framework you are | ||
362 | `use`-ing. Here are the supported frameworks. | ||
363 | |||
364 | #### oh-my-zsh | ||
365 | |||
366 | This is (almost) the same as | ||
367 | |||
368 | antigen bundle --loc=lib | ||
369 | |||
370 | So, it basically installs the oh-my-zsh's library as a bundle. | ||
371 | |||
372 | One other thing it does is that some oh-my-zsh plugins expect a `$ZSH` set to | ||
373 | the full path of the oh-my-zsh clone being used. This is also set to the | ||
374 | correct path, if not already set to something else. | ||
375 | |||
376 | Please note that this assumes that the `ANTIGEN_DEFAULT_REPO_URL` is set to the | ||
377 | oh-my-zsh repo or a fork of that repo. If you want to specify the `url` too, | ||
378 | then you can't use the `antigen use oh-my-zsh` short cut. You have to do that | ||
379 | directly with the `antigen bundle` command. | ||
380 | |||
381 | Use | ||
382 | |||
383 | antigen use oh-my-zsh | ||
384 | |||
385 | in your `.zshrc`, before any `antigen bundle` declarations. It takes no further | ||
386 | arguments. | ||
387 | |||
388 | #### prezto | ||
389 | |||
390 | This is (almost, but not quite) the same as doing, | ||
391 | |||
392 | antigen bundle sorin-ionescu/prezto | ||
393 | |||
394 | That is, initializes the canonical repo of the prezto framework. Please note | ||
395 | that prezto support is very new and experimental in antigen. If you find any | ||
396 | bugs, please report over on github issues. | ||
397 | |||
398 | Takes no further arguments. | ||
399 | |||
400 | ### antigen theme | ||
401 | |||
402 | Used for switching the prompt theme. Invoke it with the name of the theme you | ||
403 | want to use. | ||
404 | |||
405 | antigen theme fox | ||
406 | |||
407 | This will get the theme file located at `themes/fox.zsh-theme` in the repo | ||
408 | specified by `ANTIGEN_DEFAULT_REPO_URL`. | ||
409 | |||
410 | To pull themes from other repositories, use `antigen theme` just like | ||
411 | `antigen bundle`. Exactly the same, just make sure the `url` and `loc` | ||
412 | combination point to a theme file, having a `.zsh-theme` extension. | ||
413 | |||
414 | For example, | ||
415 | |||
416 | antigen theme robbyrussell/oh-my-zsh themes/apple | ||
417 | |||
418 | Will pull the apple theme from the canonical oh-my-zsh repo. Also, note that the | ||
419 | `.zsh-theme` extension is not present. It can be given, its optional. | ||
420 | |||
421 | To get themes from arbitrary git repos (such as gists) use, | ||
422 | |||
423 | antigen theme https://gist.github.com/3750104.git agnoster | ||
424 | |||
425 | in which case there is a file called `agnoster.zsh-theme` present in the gist at | ||
426 | https://gist.github.com/3750104. | ||
427 | |||
428 | You can use this command to change your theme on the fly in your shell. Go on, | ||
429 | try out a few themes in your shell before you set it in your `.zshrc`. | ||
430 | |||
431 | **Note**: Some themes use functions that are loaded by `antigen use oh-my-zsh`. | ||
432 | So, to avoid any trouble, run `antigen use oh-my-zsh` if you haven't already | ||
433 | before experimenting with themes. If you have `antigen use oh-my-zsh` in your | ||
434 | `.zshrc`, you're covered. | ||
435 | |||
436 | **Note**: Do *not* provide the `--btype` argument to `antigen theme`. Its an | ||
437 | internal argument. | ||
438 | |||
439 | *For the interested, you can read more details on the purpose & workings of the | ||
440 | `theme` command on the comments of issue #78.* | ||
441 | |||
442 | ### antigen apply | ||
443 | |||
444 | You have to add this command after defining all bundles you need, in your zshrc. | ||
445 | The completions defined by your bundles will be loaded at this step. | ||
446 | |||
447 | It is possible to load completions as and when a bundle is specified with the | ||
448 | bundle command, in which case this command would not be necessary. But loading | ||
449 | the completions is a time-consuming process, so if the completions were loaded | ||
450 | at every call to `antigen bundle`, your shell will start noticeably slow when | ||
451 | you have a good number of bundle specifications. | ||
452 | |||
453 | However, if you can suggest a way so that this would not be necessary, I am very | ||
454 | interested in discussing it. Please open up an issue with your details. Thanks. | ||
455 | |||
456 | ### antigen snapshot <sup>α</sup> | ||
457 | |||
458 | Creates a snapshot of all the clones you currently have *active* including the | ||
459 | git version hash they are at and save it to a snapshot file. *Active* means, the | ||
460 | clones for those listed by `antigen cleanup` are not included in the snapshot. | ||
461 | |||
462 | Takes one optional argument, the file name in which the snapshot is to be saved. | ||
463 | Defaults to `antigen snapshot`. | ||
464 | |||
465 | **Note**: The snapshot currently *only* contains the details of those bundles | ||
466 | that have a clone. That is, bundles that have `--no-local-clone` set or are | ||
467 | directly sourced from your file system (without a git repo), are not recorded | ||
468 | in the snapshot file. | ||
469 | |||
470 | ### antigen restore <sup>α</sup> | ||
471 | |||
472 | Restore the bundles state as specified in the snapshot. Takes one required | ||
473 | argument, the snapshot file name to read. | ||
474 | |||
475 | Although it restores the clones of the repos specified in the snapshot file, any | ||
476 | other clones present in your environment are not touched. This behavior may | ||
477 | change in the future. | ||
478 | |||
479 | ### antigen selfupdate | ||
480 | |||
481 | Use this command to update your copy of antigen. It basically does a `git pull` | ||
482 | on your antigen's clone, *if* it is a git clone. Otherwise, it doesn't do | ||
483 | anything. | ||
484 | |||
485 | Takes no options. | ||
486 | |||
487 | ### antigen help | ||
488 | |||
489 | This exists so that there can be some help right in the command line. Currently | ||
490 | it doesn't provide much help other than redirecting you to the project page for | ||
491 | documentation. It is intended to provide more meaning and sub-command specific | ||
492 | help in the future. | ||
493 | |||
494 | I could use some help here as I'm not that good at writing documentation that | ||
495 | looks good as output on the command line. | ||
496 | |||
497 | ## Configuration | ||
498 | |||
499 | The following environment variables can be set to customize the behavior of | ||
500 | antigen. Make sure you set them *before* source-ing `antigen.zsh`. | ||
501 | |||
502 | `ANTIGEN_DEFAULT_REPO_URL` — This is the default repository url that is | ||
503 | used for `bundle` commands. The default value is robbyrussell's oh-my-zsh repo, | ||
504 | but you can set this to the fork url of your own fork. | ||
505 | |||
506 | `ADOTDIR` — This directory is used to store all the repo clones, your | ||
507 | bundles, themes, caches and everything else antigen requires to run smoothly. | ||
508 | Defaults to `$HOME/.antigen`. | ||
509 | |||
510 | **Note**: `ANTIGEN_REPO_CACHE` & `ANTIGEN_BUNDLE_DIR` — These variables | ||
511 | were used previously but are now removed. Please use `ADOTDIR` instead, as | ||
512 | mentioned above. | ||
513 | |||
514 | ## Running the tests | ||
515 | |||
516 | All the tests are in the `tests` folder and are run using the [cram][] test | ||
517 | system. The latest version on that website, as of today is v0.5, which does not | ||
518 | have the `--shell` argument which is required to run our tests. So, to get the | ||
519 | correct version of cram, run | ||
520 | |||
521 | pip install -r requirements.txt | ||
522 | |||
523 | With that, once you have cram installed, you can run the tests as | ||
524 | |||
525 | make | ||
526 | |||
527 | If you are making a feature addition, I'd really appreciate if you can add a | ||
528 | test for your feature. Even if you can add a test for an existing feature, that | ||
529 | would be great as the tests are currently seriously lagging behind the full | ||
530 | functionality of antigen. | ||
531 | |||
532 | ## Notes on writing plugins | ||
533 | |||
534 | Most shell utilities/plugins are made up of just one file. For a plugin called | ||
535 | `awesomeness`, create a `awesomeness.plugin.zsh` and code away. | ||
536 | |||
537 | That said, even if you write a single file as a `.sh` file with the goodness you | ||
538 | want to create, antigen will work just fine with it. The `*.plugin.zsh` way is | ||
539 | recommended by antigen, because it is widely used because of the [oh-my-zsh][] | ||
540 | project. | ||
541 | |||
542 | If you want to know how antigen loads the plugins, do continue. | ||
543 | |||
544 | Firstly, antigen looks for a `*.plugin.zsh` file in the plugin directory. If | ||
545 | present, it will source *only* this script. Nothing else is sourced. This is for | ||
546 | oh-my-zsh style plugins. | ||
547 | |||
548 | Secondly, it looks for a `init.zsh` file in the plugin directory. If present, it | ||
549 | will source *only* this script. Nothing else is sourced. This is for prezto | ||
550 | style modules. | ||
551 | |||
552 | Otherwise, it looks for `*.zsh` files and if there are any, *all* of them are | ||
553 | sourced. The order in which they are sourced is not currently defined. Please | ||
554 | don't rely on this order. Nothing else is sourced after all the `*.zsh` scripts. | ||
555 | |||
556 | If no `*.zsh` files are present, it finally looks for any `*.sh` files and | ||
557 | sources *all* of them. Again, the order in which they are sourced in not | ||
558 | currently defined. | ||
559 | |||
560 | No matter which (or none) of the above happen to be sourced, this plugin | ||
561 | directory is added to the zsh's function path (`$fpath`) so that any completions | ||
562 | in it are loaded. | ||
563 | |||
564 | One exception to this rule is that if this plugin is a theme. In which case the | ||
565 | theme script is just sourced and nothing else is done. Not even adding to | ||
566 | `$fpath`. | ||
567 | |||
568 | ## A note on external zsh plugins | ||
569 | |||
570 | Antigen downloads zsh scripts and sources them, according to your | ||
571 | specifications. As such, these scripts are capable of doing some *real* damage | ||
572 | to your system. If you are only downloading scripts from oh-my-zsh and/or | ||
573 | prezto, you're probably fine, since there is a second level of manual checking | ||
574 | before a script gets into the framework. | ||
575 | |||
576 | But, if you are adding a script from any other source, please check the source | ||
577 | code of the plugin to see its not doing anything malicious, before adding it to | ||
578 | your `.zshrc`. | ||
579 | |||
580 | ## Meta | ||
581 | |||
582 | ### Helping out | ||
583 | |||
584 | Antigen is licensed with the [MIT License][license]. | ||
585 | |||
586 | To contribute, please read the [contributing wiki page][contributing] before | ||
587 | sending pull requests. If its a long/complicated change, please consider opening | ||
588 | an [issue][] first so we can discuss it out. Thanks! | ||
589 | |||
590 | You may also wish to [donate to the project](https://gum.co/antigen). Thank you | ||
591 | so much! | ||
592 | |||
593 | ### Feedback please | ||
594 | |||
595 | Any comments/suggestions/feedback welcome. Please say hello to me | ||
596 | ([@sharat87][twitter]) on twitter. Or open an issue to discuss something | ||
597 | (anything!) about the project ;). | ||
598 | |||
599 | ### Alternatives to antigen | ||
600 | |||
601 | * [antigen-hs] - An antigen-inspired zsh plugin manager that tries to do work statically and only on manual invocation, minimizing the zsh startup time. Antigen-hs is much more minimalistic and convention over configuration than antigen. | ||
602 | |||
603 | |||
604 | [Vundle]: https://github.com/gmarik/vundle | ||
605 | [page on themes]: https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | ||
606 | [wild]: https://github.com/zsh-users/antigen/wiki/In-the-wild | ||
607 | [syntax highlighting plugin]: https://github.com/zsh-users/zsh-syntax-highlighting | ||
608 | [autoenv]: https://github.com/kennethreitz/autoenv | ||
609 | [f-autoenv]: https://github.com/sharat87/autoenv | ||
610 | [oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh | ||
611 | [cram]: https://bitheap.org/cram/ | ||
612 | [issue]: https://github.com/zsh-users/antigen/issues | ||
613 | [license]: http://mit.sharats.me | ||
614 | [contributing]: https://github.com/zsh-users/antigen/wiki/Contributing | ||
615 | [twitter]: http://twitter.com/sharat87 | ||
616 | [antigen-hs]: https://github.com/Tarrasch/antigen-hs | ||
617 | 1 | # Antigen <sup>v1</sup> |
repos/zsh-users/antigen/antigen.zsh
1 | # Antigen: A simple plugin manager for zsh | File was deleted | |
2 | # Authors: Shrikant Sharat Kandula | ||
3 | # and Contributors <https://github.com/zsh-users/antigen/contributors> | ||
4 | # Homepage: http://antigen.sharats.me | ||
5 | # License: MIT License <mitl.sharats.me> | ||
6 | |||
7 | # Each line in this string has the following entries separated by a space | ||
8 | # character. | ||
9 | # <repo-url>, <plugin-location>, <bundle-type>, <has-local-clone> | ||
10 | # FIXME: Is not kept local by zsh! | ||
11 | local _ANTIGEN_BUNDLE_RECORD="" | ||
12 | local _ANTIGEN_INSTALL_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
13 | |||
14 | # Used to defer compinit/compdef | ||
15 | typeset -a __deferred_compdefs | ||
16 | compdef () { __deferred_compdefs=($__deferred_compdefs "$*") } | ||
17 | |||
18 | # Syntaxes | ||
19 | # antigen-bundle <url> [<loc>=/] | ||
20 | # Keyword only arguments: | ||
21 | # branch - The branch of the repo to use for this bundle. | ||
22 | antigen-bundle () { | ||
23 | |||
24 | # Bundle spec arguments' default values. | ||
25 | local url="$ANTIGEN_DEFAULT_REPO_URL" | ||
26 | local loc=/ | ||
27 | local branch= | ||
28 | local no_local_clone=false | ||
29 | local btype=plugin | ||
30 | |||
31 | # Parse the given arguments. (Will overwrite the above values). | ||
32 | eval "$(-antigen-parse-args \ | ||
33 | 'url?, loc? ; branch:?, no-local-clone?, btype:?' \ | ||
34 | "$@")" | ||
35 | |||
36 | # Check if url is just the plugin name. Super short syntax. | ||
37 | if [[ "$url" != */* ]]; then | ||
38 | loc="plugins/$url" | ||
39 | url="$ANTIGEN_DEFAULT_REPO_URL" | ||
40 | fi | ||
41 | |||
42 | # Resolve the url. | ||
43 | url="$(-antigen-resolve-bundle-url "$url")" | ||
44 | |||
45 | # Add the branch information to the url. | ||
46 | if [[ ! -z $branch ]]; then | ||
47 | url="$url|$branch" | ||
48 | fi | ||
49 | |||
50 | # The `make_local_clone` variable better represents whether there should be | ||
51 | # a local clone made. For cloning to be avoided, firstly, the `$url` should | ||
52 | # be an absolute local path and `$branch` should be empty. In addition to | ||
53 | # these two conditions, either the `--no-local-clone` option should be | ||
54 | # given, or `$url` should not a git repo. | ||
55 | local make_local_clone=true | ||
56 | if [[ $url == /* && -z $branch && | ||
57 | ( $no_local_clone == true || ! -d $url/.git ) ]]; then | ||
58 | make_local_clone=false | ||
59 | fi | ||
60 | |||
61 | # Add the theme extension to `loc`, if this is a theme. | ||
62 | if [[ $btype == theme && $loc != *.zsh-theme ]]; then | ||
63 | loc="$loc.zsh-theme" | ||
64 | fi | ||
65 | |||
66 | # Add it to the record. | ||
67 | _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype" | ||
68 | _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD $make_local_clone" | ||
69 | |||
70 | # Ensure a clone exists for this repo, if needed. | ||
71 | if $make_local_clone; then | ||
72 | -antigen-ensure-repo "$url" | ||
73 | fi | ||
74 | |||
75 | # Load the plugin. | ||
76 | -antigen-load "$url" "$loc" "$make_local_clone" | ||
77 | |||
78 | } | ||
79 | |||
80 | -antigen-resolve-bundle-url () { | ||
81 | # Given an acceptable short/full form of a bundle's repo url, this function | ||
82 | # echoes the full form of the repo's clone url. | ||
83 | |||
84 | local url="$1" | ||
85 | |||
86 | # Expand short github url syntax: `username/reponame`. | ||
87 | if [[ $url != git://* && | ||
88 | $url != https://* && | ||
89 | $url != http://* && | ||
90 | $url != ssh://* && | ||
91 | $url != /* && | ||
92 | $url != git@github.com:*/* | ||
93 | ]]; then | ||
94 | url="https://github.com/${url%.git}.git" | ||
95 | fi | ||
96 | |||
97 | echo "$url" | ||
98 | } | ||
99 | |||
100 | antigen-bundles () { | ||
101 | # Bulk add many bundles at one go. Empty lines and lines starting with a `#` | ||
102 | # are ignored. Everything else is given to `antigen-bundle` as is, no | ||
103 | # quoting rules applied. | ||
104 | |||
105 | local line | ||
106 | |||
107 | grep '^[[:space:]]*[^[:space:]#]' | while read line; do | ||
108 | # Using `eval` so that we can use the shell-style quoting in each line | ||
109 | # piped to `antigen-bundles`. | ||
110 | eval "antigen-bundle $line" | ||
111 | done | ||
112 | } | ||
113 | |||
114 | antigen-update () { | ||
115 | # Update your bundles, i.e., `git pull` in all the plugin repos. | ||
116 | |||
117 | date > $ADOTDIR/revert-info | ||
118 | |||
119 | -antigen-echo-record | | ||
120 | awk '$4 == "true" {print $1}' | | ||
121 | sort -u | | ||
122 | while read url; do | ||
123 | echo "**** Pulling $url" | ||
124 | |||
125 | local clone_dir="$(-antigen-get-clone-dir "$url")" | ||
126 | if [[ -d "$clone_dir" ]]; then | ||
127 | (echo -n "$clone_dir:" | ||
128 | cd "$clone_dir" | ||
129 | git rev-parse HEAD) >> $ADOTDIR/revert-info | ||
130 | fi | ||
131 | |||
132 | -antigen-ensure-repo "$url" --update --verbose | ||
133 | |||
134 | echo | ||
135 | done | ||
136 | } | ||
137 | |||
138 | antigen-revert () { | ||
139 | if [[ -f $ADOTDIR/revert-info ]]; then | ||
140 | cat $ADOTDIR/revert-info | sed '1!p' | while read line; do | ||
141 | dir="$(echo "$line" | cut -d: -f1)" | ||
142 | git --git-dir="$dir/.git" --work-tree="$dir" \ | ||
143 | checkout "$(echo "$line" | cut -d: -f2)" 2> /dev/null | ||
144 | |||
145 | done | ||
146 | |||
147 | echo "Reverted to state before running -update on $( | ||
148 | cat $ADOTDIR/revert-info | sed -n 1p)." | ||
149 | |||
150 | else | ||
151 | echo 'No revert information available. Cannot revert.' >&2 | ||
152 | fi | ||
153 | |||
154 | |||
155 | } | ||
156 | |||
157 | -antigen-get-clone-dir () { | ||
158 | # Takes a repo url and gives out the path that this url needs to be cloned | ||
159 | # to. Doesn't actually clone anything. | ||
160 | echo -n $ADOTDIR/repos/ | ||
161 | |||
162 | if [[ "$1" == "https://github.com/sorin-ionescu/prezto.git" ]]; then | ||
163 | # Prezto's directory *has* to be `.zprezto`. | ||
164 | echo .zprezto | ||
165 | |||
166 | else | ||
167 | echo "$1" | sed \ | ||
168 | -e 's./.-SLASH-.g' \ | ||
169 | -e 's.:.-COLON-.g' \ | ||
170 | -e 's.|.-PIPE-.g' | ||
171 | |||
172 | fi | ||
173 | } | ||
174 | |||
175 | -antigen-get-clone-url () { | ||
176 | # Takes a repo's clone dir and gives out the repo's original url that was | ||
177 | # used to create the given directory path. | ||
178 | |||
179 | if [[ "$1" == ".zprezto" ]]; then | ||
180 | # Prezto's (in `.zprezto`), is assumed to be from `sorin-ionescu`'s | ||
181 | # remote. | ||
182 | echo https://github.com/sorin-ionescu/prezto.git | ||
183 | |||
184 | else | ||
185 | echo "$1" | sed \ | ||
186 | -e "s:^$ADOTDIR/repos/::" \ | ||
187 | -e 's.-SLASH-./.g' \ | ||
188 | -e 's.-COLON-.:.g' \ | ||
189 | -e 's.-PIPE-.|.g' | ||
190 | |||
191 | fi | ||
192 | } | ||
193 | |||
194 | -antigen-ensure-repo () { | ||
195 | |||
196 | # Ensure that a clone exists for the given repo url and branch. If the first | ||
197 | # argument is `--update` and if a clone already exists for the given repo | ||
198 | # and branch, it is pull-ed, i.e., updated. | ||
199 | |||
200 | # Argument defaults. | ||
201 | # The url. No sane default for this, so just empty. | ||
202 | local url= | ||
203 | # Check if we have to update. | ||
204 | local update=false | ||
205 | # Verbose output. | ||
206 | local verbose=false | ||
207 | |||
208 | eval "$(-antigen-parse-args 'url ; update?, verbose?' "$@")" | ||
209 | shift $# | ||
210 | |||
211 | # Get the clone's directory as per the given repo url and branch. | ||
212 | local clone_dir="$(-antigen-get-clone-dir $url)" | ||
213 | |||
214 | # A temporary function wrapping the `git` command with repeated arguments. | ||
215 | --plugin-git () { | ||
216 | (cd "$clone_dir" && git --no-pager "$@") | ||
217 | } | ||
218 | |||
219 | # Clone if it doesn't already exist. | ||
220 | if [[ ! -d $clone_dir ]]; then | ||
221 | git clone --recursive "${url%|*}" "$clone_dir" | ||
222 | elif $update; then | ||
223 | # Save current revision. | ||
224 | local old_rev="$(--plugin-git rev-parse HEAD)" | ||
225 | # Pull changes if update requested. | ||
226 | --plugin-git pull | ||
227 | # Update submodules. | ||
228 | --plugin-git submodule update --recursive | ||
229 | # Get the new revision. | ||
230 | local new_rev="$(--plugin-git rev-parse HEAD)" | ||
231 | fi | ||
232 | |||
233 | # If its a specific branch that we want, checkout that branch. | ||
234 | if [[ $url == *\|* ]]; then | ||
235 | local current_branch=${$(--plugin-git symbolic-ref HEAD)##refs/heads/} | ||
236 | local requested_branch="${url#*|}" | ||
237 | # Only do the checkout when we are not already on the branch. | ||
238 | [[ $requested_branch != $current_branch ]] && | ||
239 | --plugin-git checkout $requested_branch | ||
240 | fi | ||
241 | |||
242 | if [[ -n $old_rev && $old_rev != $new_rev ]]; then | ||
243 | echo Updated from ${old_rev:0:7} to ${new_rev:0:7}. | ||
244 | if $verbose; then | ||
245 | --plugin-git log --oneline --reverse --no-merges --stat '@{1}..' | ||
246 | fi | ||
247 | fi | ||
248 | |||
249 | # Remove the temporary git wrapper function. | ||
250 | unfunction -- --plugin-git | ||
251 | |||
252 | } | ||
253 | |||
254 | -antigen-load () { | ||
255 | |||
256 | local url="$1" | ||
257 | local loc="$2" | ||
258 | local make_local_clone="$3" | ||
259 | |||
260 | # The full location where the plugin is located. | ||
261 | local location | ||
262 | if $make_local_clone; then | ||
263 | location="$(-antigen-get-clone-dir "$url")/$loc" | ||
264 | else | ||
265 | location="$url/$loc" | ||
266 | fi | ||
267 | |||
268 | if [[ -f "$location" ]]; then | ||
269 | source "$location" | ||
270 | |||
271 | else | ||
272 | |||
273 | # Source the plugin script. | ||
274 | # FIXME: I don't know. Looks very very ugly. Needs a better | ||
275 | # implementation once tests are ready. | ||
276 | local script_loc="$(ls "$location" | grep '\.plugin\.zsh$' | head -n1)" | ||
277 | |||
278 | if [[ -f $location/$script_loc ]]; then | ||
279 | # If we have a `*.plugin.zsh`, source it. | ||
280 | source "$location/$script_loc" | ||
281 | |||
282 | elif [[ -f $location/init.zsh ]]; then | ||
283 | # If we have a `init.zsh` | ||
284 | if (( $+functions[pmodload] )); then | ||
285 | # If pmodload is defined pmodload the module. Remove `modules/` | ||
286 | # from loc to find module name. | ||
287 | pmodload "${loc#modules/}" | ||
288 | else | ||
289 | # Otherwise source it. | ||
290 | source "$location/init.zsh" | ||
291 | fi | ||
292 | |||
293 | elif ls "$location" | grep -l '\.zsh$' &> /dev/null; then | ||
294 | # If there is no `*.plugin.zsh` file, source *all* the `*.zsh` | ||
295 | # files. | ||
296 | for script ($location/*.zsh(N)) source "$script" | ||
297 | |||
298 | elif ls "$location" | grep -l '\.sh$' &> /dev/null; then | ||
299 | # If there are no `*.zsh` files either, we look for and source any | ||
300 | # `*.sh` files instead. | ||
301 | for script ($location/*.sh(N)) source "$script" | ||
302 | |||
303 | fi | ||
304 | |||
305 | # Add to $fpath, for completion(s). | ||
306 | fpath=($location $fpath) | ||
307 | |||
308 | fi | ||
309 | |||
310 | } | ||
311 | |||
312 | # Update (with `git pull`) antigen itself. | ||
313 | # TODO: Once update is finished, show a summary of the new commits, as a kind of | ||
314 | # "what's new" message. | ||
315 | antigen-selfupdate () { | ||
316 | ( cd $_ANTIGEN_INSTALL_DIR | ||
317 | if [[ ! ( -d .git || -f .git ) ]]; then | ||
318 | echo "Your copy of antigen doesn't appear to be a git clone. " \ | ||
319 | "The 'selfupdate' command cannot work in this case." | ||
320 | return 1 | ||
321 | fi | ||
322 | local head="$(git rev-parse --abbrev-ref HEAD)" | ||
323 | if [[ $head == "HEAD" ]]; then | ||
324 | # If current head is detached HEAD, checkout to master branch. | ||
325 | git checkout master | ||
326 | fi | ||
327 | git pull | ||
328 | ) | ||
329 | } | ||
330 | |||
331 | antigen-cleanup () { | ||
332 | |||
333 | # Cleanup unused repositories. | ||
334 | |||
335 | local force=false | ||
336 | if [[ $1 == --force ]]; then | ||
337 | force=true | ||
338 | fi | ||
339 | |||
340 | if [[ ! -d "$ADOTDIR/repos" || -z "$(ls "$ADOTDIR/repos/")" ]]; then | ||
341 | echo "You don't have any bundles." | ||
342 | return 0 | ||
343 | fi | ||
344 | |||
345 | # Find directores in ADOTDIR/repos, that are not in the bundles record. | ||
346 | local unused_clones="$(comm -13 \ | ||
347 | <(-antigen-echo-record | | ||
348 | awk '$4 == "true" {print $1}' | | ||
349 | while read line; do | ||
350 | -antigen-get-clone-dir "$line" | ||
351 | done | | ||
352 | sort -u) \ | ||
353 | <(ls -d "$ADOTDIR/repos/"* | sort -u))" | ||
354 | |||
355 | if [[ -z $unused_clones ]]; then | ||
356 | echo "You don't have any unidentified bundles." | ||
357 | return 0 | ||
358 | fi | ||
359 | |||
360 | echo 'You have clones for the following repos, but are not used.' | ||
361 | echo "$unused_clones" | | ||
362 | while read line; do | ||
363 | -antigen-get-clone-url "$line" | ||
364 | done | | ||
365 | sed -e 's/^/ /' -e 's/|/, branch /' | ||
366 | |||
367 | if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then | ||
368 | echo | ||
369 | echo | ||
370 | echo "$unused_clones" | while read line; do | ||
371 | echo -n "Deleting clone for $(-antigen-get-clone-url "$line")..." | ||
372 | rm -rf "$line" | ||
373 | echo ' done.' | ||
374 | done | ||
375 | else | ||
376 | echo | ||
377 | echo Nothing deleted. | ||
378 | fi | ||
379 | } | ||
380 | |||
381 | antigen-use () { | ||
382 | if [[ $1 == oh-my-zsh ]]; then | ||
383 | -antigen-use-oh-my-zsh | ||
384 | elif [[ $1 == prezto ]]; then | ||
385 | -antigen-use-prezto | ||
386 | else | ||
387 | echo 'Usage: antigen-use <library-name>' >&2 | ||
388 | echo 'Where <library-name> is any one of the following:' >&2 | ||
389 | echo ' * oh-my-zsh' >&2 | ||
390 | echo ' * prezto' >&2 | ||
391 | return 1 | ||
392 | fi | ||
393 | } | ||
394 | |||
395 | -antigen-use-oh-my-zsh () { | ||
396 | if [[ -z "$ZSH" ]]; then | ||
397 | export ZSH="$(-antigen-get-clone-dir "$ANTIGEN_DEFAULT_REPO_URL")" | ||
398 | fi | ||
399 | antigen-bundle --loc=lib | ||
400 | } | ||
401 | |||
402 | -antigen-use-prezto () { | ||
403 | antigen-bundle sorin-ionescu/prezto | ||
404 | export ZDOTDIR=$ADOTDIR/repos/ | ||
405 | } | ||
406 | |||
407 | # For backwards compatibility. | ||
408 | antigen-lib () { | ||
409 | -antigen-use-oh-my-zsh | ||
410 | echo '`antigen-lib` is deprecated and will soon be removed.' | ||
411 | echo 'Use `antigen-use oh-my-zsh` instead.' | ||
412 | } | ||
413 | |||
414 | # For backwards compatibility. | ||
415 | antigen-prezto-lib () { | ||
416 | -antigen-use-prezto | ||
417 | echo '`antigen-prezto-lib` is deprecated and will soon be removed.' | ||
418 | echo 'Use `antigen-use prezto` instead.' | ||
419 | } | ||
420 | |||
421 | antigen-theme () { | ||
422 | |||
423 | if [[ "$1" != */* && "$1" != --* ]]; then | ||
424 | # The first argument is just a name of the plugin, to be picked up from | ||
425 | # the default repo. | ||
426 | local name="${1:-robbyrussell}" | ||
427 | antigen-bundle --loc=themes/$name --btype=theme | ||
428 | |||
429 | else | ||
430 | antigen-bundle "$@" --btype=theme | ||
431 | |||
432 | fi | ||
433 | |||
434 | } | ||
435 | |||
436 | antigen-apply () { | ||
437 | |||
438 | # Initialize completion. | ||
439 | local cdef | ||
440 | |||
441 | # Load the compinit module. This will readefine the `compdef` function to | ||
442 | # the one that actually initializes completions. | ||
443 | autoload -U compinit | ||
444 | compinit -i | ||
445 | |||
446 | # Apply all `compinit`s that have been deferred. | ||
447 | eval "$(for cdef in $__deferred_compdefs; do | ||
448 | echo compdef $cdef | ||
449 | done)" | ||
450 | |||
451 | unset __deferred_compdefs | ||
452 | |||
453 | } | ||
454 | |||
455 | antigen-list () { | ||
456 | # List all currently installed bundles. | ||
457 | if [[ -z "$_ANTIGEN_BUNDLE_RECORD" ]]; then | ||
458 | echo "You don't have any bundles." >&2 | ||
459 | return 1 | ||
460 | else | ||
461 | -antigen-echo-record | sort -u | ||
462 | fi | ||
463 | } | ||
464 | |||
465 | antigen-snapshot () { | ||
466 | |||
467 | local snapshot_file="${1:-antigen-shapshot}" | ||
468 | |||
469 | # The snapshot content lines are pairs of repo-url and git version hash, in | ||
470 | # the form: | ||
471 | # <version-hash> <repo-url> | ||
472 | local snapshot_content="$(-antigen-echo-record | | ||
473 | grep 'true$' | | ||
474 | sed 's/ .*$//' | | ||
475 | sort -u | | ||
476 | while read url; do | ||
477 | local dir="$(-antigen-get-clone-dir "$url")" | ||
478 | local version_hash="$(cd "$dir" && git rev-parse HEAD)" | ||
479 | echo "$version_hash $url" | ||
480 | done)" | ||
481 | |||
482 | { | ||
483 | # The first line in the snapshot file is for metadata, in the form: | ||
484 | # key='value'; key='value'; key='value'; | ||
485 | # Where `key`s are valid shell variable names. | ||
486 | |||
487 | # Snapshot version. Has no relation to antigen version. If the snapshot | ||
488 | # file format changes, this number can be incremented. | ||
489 | echo -n "version='1';" | ||
490 | |||
491 | # Snapshot creation date+time. | ||
492 | echo -n " created_on='$(date)';" | ||
493 | |||
494 | # Add a checksum with the md5 checksum of all the snapshot lines. | ||
495 | chksum() { (md5sum; test $? = 127 && md5) 2>/dev/null | cut -d' ' -f1 } | ||
496 | local checksum="$(echo "$snapshot_content" | chksum)" | ||
497 | unset -f chksum; | ||
498 | echo -n " checksum='${checksum%% *}';" | ||
499 | |||
500 | # A newline after the metadata and then the snapshot lines. | ||
501 | echo "\n$snapshot_content" | ||
502 | |||
503 | } > "$snapshot_file" | ||
504 | |||
505 | } | ||
506 | |||
507 | antigen-restore () { | ||
508 | |||
509 | if [[ $# == 0 ]]; then | ||
510 | echo 'Please provide a snapshot file to restore from.' >&2 | ||
511 | return 1 | ||
512 | fi | ||
513 | |||
514 | local snapshot_file="$1" | ||
515 | |||
516 | # TODO: Before doing anything with the snapshot file, verify its checksum. | ||
517 | # If it fails, notify this to the user and confirm if restore should | ||
518 | # proceed. | ||
519 | |||
520 | echo -n "Restoring from $snapshot_file..." | ||
521 | |||
522 | sed -n '1!p' "$snapshot_file" | | ||
523 | while read line; do | ||
524 | |||
525 | local version_hash="${line%% *}" | ||
526 | local url="${line##* }" | ||
527 | local clone_dir="$(-antigen-get-clone-dir "$url")" | ||
528 | |||
529 | if [[ ! -d $clone_dir ]]; then | ||
530 | git clone "$url" "$clone_dir" &> /dev/null | ||
531 | fi | ||
532 | |||
533 | (cd "$clone_dir" && git checkout $version_hash) &> /dev/null | ||
534 | |||
535 | done | ||
536 | |||
537 | echo ' done.' | ||
538 | echo 'Please open a new shell to get the restored changes.' | ||
539 | } | ||
540 | |||
541 | antigen-help () { | ||
542 | cat <<EOF | ||
543 | Antigen is a plugin management system for zsh. It makes it easy to grab awesome | ||
544 | shell scripts and utilities, put up on github. For further details and complete | ||
545 | documentation, visit the project's page at 'http://antigen.sharats.me'. | ||
546 | EOF | ||
547 | } | ||
548 | |||
549 | # A syntax sugar to avoid the `-` when calling antigen commands. With this | ||
550 | # function, you can write `antigen-bundle` as `antigen bundle` and so on. | ||
551 | antigen () { | ||
552 | local cmd="$1" | ||
553 | if [[ -z "$cmd" ]]; then | ||
554 | echo 'Antigen: Please give a command to run.' >&2 | ||
555 | return 1 | ||
556 | fi | ||
557 | shift | ||
558 | |||
559 | if functions "antigen-$cmd" > /dev/null; then | ||
560 | "antigen-$cmd" "$@" | ||
561 | else | ||
562 | echo "Antigen: Unknown command: $cmd" >&2 | ||
563 | fi | ||
564 | } | ||
565 | |||
566 | -antigen-parse-args () { | ||
567 | # An argument parsing functionality to parse arguments the *antigen* way :). | ||
568 | # Takes one first argument (called spec), which dictates how to parse and | ||
569 | # the rest of the arguments are parsed. Outputs a piece of valid shell code | ||
570 | # that can be passed to `eval` inside a function which creates the arguments | ||
571 | # and their values as local variables. Suggested use is to set the defaults | ||
572 | # to all arguments first and then eval the output of this function. | ||
573 | |||
574 | # Spec: Only long argument supported. No support for parsing short options. | ||
575 | # The spec must have two sections, separated by a `;`. | ||
576 | # '<positional-arguments>;<keyword-only-arguments>' | ||
577 | # Positional arguments are passed as just values, like `command a b`. | ||
578 | # Keyword arguments are passed as a `--name=value` pair, like `command | ||
579 | # --arg1=a --arg2=b`. | ||
580 | |||
581 | # Each argument in the spec is separated by a `,`. Each keyword argument can | ||
582 | # end in a `:` to specifiy that this argument wants a value, otherwise it | ||
583 | # doesn't take a value. (The value in the output when the keyword argument | ||
584 | # doesn't have a `:` is `true`). | ||
585 | |||
586 | # Arguments in either section can end with a `?` (should come after `:`, if | ||
587 | # both are present), means optional. FIXME: Not yet implemented. | ||
588 | |||
589 | # See the test file, tests/arg-parser.t for (working) examples. | ||
590 | |||
591 | local spec="$1" | ||
592 | shift | ||
593 | |||
594 | # Sanitize the spec | ||
595 | spec="$(echo "$spec" | tr '\n' ' ' | sed 's/[[:space:]]//g')" | ||
596 | |||
597 | local code='' | ||
598 | |||
599 | --add-var () { | ||
600 | test -z "$code" || code="$code\n" | ||
601 | code="${code}local $1='$2'" | ||
602 | } | ||
603 | |||
604 | local positional_args="$(echo "$spec" | cut -d\; -f1)" | ||
605 | local positional_args_count="$(echo $positional_args | | ||
606 | awk -F, '{print NF}')" | ||
607 | |||
608 | # Set spec values based on the positional arguments. | ||
609 | local i=1 | ||
610 | while [[ -n $1 && $1 != --* ]]; do | ||
611 | |||
612 | if (( $i > $positional_args_count )); then | ||
613 | echo "Only $positional_args_count positional arguments allowed." >&2 | ||
614 | echo "Found at least one more: '$1'" >&2 | ||
615 | return | ||
616 | fi | ||
617 | |||
618 | local name_spec="$(echo "$positional_args" | cut -d, -f$i)" | ||
619 | local name="${${name_spec%\?}%:}" | ||
620 | local value="$1" | ||
621 | |||
622 | if echo "$code" | grep -l "^local $name=" &> /dev/null; then | ||
623 | echo "Argument '$name' repeated with the value '$value'". >&2 | ||
624 | return | ||
625 | fi | ||
626 | |||
627 | --add-var $name "$value" | ||
628 | |||
629 | shift | ||
630 | i=$(($i + 1)) | ||
631 | done | ||
632 | |||
633 | local keyword_args="$( | ||
634 | # Positional arguments can double up as keyword arguments too. | ||
635 | echo "$positional_args" | tr , '\n' | | ||
636 | while read line; do | ||
637 | if [[ $line == *\? ]]; then | ||
638 | echo "${line%?}:?" | ||
639 | else | ||
640 | echo "$line:" | ||
641 | fi | ||
642 | done | ||
643 | |||
644 | # Specified keyword arguments. | ||
645 | echo "$spec" | cut -d\; -f2 | tr , '\n' | ||
646 | )" | ||
647 | local keyword_args_count="$(echo $keyword_args | awk -F, '{print NF}')" | ||
648 | |||
649 | # Set spec values from keyword arguments, if any. The remaining arguments | ||
650 | # are all assumed to be keyword arguments. | ||
651 | while [[ $1 == --* ]]; do | ||
652 | # Remove the `--` at the start. | ||
653 | local arg="${1#--}" | ||
654 | |||
655 | # Get the argument name and value. | ||
656 | if [[ $arg != *=* ]]; then | ||
657 | local name="$arg" | ||
658 | local value='' | ||
659 | else | ||
660 | local name="${arg%\=*}" | ||
661 | local value="${arg#*=}" | ||
662 | fi | ||
663 | |||
664 | if echo "$code" | grep -l "^local $name=" &> /dev/null; then | ||
665 | echo "Argument '$name' repeated with the value '$value'". >&2 | ||
666 | return | ||
667 | fi | ||
668 | |||
669 | # The specification for this argument, used for validations. | ||
670 | local arg_line="$(echo "$keyword_args" | | ||
671 | egrep "^$name:?\??" | head -n1)" | ||
672 | |||
673 | # Validate argument and value. | ||
674 | if [[ -z $arg_line ]]; then | ||
675 | # This argument is not known to us. | ||
676 | echo "Unknown argument '$name'." >&2 | ||
677 | return | ||
678 | |||
679 | elif (echo "$arg_line" | grep -l ':' &> /dev/null) && | ||
680 | [[ -z $value ]]; then | ||
681 | # This argument needs a value, but is not provided. | ||
682 | echo "Required argument for '$name' not provided." >&2 | ||
683 | return | ||
684 | |||
685 | elif (echo "$arg_line" | grep -vl ':' &> /dev/null) && | ||
686 | [[ -n $value ]]; then | ||
687 | # This argument doesn't need a value, but is provided. | ||
688 | echo "No argument required for '$name', but provided '$value'." >&2 | ||
689 | return | ||
690 | |||
691 | fi | ||
692 | |||
693 | if [[ -z $value ]]; then | ||
694 | value=true | ||
695 | fi | ||
696 | |||
697 | --add-var "${name//-/_}" "$value" | ||
698 | shift | ||
699 | done | ||
700 | |||
701 | echo "$code" | ||
702 | |||
703 | unfunction -- --add-var | ||
704 | |||
705 | } | ||
706 | |||
707 | # Echo the bundle specs as in the record. The first line is not echoed since it | ||
708 | # is a blank line. | ||
709 | -antigen-echo-record () { | ||
710 | echo "$_ANTIGEN_BUNDLE_RECORD" | sed -n '1!p' | ||
711 | } | ||
712 | |||
713 | -antigen-env-setup () { | ||
714 | |||
715 | # Helper function: Same as `export $1=$2`, but will only happen if the name | ||
716 | # specified by `$1` is not already set. | ||
717 | -set-default () { | ||
718 | local arg_name="$1" | ||
719 | local arg_value="$2" | ||
720 | eval "test -z \"\$$arg_name\" && export $arg_name='$arg_value'" | ||
721 | } | ||
722 | |||
723 | # Pre-startup initializations. | ||
724 | -set-default ANTIGEN_DEFAULT_REPO_URL \ | ||
725 | https://github.com/robbyrussell/oh-my-zsh.git | ||
726 | -set-default ADOTDIR $HOME/.antigen | ||
727 | |||
728 | # Setup antigen's own completion. | ||
729 | compdef _antigen antigen | ||
730 | |||
731 | # Remove private functions. | ||
732 | unfunction -- -set-default | ||
733 | } | ||
734 | |||
735 | # Setup antigen's autocompletion | ||
736 | _antigen () { | ||
737 | compadd \ | ||
738 | bundle \ | ||
739 | bundles \ | ||
740 | update \ | ||
741 | revert \ | ||
742 | list \ | ||
743 | cleanup \ | ||
744 | use \ | ||
745 | selfupdate \ | ||
746 | theme \ | ||
747 | apply \ | ||
748 | snapshot \ | ||
749 | restore \ | ||
750 | help | ||
751 | } | ||
752 | |||
753 | -antigen-env-setup | ||
754 | 1 | # Antigen: A simple plugin manager for zsh |
repos/zsh-users/antigen/requirements.txt
1 | cram==0.6 | File was deleted | |
2 | 1 | cram==0.6 |
repos/zsh-users/antigen/tests/.zshenv
1 | # zshrc file written for antigen's tests. Might not be a good one for daily use. | File was deleted | |
2 | |||
3 | # See cram's documentation for some of the variables used below. | ||
4 | |||
5 | export ADOTDIR="$PWD/dot-antigen" | ||
6 | |||
7 | test -f "$TESTDIR/.zcompdump" && rm "$TESTDIR/.zcompdump" | ||
8 | |||
9 | source "$TESTDIR/../antigen.zsh" | ||
10 | |||
11 | # A test plugin repository to test out antigen with. | ||
12 | |||
13 | export PLUGIN_DIR="$PWD/test-plugin" | ||
14 | mkdir "$PLUGIN_DIR" | ||
15 | |||
16 | # A wrapper function over `git` to work with the test plugin repo. | ||
17 | alias pg='git --git-dir "$PLUGIN_DIR/.git" --work-tree "$PLUGIN_DIR"' | ||
18 | |||
19 | echo 'alias hehe="echo hehe"' > "$PLUGIN_DIR"/aliases.zsh | ||
20 | echo 'export PS1="prompt>"' > "$PLUGIN_DIR"/silly.zsh-theme | ||
21 | |||
22 | { | ||
23 | pg init | ||
24 | pg add . | ||
25 | pg commit -m 'Initial commit' | ||
26 | } > /dev/null | ||
27 | |||
28 | # Another test plugin. | ||
29 | |||
30 | export PLUGIN_DIR2="$PWD/test-plugin2" | ||
31 | mkdir "$PLUGIN_DIR2" | ||
32 | |||
33 | # A wrapper function over `git` to work with the test plugin repo. | ||
34 | alias pg2='git --git-dir "$PLUGIN_DIR2/.git" --work-tree "$PLUGIN_DIR2"' | ||
35 | |||
36 | echo 'alias hehe2="echo hehe2"' > "$PLUGIN_DIR2"/init.zsh | ||
37 | echo 'alias unsourced-alias="echo unsourced-alias"' > "$PLUGIN_DIR2"/aliases.zsh | ||
38 | |||
39 | { | ||
40 | pg2 init | ||
41 | pg2 add . | ||
42 | pg2 commit -m 'Initial commit' | ||
43 | } > /dev/null | ||
44 | 1 | # zshrc file written for antigen's tests. Might not be a good one for daily use. |
repos/zsh-users/antigen/tests/antigen-wrapper.t
1 | Create a dummy antigen command. | File was deleted | |
2 | |||
3 | $ antigen-dummy () { | ||
4 | > echo me dummy | ||
5 | > } | ||
6 | |||
7 | Check the normal way of calling it | ||
8 | |||
9 | $ antigen-dummy | ||
10 | me dummy | ||
11 | |||
12 | Call with the wrapper syntax. | ||
13 | |||
14 | $ antigen dummy | ||
15 | me dummy | ||
16 | |||
17 | Call with an alias | ||
18 | |||
19 | $ alias a=antigen | ||
20 | $ a dummy | ||
21 | me dummy | ||
22 | 1 | Create a dummy antigen command. |
repos/zsh-users/antigen/tests/arg-parser.t
1 | Helper alias. | File was deleted | |
2 | |||
3 | $ alias parse='-antigen-parse-args "url?, loc?; | ||
4 | > btype:?, no-local-clone?"' | ||
5 | |||
6 | No arguments (since all are specified as optional). | ||
7 | |||
8 | $ parse | ||
9 | (glob) | ||
10 | |||
11 | One positional argument. | ||
12 | |||
13 | $ parse name | ||
14 | local url='name' | ||
15 | |||
16 | Two arguments. | ||
17 | |||
18 | $ parse url location | ||
19 | local url='url' | ||
20 | local loc='location' | ||
21 | |||
22 | Three arguments. | ||
23 | |||
24 | $ parse url location crap | ||
25 | Only 2 positional arguments allowed. | ||
26 | Found at least one more: 'crap' | ||
27 | |||
28 | Keywordo magic. | ||
29 | |||
30 | $ parse url location --btype=1 --no-local-clone | ||
31 | local url='url' | ||
32 | local loc='location' | ||
33 | local btype='1' | ||
34 | local no_local_clone='true' | ||
35 | |||
36 | Unknown keyword argument. | ||
37 | |||
38 | $ parse --me=genius | ||
39 | Unknown argument 'me'. | ||
40 | |||
41 | Missed value for keyword argument. | ||
42 | |||
43 | $ parse --btype | ||
44 | Required argument for 'btype' not provided. | ||
45 | |||
46 | Provide value for keyword argument, that shouldn't be there. | ||
47 | |||
48 | $ parse --no-local-clone=yes | ||
49 | No argument required for 'no-local-clone', but provided 'yes'. | ||
50 | |||
51 | Positional argument as a keyword argument. | ||
52 | |||
53 | $ parse --url=some-url | ||
54 | local url='some-url' | ||
55 | |||
56 | Repeated keyword arguments. | ||
57 | |||
58 | $ parse --url=url1 --url=url2 | ||
59 | Argument 'url' repeated with the value 'url2'. | ||
60 | |||
61 | Repeated, once as positional and once more as keyword. | ||
62 | |||
63 | $ parse url1 --url=url2 | ||
64 | Argument 'url' repeated with the value 'url2'. | ||
65 | 1 | Helper alias. |
repos/zsh-users/antigen/tests/branch-bundle.t
1 | Branch b1. | File was deleted | |
2 | |||
3 | $ pg branch b1 | ||
4 | $ pg checkout b1 | ||
5 | Switched to branch 'b1' | ||
6 | $ cat > $PLUGIN_DIR/aliases.zsh <<EOF | ||
7 | > alias hehe='echo hehe from b1' | ||
8 | > EOF | ||
9 | $ pg commit -am 'Change for b1' | ||
10 | \[b1 [a-f0-9]{7}\] Change for b1 (re) | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | Go back to master. | ||
14 | |||
15 | $ pg checkout master | ||
16 | Switched to branch 'master' | ||
17 | |||
18 | Load plugin from b1. | ||
19 | |||
20 | $ antigen-bundle $PLUGIN_DIR --branch=b1 &> /dev/null | ||
21 | $ hehe | ||
22 | hehe from b1 | ||
23 | |||
24 | Does not say 'Already on b1' on each session startup. | ||
25 | |||
26 | $ antigen-bundle $PLUGIN_DIR --branch=b1 | ||
27 | |||
28 | Load plugin from master. | ||
29 | |||
30 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
31 | $ hehe | ||
32 | hehe | ||
33 | 1 | Branch b1. |
repos/zsh-users/antigen/tests/bundle-syntaxes.t
1 | Test helper and mock functions. | File was deleted | |
2 | |||
3 | $ ANTIGEN_DEFAULT_REPO_URL=gh-user/repo | ||
4 | |||
5 | $ b () { | ||
6 | > antigen-bundle "$@" | ||
7 | > } | ||
8 | |||
9 | $ -antigen-ensure-repo () {} | ||
10 | |||
11 | $ -antigen-load () { | ||
12 | > echo "url: $1" | ||
13 | > echo "dir: $2" | ||
14 | > echo "clone?: $3" | ||
15 | > } | ||
16 | |||
17 | Short and sweet. | ||
18 | |||
19 | $ b lol | ||
20 | url: https://github.com/gh-user/repo.git | ||
21 | dir: plugins/lol | ||
22 | clone?: true | ||
23 | |||
24 | Short repo url. | ||
25 | |||
26 | $ b github-username/repo-name | ||
27 | url: https://github.com/github-username/repo-name.git | ||
28 | dir: / | ||
29 | clone?: true | ||
30 | |||
31 | Short repo url with `.git` suffix. | ||
32 | |||
33 | $ b github-username/repo-name.git | ||
34 | url: https://github.com/github-username/repo-name.git | ||
35 | dir: / | ||
36 | clone?: true | ||
37 | |||
38 | Long repo url. | ||
39 | |||
40 | $ b https://github.com/user/repo.git | ||
41 | url: https://github.com/user/repo.git | ||
42 | dir: / | ||
43 | clone?: true | ||
44 | |||
45 | Long repo url with missing `.git` suffix (should'nt add the suffix). | ||
46 | |||
47 | $ b https://github.com/user/repo | ||
48 | url: https://github.com/user/repo | ||
49 | dir: / | ||
50 | clone?: true | ||
51 | |||
52 | Short repo with location. | ||
53 | |||
54 | $ b user/plugin path/to/plugin | ||
55 | url: https://github.com/user/plugin.git | ||
56 | dir: path/to/plugin | ||
57 | clone?: true | ||
58 | |||
59 | Keyword arguments, in respective places. | ||
60 | |||
61 | $ b --url=user/repo --loc=path/of/plugin | ||
62 | url: https://github.com/user/repo.git | ||
63 | dir: path/of/plugin | ||
64 | clone?: true | ||
65 | |||
66 | Keyword arguments, in respective places, with full repo url. | ||
67 | |||
68 | $ b --url=https://github.com/user/repo.git --loc=plugin/path | ||
69 | url: https://github.com/user/repo.git | ||
70 | dir: plugin/path | ||
71 | clone?: true | ||
72 | |||
73 | Keyword arguments, in reversed order. | ||
74 | |||
75 | $ b --loc=path/of/plugin --url=user/repo | ||
76 | url: https://github.com/user/repo.git | ||
77 | dir: path/of/plugin | ||
78 | clone?: true | ||
79 | |||
80 | Mixed positional and keyword arguments, and skip `loc`. | ||
81 | |||
82 | $ b user/repo --loc=plugin/loc | ||
83 | url: https://github.com/user/repo.git | ||
84 | dir: plugin/loc | ||
85 | clone?: true | ||
86 | |||
87 | Just `loc`, using keyword arguments. | ||
88 | |||
89 | $ b --loc=plugin/path | ||
90 | url: https://github.com/gh-user/repo.git | ||
91 | dir: plugin/path | ||
92 | clone?: true | ||
93 | |||
94 | TODO: Error reporting with erroneous arguments or usage with incorrect syntax. | ||
95 | 1 | Test helper and mock functions. |
repos/zsh-users/antigen/tests/bundle.t
1 | Load plugin from master. | File was deleted | |
2 | |||
3 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
4 | $ hehe | ||
5 | hehe | ||
6 | |||
7 | Load the plugin again. Just to see nothing happens. | ||
8 | |||
9 | $ antigen-bundle $PLUGIN_DIR | ||
10 | $ hehe | ||
11 | hehe | ||
12 | |||
13 | Confirm there is still only one repository. | ||
14 | |||
15 | $ ls $ADOTDIR/repos | wc -l | ||
16 | 1 | ||
17 | |||
18 | Load a prezto style module. Should only source the `init.zsh` present in the | ||
19 | module. | ||
20 | |||
21 | $ antigen-bundle $PLUGIN_DIR2 &> /dev/null | ||
22 | $ hehe2 | ||
23 | hehe2 | ||
24 | |||
25 | The alias defined in the other zsh file should not be available. | ||
26 | |||
27 | $ unsourced-alias | ||
28 | zsh: command not found: unsourced-alias | ||
29 | [127] | ||
30 | 1 | Load plugin from master. |
repos/zsh-users/antigen/tests/bundles.t
1 | Add multiple bundles. | File was deleted | |
2 | |||
3 | $ echo "$PLUGIN_DIR\n$PLUGIN_DIR2" | antigen-bundles &> /dev/null | ||
4 | |||
5 | Check if they are both applied. | ||
6 | |||
7 | $ hehe | ||
8 | hehe | ||
9 | $ hehe2 | ||
10 | hehe2 | ||
11 | |||
12 | Clean it all up. | ||
13 | |||
14 | $ export _ANTIGEN_BUNDLE_RECORD="" | ||
15 | $ antigen-cleanup --force &> /dev/null | ||
16 | |||
17 | Specify with indentation. | ||
18 | |||
19 | $ echo " $PLUGIN_DIR\n $PLUGIN_DIR2" | antigen-bundles &> /dev/null | ||
20 | |||
21 | Again, check if they are both applied. | ||
22 | |||
23 | $ hehe | ||
24 | hehe | ||
25 | $ hehe2 | ||
26 | hehe2 | ||
27 | 1 | Add multiple bundles. |
repos/zsh-users/antigen/tests/cleanup.t
1 | Firstly, no plugins, nothing to cleanup. | File was deleted | |
2 | |||
3 | $ antigen-cleanup --force | ||
4 | You don't have any bundles. | ||
5 | |||
6 | Load the plugins. | ||
7 | |||
8 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
9 | $ antigen-bundle $PLUGIN_DIR2 &> /dev/null | ||
10 | |||
11 | Check the listing. | ||
12 | |||
13 | $ antigen-list | ||
14 | */test-plugin / plugin true (glob) | ||
15 | */test-plugin2 / plugin true (glob) | ||
16 | |||
17 | Nothing should be available for cleanup. | ||
18 | |||
19 | $ antigen-cleanup --force | ||
20 | You don't have any unidentified bundles. | ||
21 | |||
22 | Clear out the bundles record. | ||
23 | |||
24 | $ _ANTIGEN_BUNDLE_RECORD="" | ||
25 | |||
26 | Check the listing, after clearing the record. | ||
27 | |||
28 | $ antigen-list | ||
29 | You don't have any bundles. | ||
30 | [1] | ||
31 | |||
32 | Confirm the plugin directory exists. | ||
33 | |||
34 | $ ls dot-antigen/repos | wc -l | ||
35 | 2 | ||
36 | |||
37 | Do the cleanup. | ||
38 | |||
39 | $ antigen-cleanup --force | ||
40 | You have clones for the following repos, but are not used. | ||
41 | */test-plugin (glob) | ||
42 | */test-plugin2 (glob) | ||
43 | |||
44 | |||
45 | Deleting clone for */test-plugin... done. (glob) | ||
46 | Deleting clone for */test-plugin2... done. (glob) | ||
47 | |||
48 | Check the listing, after cleanup. | ||
49 | |||
50 | $ antigen-list | ||
51 | You don't have any bundles. | ||
52 | [1] | ||
53 | |||
54 | Confirm the plugin directory does not exist after cleanup. | ||
55 | |||
56 | $ ls dot-antigen/repos | wc -l | ||
57 | 0 | ||
58 | 1 | Firstly, no plugins, nothing to cleanup. |
repos/zsh-users/antigen/tests/list.t
1 | Empty initial listing. | File was deleted | |
2 | |||
3 | $ antigen-list | ||
4 | You don't have any bundles. | ||
5 | [1] | ||
6 | |||
7 | Add a bundle. | ||
8 | |||
9 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
10 | $ antigen-list | ||
11 | */test-plugin / plugin true (glob) | ||
12 | |||
13 | Add same bundle and check uniqueness. | ||
14 | |||
15 | $ antigen-bundle $PLUGIN_DIR | ||
16 | $ antigen-list | ||
17 | */test-plugin / plugin true (glob) | ||
18 | |||
19 | Add another bundle. | ||
20 | |||
21 | $ antigen-bundle $PLUGIN_DIR2 &> /dev/null | ||
22 | $ antigen-list | ||
23 | */test-plugin / plugin true (glob) | ||
24 | */test-plugin2 / plugin true (glob) | ||
25 | 1 | Empty initial listing. |
repos/zsh-users/antigen/tests/no_local_clone.t
1 | Load the plugin with no local clone. | File was deleted | |
2 | |||
3 | $ antigen-bundle $PLUGIN_DIR --no-local-clone | ||
4 | |||
5 | Check if the plugin is loaded correctly. | ||
6 | |||
7 | $ hehe | ||
8 | hehe | ||
9 | |||
10 | Confirm no clone is made. | ||
11 | |||
12 | $ test -d dot-antigen | ||
13 | [1] | ||
14 | |||
15 | Load the plugin with a clone. | ||
16 | |||
17 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
18 | |||
19 | Empty the record. | ||
20 | |||
21 | $ _ANTIGEN_BUNDLE_RECORD= | ||
22 | |||
23 | Load the plugin again with no local clone. | ||
24 | |||
25 | $ antigen-bundle $PLUGIN_DIR --no-local-clone | ||
26 | |||
27 | The cleanup should list the bundle's clone. | ||
28 | |||
29 | $ antigen-cleanup --force | ||
30 | You have clones for the following repos, but are not used. | ||
31 | */test-plugin (glob) | ||
32 | |||
33 | |||
34 | Deleting clone for */test-plugin... done. (glob) | ||
35 | 1 | Load the plugin with no local clone. |
repos/zsh-users/antigen/tests/revert-update.t
1 | Load and test plugin. | File was deleted | |
2 | |||
3 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
4 | $ hehe | ||
5 | hehe | ||
6 | |||
7 | Save the current HEAD of the plugin. | ||
8 | |||
9 | $ old_version="$(pg rev-parse HEAD)" | ||
10 | |||
11 | Modify the plugin. | ||
12 | |||
13 | $ cat > $PLUGIN_DIR/aliases.zsh <<EOF | ||
14 | > alias hehe='echo hehe, updated' | ||
15 | > EOF | ||
16 | $ pg commit -am 'Updated message' | ||
17 | \[master [a-f0-9]{7}\] Updated message (re) | ||
18 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
19 | |||
20 | Save the new HEAD of the plugin. | ||
21 | |||
22 | $ new_version="$(pg rev-parse HEAD)" | ||
23 | |||
24 | Define a convenience function to get the current version. | ||
25 | |||
26 | $ current-version () {(cd dot-antigen/repos/* && git rev-parse HEAD)} | ||
27 | |||
28 | Confirm we currently have the old version. | ||
29 | |||
30 | $ [[ $(current-version) == $old_version ]] | ||
31 | |||
32 | Run antigen's update. | ||
33 | |||
34 | $ antigen-update | ||
35 | **** Pulling */test-plugin (glob) | ||
36 | From */test-plugin (glob) | ||
37 | ???????..??????? master -> origin/master (glob) | ||
38 | Updating ???????..??????? (glob) | ||
39 | Fast-forward | ||
40 | aliases.zsh |\s+2 \+- (re) | ||
41 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
42 | Updated from ??????? to ???????. (glob) | ||
43 | ??????? Updated message (glob) | ||
44 | aliases.zsh |\s+2 +- (re) | ||
45 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
46 | |||
47 | |||
48 | Confirm we have the new version. | ||
49 | |||
50 | $ [[ $(current-version) == $new_version ]] | ||
51 | |||
52 | Run update again, with no changes in the origin repo. | ||
53 | |||
54 | $ antigen-revert | ||
55 | Reverted to state before running -update on *. (glob) | ||
56 | |||
57 | Confirm we have the old version again. | ||
58 | |||
59 | $ [[ $(current-version) == $old_version ]] | ||
60 | 1 | Load and test plugin. |
repos/zsh-users/antigen/tests/selfupdate.t
1 | Set environment variables for this test case | File was deleted | |
2 | |||
3 | $ export TEST_DIR=$PWD | ||
4 | $ export TEST_HOST=$TEST_DIR/host | ||
5 | $ export TEST_NORMAL=$TEST_DIR/client | ||
6 | $ export TEST_SUBMODULE=$TEST_DIR/submodule | ||
7 | |||
8 | Create fake host repository | ||
9 | |||
10 | $ mkdir -p $TEST_HOST | ||
11 | $ cd $TEST_HOST | ||
12 | $ git init | ||
13 | Initialized empty Git repository in * (glob) | ||
14 | $ echo 1 > ver | ||
15 | $ git add ver | ||
16 | $ git commit -m "1" | ||
17 | [master (root-commit) ???????] 1 (glob) | ||
18 | 1 file changed, 1 insertion(+) | ||
19 | create mode 100644 ver | ||
20 | |||
21 | Create a normal repository cloning from host | ||
22 | |||
23 | $ git clone $TEST_HOST $TEST_NORMAL &> /dev/null | ||
24 | |||
25 | Create a submodule repository cloning from host | ||
26 | |||
27 | $ mkdir -p $TEST_SUBMODULE | ||
28 | $ cd $TEST_SUBMODULE | ||
29 | $ git init | ||
30 | Initialized empty Git repository in * (glob) | ||
31 | $ git submodule add $TEST_HOST antigen &> /dev/null | ||
32 | $ git commit -m "1" | ||
33 | [master (root-commit) ???????] 1 (glob) | ||
34 | 2 files changed, 4 insertions(+) | ||
35 | create mode 100644 .gitmodules | ||
36 | create mode 160000 antigen | ||
37 | |||
38 | Update host repository | ||
39 | |||
40 | $ cd $TEST_HOST | ||
41 | $ echo 2 > ver | ||
42 | $ git add ver | ||
43 | $ git commit -m "2" | ||
44 | [master ???????] 2 (glob) | ||
45 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
46 | |||
47 | Use selfupdate from normal repository | ||
48 | |||
49 | $ _ANTIGEN_INSTALL_DIR=$TEST_NORMAL antigen-selfupdate | ||
50 | From * (glob) | ||
51 | ???????..??????? master -> origin/master (glob) | ||
52 | Updating ???????..??????? (glob) | ||
53 | Fast-forward | ||
54 | ver | 2 +- | ||
55 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
56 | $ _ANTIGEN_INSTALL_DIR=$TEST_NORMAL antigen-selfupdate | ||
57 | Already up-to-date. | ||
58 | |||
59 | Use selfupdate from submodule repository | ||
60 | |||
61 | $ _ANTIGEN_INSTALL_DIR=$TEST_SUBMODULE/antigen antigen-selfupdate | ||
62 | From * (glob) | ||
63 | ???????..??????? master -> origin/master (glob) | ||
64 | Updating ???????..??????? (glob) | ||
65 | Fast-forward | ||
66 | ver | 2 +- | ||
67 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
68 | $ _ANTIGEN_INSTALL_DIR=$TEST_SUBMODULE/antigen antigen-selfupdate | ||
69 | Already up-to-date. | ||
70 | 1 | Set environment variables for this test case |
repos/zsh-users/antigen/tests/snapshots.t
1 | Load a couple of plugins. | File was deleted | |
2 | |||
3 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
4 | $ antigen-bundle $PLUGIN_DIR2 &> /dev/null | ||
5 | |||
6 | Create a snapshot file. | ||
7 | |||
8 | $ test -f snapshot-file | ||
9 | [1] | ||
10 | $ antigen-snapshot snapshot-file | ||
11 | $ test -f snapshot-file | ||
12 | |||
13 | See the contents of the snapshot file. | ||
14 | |||
15 | $ cat snapshot-file | ||
16 | version='1'; created_on='*'; checksum='*'; (glob) | ||
17 | .{40} .*/test-plugin (re) | ||
18 | .{40} .*/test-plugin2 (re) | ||
19 | |||
20 | Reset the antigen's bundle record and run cleanup. | ||
21 | |||
22 | $ unset _ANTIGEN_BUNDLE_RECORD | ||
23 | $ antigen-cleanup --force | grep '^Deleting' | wc -l | ||
24 | 2 | ||
25 | |||
26 | Restore from the snapshot. | ||
27 | |||
28 | $ ls dot-antigen/repos | wc -l | ||
29 | 0 | ||
30 | $ antigen-restore snapshot-file | ||
31 | Restoring from snapshot-file... done. | ||
32 | Please open a new shell to get the restored changes. | ||
33 | $ ls dot-antigen/repos | wc -l | ||
34 | 2 | ||
35 | 1 | Load a couple of plugins. |
repos/zsh-users/antigen/tests/theme.t
1 | Load the theme explicitly. | File was deleted | |
2 | |||
3 | $ antigen-theme $PLUGIN_DIR silly &> /dev/null | ||
4 | $ echo "$PS1" | ||
5 | prompt> | ||
6 | 1 | Load the theme explicitly. |
repos/zsh-users/antigen/tests/update.t
1 | Load plugin. | File was deleted | |
2 | |||
3 | $ antigen-bundle $PLUGIN_DIR &> /dev/null | ||
4 | $ hehe | ||
5 | hehe | ||
6 | |||
7 | Update the plugin. | ||
8 | |||
9 | $ cat > $PLUGIN_DIR/aliases.zsh <<EOF | ||
10 | > alias hehe='echo hehe, updated' | ||
11 | > EOF | ||
12 | $ pg commit -am 'Updated message' | ||
13 | \[master [a-f0-9]{7}\] Updated message (re) | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | Run antigen's update. | ||
17 | |||
18 | $ antigen-update | ||
19 | **** Pulling */test-plugin (glob) | ||
20 | From */test-plugin (glob) | ||
21 | ???????..??????? master -> origin/master (glob) | ||
22 | Updating ???????..??????? (glob) | ||
23 | Fast-forward | ||
24 | aliases.zsh |\s+2 \+- (re) | ||
25 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
26 | Updated from ??????? to ???????. (glob) | ||
27 | ??????? Updated message (glob) | ||
28 | aliases.zsh |\s+2 \+- (re) | ||
29 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
30 | |||
31 | |||
32 | Confirm there is still only one repository. | ||
33 | |||
34 | $ ls $ADOTDIR/repos | wc -l | ||
35 | 1 | ||
36 | |||
37 | The new alias should not activate. | ||
38 | |||
39 | $ hehe | ||
40 | hehe | ||
41 | |||
42 | Run update again, with no changes in the origin repo. | ||
43 | |||
44 | $ antigen-update | ||
45 | **** Pulling */test-plugin (glob) | ||
46 | Already up-to-date. | ||
47 | |||
48 | 1 | Load plugin. |
repos/zsh-users/antigen/tests/url-resolver.t
1 | Helper alias. | File was deleted | |
2 | |||
3 | $ alias resolve=-antigen-resolve-bundle-url | ||
4 | |||
5 | Complete urls. | ||
6 | |||
7 | $ resolve https://github.com/zsh-users/antigen.git | ||
8 | https://github.com/zsh-users/antigen.git | ||
9 | $ resolve git://github.com/zsh-users/antigen.git | ||
10 | git://github.com/zsh-users/antigen.git | ||
11 | $ resolve git@github.com:zsh-users/antigen.git | ||
12 | git@github.com:zsh-users/antigen.git | ||
13 | |||
14 | Complete github urls, missing the `.git` suffix. | ||
15 | |||
16 | $ resolve https://github.com/zsh-users/antigen | ||
17 | https://github.com/zsh-users/antigen | ||
18 | $ resolve git://github.com/zsh-users/antigen | ||
19 | git://github.com/zsh-users/antigen | ||
20 | $ resolve git@github.com:zsh-users/antigen | ||
21 | git@github.com:zsh-users/antigen | ||
22 | |||
23 | Just username and repo name. | ||
24 | |||
25 | $ resolve zsh-users/antigen | ||
26 | https://github.com/zsh-users/antigen.git | ||
27 | $ resolve zsh-users/antigen.git | ||
28 | https://github.com/zsh-users/antigen.git | ||
29 | |||
30 | Local absolute file path. | ||
31 | |||
32 | $ resolve /path/to/a/local/git/repo | ||
33 | /path/to/a/local/git/repo | ||
34 | 1 | Helper alias. |
repos/zsh-users/antigen/tests/use.t
1 | Use unknown library. | File was deleted | |
2 | |||
3 | $ antigen-use unknown | ||
4 | Usage: antigen-use <library-name> | ||
5 | Where <library-name> is any one of the following: | ||
6 | * oh-my-zsh | ||
7 | * prezto | ||
8 | [1] | ||
9 | |||
10 | Missing argument. | ||
11 | |||
12 | $ antigen-use | ||
13 | Usage: antigen-use <library-name> | ||
14 | Where <library-name> is any one of the following: | ||
15 | * oh-my-zsh | ||
16 | * prezto | ||
17 | [1] | ||
18 | |||
19 | Mock out the library loading functions. | ||
20 | |||
21 | $ -antigen-use-oh-my-zsh () { echo Using oh-my-zsh. } | ||
22 | $ -antigen-use-prezto () { echo Using prezto. } | ||
23 | |||
24 | Note: We lack tests for these internal functions. I'm not sure how feasible | ||
25 | testing them is given they most certainly use the network. | ||
26 | |||
27 | Use oh-my-zsh library. | ||
28 | |||
29 | $ antigen-use oh-my-zsh | ||
30 | Using oh-my-zsh. | ||
31 | |||
32 | Use prezto library. | ||
33 | |||
34 | $ antigen-use prezto | ||
35 | Using prezto. | ||
36 | 1 | Use unknown library. |
repos/zsh-users/antigen/travis-ppa.sh
1 | #! /bin/sh | File was deleted | |
2 | if [ $PPA != 'none' ];then | ||
3 | sudo apt-add-repository -y $PPA; | ||
4 | sudo apt-get update -qq; | ||
5 | fi | ||
6 | 1 | #! /bin/sh |