README.mkd
9.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# 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.
# Quick Usage
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
The usage should be very familiar to you if you use Vundle. A typical `.zshrc`
might look like this
source /path-to-antigen-clone/antigen.zsh
# Load the oh-my-zsh's library.
bundle-lib
# Bundles from the default repo (robbyrussell's oh-my-zsh).
bundle git
bundle heroku
bundle pip
bundle lein
bundle command-not-found
# Syntax highlighting bundle.
bundle zsh-users/zsh-syntax-highlighting
# Load the theme.
bundle-theme robbyrussell
# Tell antigen that you're done.
bundle-apply
Open your zsh with this zshrc and run `bundle-install` and you should be ready
to roll. The complete syntax for the `bundle` command is discussed further down
on this page.
# Motivation
If you use zsh and [oh-my-zsh][], you know that having many different plugins
that are developed by many different authors in a single (sub)repo is not 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
admire robbyrussell's efforts for reviewing and mergine the gigantic number of
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.
# Commands
## bundle
This is the command you use to tell antigen that you want to use a plugin. The
simplest usage follows the following syntax
bundle <plugin-name>
This will add the `plugins/<name>` directory from [robbyrussell's
oh-my-zsh][oh-my-zsh] (can be changed by setting `ANTIGEN_DEFAULT_REPO_URL`).
However, the above is just syntax sugar for the real syntax of the `bundle`
command.
bundle [<url> [<loc> [<name>]]]
where `<url>` is the repository url and it defaults to [robbyrussell's
oh-my-zsh][oh-my-zsh] repo. `<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 too. `<loc>` defaults to `/`, which
indicates the repository itself is a plugin. `<name>` is the name with which
this plugin will be identified. This plugin will be installed in the bundles
directory with this name used as the directory name. If the `<name>` is not
given, antigen tries to make an intelligent guess based on the other given
arguments.
An example invocation would be
bundle https://github.com/robbyrussell/oh-my-zsh.git plugins/ant
This would install the ant plugin (with `<name>` as `ant`) from robbyrussell's
oh-my-zsh repo. Of course, github url's can be shortened.
bundle robbyrussell/oh-my-zsh plugins/ant
And since this is the default, even that isn't necessary. But we can't specify
the `loc` without giving the first argument.
For this and a few other reasons, `bundle` also supports a simple keyword
argument syntax, using which we can rewrite the above as
bundle --loc=plugins/ant
Which is the same as
bundle ant
(In the short syntax sugar introduced at the start of this section).
Note that you can mix and match positional and keyword arguments. But you can't
have positional arguments after starting keyword arguments.
bundle robbyrussell/oh-my-zsh --loc=plugins/ant
And keyword arguments don't care about the order in which the arguments are
specified. The following is perfectly valid.
bundle --loc=plugins/ant --url=robbyrussell/oh-my-zsh --name=ant
In addition to the above discussed arguments, `bundle` also takes the following
arguments but only as keyword arguments.
`load` — Set to `true` (default) or `false`. If this is set to `false`,
the plugin specified is only recorded, may be for future use. It is not loaded
into the environment. But with `true`, the plugin is immediately sourced and
is ready to use, which is the default behavior.
## bundle-install
This is something you might not want to put in your `.zshrc`. Instead, run it to
install all the recorded bundles, using the `bundle` command. It has the
following syntax.
bundle-install [--update] [<plugin-spec>]
The optional `--update` argument can be given to update all your plugins from
the server. By default, `bundle-install` does *not* check for updates on the
plugins. It just installs them, if there is a cached copy available and if its
not already installed.
The other argument part illustrated above is the `<plugin-spec>`. Other than the
optional `--update` argument, everything else is considered as describing a
particular plugin to be installed. So, a command like
bundle-install <plugin-spec>
is **almost** equivalent to
bundle <plugin-spec>
bundle-install
I say **almost** because in the former, *only* the said plugin is installed and
is usable immediately. This kind of invocation is supposed to be used directly
from the shell, not added to your `.zshrc`. The idea is to let you try out new
plugins you come across. For example,
bundle-install lol
After that, you have the `lol` plugin ready to be used right there. You can try
it out and if you like it, you can add the following to load it in every new
shell instance you open
bundle lol
If you don't want it, the plugin will still stay installed, but won't be used.
No harm done, but you can run `bundle-cleanup` to clean up such stray plugins
that you don't use. Documentation for that command further down.
**Note** that the `<plugin-spec>` can be made of multiple number of arguments,
just like the `bundle` command can take multiple number of arguments to
correctly describe the plugin.
## bundle-install!
This is the same as running
bundle-install --update
That is, it installs the recorded plugins, and updates them to the latest
available versions.
## bundle-cleanup
Used to clean up unused bundles. It takes no arguments. When this is run, it
lists out the plugins that are installed but are not recorded with a `bundle`
command, and will ask you if you want to delete them.
This command currently cannot run in a non-interactive mode. So it won't be very
pleasant to use it in your `.zshrc`.
## bundle-lib
This currently exists only to make is possible to use oh-my-zsh's library, since
its organisation is different from that of plugins. If you want to load
oh-my-zsh's library, which you very likely do, put a
bundle-lib
in your `.zshrc`, before any `bundle` declarations. It takes no arguments.
## bundle-theme
Used for switching the prompt theme. Invoke it with the name of the theme you
want to use.
bundle-theme fox
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.
## bundle-apply
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.
# Configuration
The following environment variables can be set to customize the behavior of
antigen. Make sure you set them *before* sourceing `antigen.zsh`.
`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.
`ANTIGEN_REPO_CACHE` — This is where the cloned repositories are cached.
Defaults to `$HOME/.antigen/cache`
`ANTIGEN_BUNDLE_DIR` — This is where the plugins are installed and sourced
from. Defaults to `$HOME/.antigen/bundles`
# Meta
Please note that I built this over night and should be considered very alpha.
However, I am using it full time now on my work machine.
Project is licensed with the MIT 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.
Any comments/suggestions/feedback welcome. Please join the discussion on the
[reddit page][] of this project.
[Vundle]: https://github.com/gmarik/vundle
[oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh
[issue]: https://github.com/sharat87/antigen/issues
[reddit page]: http://www.reddit.com/r/commandline/comments/u4f26/antigen_a_plugin_manager_for_zsh_shell/