Blame view
README.mkd
13.6 KB
|
b84833b4c
|
1 2 3 4 5 |
# Antigen 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. |
|
015b9e5e9
|
6 7 8 9 |
Please note that this is a very new project and can be considered beta at best. That said, I am using antigen full time now on my work machine. Also, please read the commit comments of the changesets when you pull a new version of antigen. |
|
e1bf049d8
|
10 |
|
|
ac6ddd7d4
|
11 |
## Show off |
|
8f0e534f1
|
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
> Enough talk. Let's fight!
> -- Po, Kung-fu Panda.
You're going to experience antigen right in your open shell. No `.zshrc`
tweaking and reading the rest of this documentation. Kinda like an ice-cream
sample, if you will.
Get and load antigen.
curl https://raw.github.com/zsh-users/antigen/master/antigen.zsh > antigen.zsh
source antigen.zsh
There. You now have all the antigen goodies. Let's try install some plugins. How
|
|
b36de9bb3
|
26 27 |
about some color to start with. Get the [syntax highlighting plugin][] by running |
|
8f0e534f1
|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
antigen-bundle zsh-users/zsh-syntax-highlighting
Now let it do its thing and once its done and you're back at your prompt, try
and type a command. See that? Colors!
So, you do git? ruby? git and ruby? There are lots of awesome plugins over at
oh-my-zsh. Treat yourself to some.
antigen-bundle robbyrussell/oh-my-zsh plugins/ruby
antigen-bundle robbyrussell/oh-my-zsh plugins/git
There are lots of plugins out there in the wild and people are writing zsh
utilities as small scripts all the time. Antigen is compatible with all of them.
The plugins and scripts don't need any special handling to be compatible with
antigen.
|
|
3e16c4709
|
44 45 46 47 48 49 50 |
Another example, [kennethreitz's autoenv](autoenv). Just a bundle command away.
antigen-bundle kennethreitz/autoenv
And boom! you have all the autoenv goodness. Just remember how you used to do
these before antigen, clone it, modify your bashrc to source it, load a new
terminal, all just to test it out. Duh!
|
|
8f0e534f1
|
51 52 53 54 55 56 57 58 59 |
The side effect of this is that you can tell antigen to grab just about anything
from anyone's `dotfiles` repo, as long as it is in a directory under any repo on
github.
And themes? How would you like a fancy new prompt for yourself?
antigen-theme funky
No? Not your taste? There are many themes available to you, check out the
|
|
b36de9bb3
|
60 |
oh-my-zsh's [page on themes][]. (You can currently only install themes from |
|
8f0e534f1
|
61 62 63 64 65 66 67 68 69 |
robbyrussell's, i.e., the canonical oh-my-zsh repo).
Note: Many of those plugins and especially themes, assume you have the core
library of oh-my-zsh loaded. So, if you want to experiment further, issue a
antigen-lib
and continue until you're tired. At which point you can come back to this page
;)
|
|
ac6ddd7d4
|
70 |
## Usage |
|
8f0e534f1
|
71 72 73 |
So, now that you're here, I'll assume you are convinced and want antigen running your shell all the time. Sweet. Let's do it. |
|
b84833b4c
|
74 |
|
|
3c698aac0
|
75 76 77 78 |
First, clone this repo, probably as a submodule if you have your dotfiles in a
git repo,
git clone https://github.com/sharat87/antigen.git
|
|
b84833b4c
|
79 80 |
The usage should be very familiar to you if you use Vundle. A typical `.zshrc` might look like this |
|
3c698aac0
|
81 |
source /path-to-antigen-clone/antigen.zsh |
|
b84833b4c
|
82 83 |
# Load the oh-my-zsh's library.
|
|
de8d00ed4
|
84 |
antigen-lib |
|
b84833b4c
|
85 86 |
# Bundles from the default repo (robbyrussell's oh-my-zsh).
|
|
de8d00ed4
|
87 88 89 90 91 |
antigen-bundle git
antigen-bundle heroku
antigen-bundle pip
antigen-bundle lein
antigen-bundle command-not-found
|
|
b84833b4c
|
92 93 |
# Syntax highlighting bundle.
|
|
de8d00ed4
|
94 |
antigen-bundle zsh-users/zsh-syntax-highlighting |
|
b84833b4c
|
95 96 |
# Load the theme.
|
|
de8d00ed4
|
97 |
antigen-theme robbyrussell |
|
b84833b4c
|
98 |
|
|
1af74ea9e
|
99 |
# Tell antigen that you're done. |
|
de8d00ed4
|
100 |
antigen-apply |
|
1af74ea9e
|
101 |
|
|
7ba3548fd
|
102 103 |
Open your zsh with this zshrc and you should see all the bundles you defined here, getting installed. Once its done, you are ready to roll. The complete |
|
de8d00ed4
|
104 |
syntax for the `antigen-bundle` command is discussed further down on this page. |
|
b84833b4c
|
105 |
|
|
ac6ddd7d4
|
106 |
## Motivation |
|
b84833b4c
|
107 108 109 110 111 |
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 a 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 |
|
7ba3548fd
|
112 |
admire robbyrussell's efforts for reviewing and merging the gigantic number of |
|
b84833b4c
|
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
pull requests the project gets. It needs 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.
Antigen also lets you switch the prompt theme with one command, just like that
bundle-theme candy
and your prompt is changed, just for this session of course.
|
|
ac6ddd7d4
|
134 |
## Commands |
|
b84833b4c
|
135 |
|
|
ac6ddd7d4
|
136 |
### antigen-bundle |
|
b84833b4c
|
137 |
|
|
7ba3548fd
|
138 139 |
This command tells antigen to install (if not already installed) and load the given plugin. The simplest usage follows the following syntax. |
|
b84833b4c
|
140 |
|
|
2fe4683b3
|
141 |
antigen-bundle <plugin-name> |
|
7e0aca7ce
|
142 |
|
|
7ba3548fd
|
143 |
This will install the `plugins/<name>` directory from [robbyrussell's |
|
7e0aca7ce
|
144 |
oh-my-zsh][oh-my-zsh] (can be changed by setting `ANTIGEN_DEFAULT_REPO_URL`). |
|
2fe4683b3
|
145 146 |
However, the above is just syntax sugar for the extended syntax of the `antigen-bundle` command. |
|
7e0aca7ce
|
147 |
|
|
2fe4683b3
|
148 |
antigen-bundle [<url> [<loc>]] |
|
b84833b4c
|
149 150 |
where `<url>` is the repository url and it defaults to [robbyrussell's |
|
7ba3548fd
|
151 152 153 154 155 |
oh-my-zsh][oh-my-zsh] repo (can be changed by setting `ANTIGEN_DEFAULT_REPO_URL` discussed further down). `<loc>` is the path under this repository which has the zsh plugin. This is typically the directory that contains a `*.plugin.zsh` file, but it could contain a completion file or just many `*.zsh` files to be sourced. `<loc>` defaults to `/`, which indicates the repository itself is a plugin. |
|
b84833b4c
|
156 157 |
An example invocation would be |
|
2fe4683b3
|
158 159 160 |
# The following is the same as `antigen-bundle ant`. But for demonstration
# purposes, we use the extended syntax here.
antigen-bundle https://github.com/robbyrussell/oh-my-zsh.git plugins/ant
|
|
b84833b4c
|
161 |
|
|
7ba3548fd
|
162 163 |
This would install the ant plugin from robbyrussell's oh-my-zsh repo. Of course, github url's can be shortened. |
|
b84833b4c
|
164 |
|
|
2fe4683b3
|
165 |
antigen-bundle robbyrussell/oh-my-zsh plugins/ant |
|
b84833b4c
|
166 |
|
|
7ba3548fd
|
167 168 |
And since this repo is the default, even that isn't necessary. But we can't specify the `loc` without giving the first argument. |
|
b84833b4c
|
169 |
|
|
2fe4683b3
|
170 171 |
For this and a few other reasons, `antigen-bundle` also supports a simple keyword argument syntax, using which we can rewrite the above as |
|
b84833b4c
|
172 |
|
|
2fe4683b3
|
173 |
antigen-bundle --loc=plugins/ant |
|
b84833b4c
|
174 |
|
|
7ba3548fd
|
175 176 |
Which picks up the default for the `url` argument, and uses the `loc` given to it. |
|
7e0aca7ce
|
177 |
|
|
7ba3548fd
|
178 179 |
*Note* that you can mix and match positional and keyword arguments. But you can't have positional arguments after keyword arguments. |
|
b84833b4c
|
180 |
|
|
2fe4683b3
|
181 |
antigen-bundle robbyrussell/oh-my-zsh --loc=plugins/ant |
|
b84833b4c
|
182 183 184 |
And keyword arguments don't care about the order in which the arguments are specified. The following is perfectly valid. |
|
2fe4683b3
|
185 |
antigen-bundle --loc=plugins/ant --url=robbyrussell/oh-my-zsh |
|
5e26a8e26
|
186 |
|
|
2fe4683b3
|
187 188 189 190 |
In addition to the above discussed arguments, `antigen-bundle` also takes a `btype` keyword-only argument, that is used internally. You shouldn't be concerned with this argument, its only used internally and will probably go away in the future. It indicates whether the bundle is a theme or a simple plugin. |
|
5e26a8e26
|
191 |
|
|
2fe4683b3
|
192 193 194 195 |
You can use this `antigen-bundle` command not just from your `.zshrc`, but also from your shell environment. This allows you to install plugins on the fly and try them out. Of course if you want a bundle to be available every time you open a shell, put it in your `.zshrc`. |
|
5e26a8e26
|
196 |
|
|
4129490ce
|
197 |
Other keyword-only arguments accepted: |
|
e7bf36002
|
198 |
`branch` — Specify the branch of the git repo to be used for this bundle. |
|
4129490ce
|
199 200 201 202 |
Please note that if you specify two plugins to be loaded from the same git repo, but different branches, then two separate clones of this repo will be maintained. This is a small implementation detail and shouldn't influence you in any way. |
|
ac6ddd7d4
|
203 |
### antigen-bundles |
|
78ea5a9f4
|
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
If you have a fair number of bundles, using the `antigen-bundle` command can
look cumbersome. You can use the `antigen-bundles` command to *bulk* define
bundles instead of individual calls to `antigen-bundle`.
Usage is pretty straightforward. Just pipe the bundle specifications, just as
you would give to the `antigen-bundle` command, one per line, into the
`antigen-bundles` command. The easiest way to do this, is using the heredoc
syntax.
antigen-bundles <<EOF
# Guess what to install when running an unknown command.
command-not-found
# The heroku tool helper plugin.
heroku
EOF
This is equivalent to
antigen-bundle command-not-found
antigen-bundle heroku
Of course, as you can see, from the lines piped to `antigen-bundles`, empty
lines and those starting with a `#` are ignored. The rest are passed to
`antigen-bundle` without any quoting rules applied. They are actually `eval`-ed
with the `antigen-bundle` command. See the source if you want to really
understand how it works. Its a very small function.
|
|
ac6ddd7d4
|
233 |
### antigen-update |
|
5e26a8e26
|
234 |
|
|
7ba3548fd
|
235 236 |
This is something you might not want to put in your `.zshrc`. Instead, run it occasionally to update all your plugins. It doesn't take any arguments. |
|
5e26a8e26
|
237 |
|
|
2fe4683b3
|
238 |
antigen-update |
|
5e26a8e26
|
239 |
|
|
7ba3548fd
|
240 241 242 243 244 |
Please note that the updates that are downloaded are not immediately available. You have to open a new shell to be able to see the changes. This is a limitation by design since reloading all the plugins *might* have some nasty side effects that may not be immediately apparent. Let's just say it can make your shell act real quirky. |
|
b84833b4c
|
245 |
|
|
2fe4683b3
|
246 247 |
**Please note**: This command is not for updating *antigen* itself. Its for updating the bundles you are using with antigen. |
|
ac6ddd7d4
|
248 |
### antigen-list |
|
de2f0c562
|
249 |
|
|
7ba3548fd
|
250 251 |
Use this command to list out the currently *loaded* plugins. Keep in mind that this includes any bundles installed on-the-fly. |
|
de2f0c562
|
252 |
|
|
7ba3548fd
|
253 254 |
Takes no arguments. Gives out the repo url and the plugin's location under the repo. |
|
de2f0c562
|
255 |
|
|
ac6ddd7d4
|
256 |
### antigen-cleanup |
|
b84833b4c
|
257 |
|
|
7ba3548fd
|
258 259 260 |
Used to clean up the clones of repos which are not used by any plugins. It takes no arguments. When this is run, it lists out the repo-clones that are available but are not used by any plugin *currently loaded*. |
|
b84833b4c
|
261 262 263 |
This command currently cannot run in a non-interactive mode. So it won't be very pleasant to use it in your `.zshrc`. |
|
ac6ddd7d4
|
264 |
### antigen-lib |
|
b84833b4c
|
265 |
|
|
7ba3548fd
|
266 |
This is a shortcut to |
|
2fe4683b3
|
267 |
antigen-bundle --loc=lib |
|
7ba3548fd
|
268 269 270 271 |
So, it basically installs the oh-my-zsh's library as a bundle. Please note that this assumes that the `ANTIGEN_DEFAULT_REPO_URL` is set to the oh-my-zsh repo or a fork of that repo. If you want to specify the `url` too, then you can't use |
|
2fe4683b3
|
272 273 |
the `antigen-lib` short cut. You have to do that directly with the `antigen-bundle` command. |
|
7ba3548fd
|
274 275 276 277 278 |
This is present only for legacy reasons and *might* (or might not) be removed in the future. Use |
|
b84833b4c
|
279 |
|
|
2fe4683b3
|
280 |
antigen-lib |
|
b84833b4c
|
281 |
|
|
2fe4683b3
|
282 283 |
in your `.zshrc`, before any `antigen-bundle` declarations. It takes no arguments. |
|
b84833b4c
|
284 |
|
|
ac6ddd7d4
|
285 |
### antigen-theme |
|
b84833b4c
|
286 287 288 |
Used for switching the prompt theme. Invoke it with the name of the theme you want to use. |
|
2fe4683b3
|
289 |
antigen-theme fox |
|
b84833b4c
|
290 291 292 |
Currently, themes are pulled from robbyrussell's oh-my-zsh repo, but it will support getting themes from other repos as well in the future. |
|
7ba3548fd
|
293 294 |
You can use this command to change your theme on the fly in your shell. Go on, try out a few themes in your shell before you set it in your `.zshrc`. |
|
ac6ddd7d4
|
295 |
### antigen-apply |
|
1af74ea9e
|
296 297 298 299 300 301 302 303 304 305 306 307 |
You have to add this command after defining all bundles you need, in your zshrc. The completions defined by your bundles will be loaded at this step. It is possible to load completions as and when a bundle is specified with the bundle command, in which case this command would not be necessary. But loading the completions is a time-consuming process and your shell will start noticeably slow if you have a good number of bundle specifications. However, if you're a zsh expert and can suggest a way so that this would not be necessary, I am very interested in discussing it. Please open up an issue with your details. Thanks. |
|
ac6ddd7d4
|
308 |
## Configuration |
|
b84833b4c
|
309 310 |
The following environment variables can be set to customize the behavior of |
|
7ba3548fd
|
311 |
antigen. Make sure you set them *before* source-ing `antigen.zsh`. |
|
b84833b4c
|
312 313 314 315 |
`ANTIGEN_DEFAULT_REPO_URL` — This is the default repository url that is used for `bundle` commands. The default value is robbyrussell's oh-my-zsh repo, but you can set this to the fork url of your own fork. |
|
911cc8cb5
|
316 317 318 |
`ADOTDIR` — This directory is used to store all the repo clones, your bundles, themes, caches and everything else antigen requires to run smoothly. Defaults to `$HOME/.antigen`. |
|
b84833b4c
|
319 |
|
|
911cc8cb5
|
320 321 322 |
**Note**: `ANTIGEN_REPO_CACHE` & `ANTIGEN_BUNDLE_DIR` — These variables were used previously but are now removed. Please use `ADOTDIR` instead, as mentioned above. |
|
b84833b4c
|
323 |
|
|
ac6ddd7d4
|
324 |
## Notes on writing plugins |
|
b36de9bb3
|
325 326 |
> *TBD* |
|
ac6ddd7d4
|
327 |
## Meta |
|
b84833b4c
|
328 |
|
|
7ba3548fd
|
329 330 331 |
Project is licensed with the [MIT License][license]. To contribute, just fork, make changes and send a pull request. If its a rather long/complicated change, please consider opening an [issue][] first so we can discuss it out. |
|
b84833b4c
|
332 |
|
|
5c124ed5a
|
333 |
Any comments/suggestions/feedback welcome. Please join the discussion on the |
|
7ba3548fd
|
334 335 |
[reddit page][] of this project. Also, follow me on twitter, [@sharat87](twitter). |
|
5c124ed5a
|
336 |
|
|
b84833b4c
|
337 |
[Vundle]: https://github.com/gmarik/vundle |
|
b36de9bb3
|
338 339 |
[page on themes]: https://github.com/robbyrussell/oh-my-zsh/wiki/Themes [syntax highlighting plugin]: https://github.com/zsh-users/zsh-syntax-highlighting |
|
3e16c4709
|
340 |
[autoenv]: https://github.com/kennethreitz/autoenv |
|
b84833b4c
|
341 342 |
[oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh [issue]: https://github.com/sharat87/antigen/issues |
|
7ba3548fd
|
343 |
[license]: http://mit.sharats.me |
|
5c124ed5a
|
344 |
[reddit page]: http://www.reddit.com/r/commandline/comments/u4f26/antigen_a_plugin_manager_for_zsh_shell/ |
|
7ba3548fd
|
345 |
[twitter]: http://twitter.com/sharat87 |