Blame view

README.mkd 9.4 KB
b84833b4c   Shrikant Sharat   Add readme.
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.
e1bf049d8   Shrikant Sharat   Add alpha notice ...
6
7
8
9
  **Please** note that antigen is currently is alpha stage and will have backwards
  incompatible changes now and then, until we have a pretty stable system we can
  reason about. **Please** read the commit comments of the changesets when you
  pull a new version of antigen.
b84833b4c   Shrikant Sharat   Add readme.
10
  # Quick Usage
3c698aac0   Shrikant Sharat   Add information o...
11
12
13
14
  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   Shrikant Sharat   Add readme.
15
16
  The usage should be very familiar to you if you use Vundle. A typical `.zshrc`
  might look like this
3c698aac0   Shrikant Sharat   Add information o...
17
      source /path-to-antigen-clone/antigen.zsh
b84833b4c   Shrikant Sharat   Add readme.
18
19
20
21
22
  
      # Load the oh-my-zsh's library.
      bundle-lib
  
      # Bundles from the default repo (robbyrussell's oh-my-zsh).
7e0aca7ce   Shrikant Sharat   Add notes about b...
23
24
25
26
27
      bundle git
      bundle heroku
      bundle pip
      bundle lein
      bundle command-not-found
b84833b4c   Shrikant Sharat   Add readme.
28
29
30
31
32
33
  
      # Syntax highlighting bundle.
      bundle zsh-users/zsh-syntax-highlighting
  
      # Load the theme.
      bundle-theme robbyrussell
1af74ea9e   Shrikant Sharat   Load completions ...
34
35
      # Tell antigen that you're done.
      bundle-apply
7ba3548fd   Shrikant Sharat   Updated README wi...
36
37
38
  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
  syntax for the `bundle` command is discussed further down on this page.
b84833b4c   Shrikant Sharat   Add readme.
39
40
41
42
43
44
45
  
  # 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
7ba3548fd   Shrikant Sharat   Updated README wi...
46
  admire robbyrussell's efforts for reviewing and merging the gigantic number of
b84833b4c   Shrikant Sharat   Add readme.
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
  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
7ba3548fd   Shrikant Sharat   Updated README wi...
72
73
  This command tells antigen to install (if not already installed) and load the
  given plugin. The simplest usage follows the following syntax.
b84833b4c   Shrikant Sharat   Add readme.
74

7e0aca7ce   Shrikant Sharat   Add notes about b...
75
      bundle <plugin-name>
7ba3548fd   Shrikant Sharat   Updated README wi...
76
  This will install the `plugins/<name>` directory from [robbyrussell's
7e0aca7ce   Shrikant Sharat   Add notes about b...
77
  oh-my-zsh][oh-my-zsh] (can be changed by setting `ANTIGEN_DEFAULT_REPO_URL`).
7ba3548fd   Shrikant Sharat   Updated README wi...
78
  However, the above is just syntax sugar for the extended syntax of the `bundle`
7e0aca7ce   Shrikant Sharat   Add notes about b...
79
  command.
7ba3548fd   Shrikant Sharat   Updated README wi...
80
      bundle [<url> [<loc>]]
b84833b4c   Shrikant Sharat   Add readme.
81
82
  
  where `<url>` is the repository url and it defaults to [robbyrussell's
7ba3548fd   Shrikant Sharat   Updated README wi...
83
84
85
86
87
  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   Shrikant Sharat   Add readme.
88
89
  
  An example invocation would be
7ba3548fd   Shrikant Sharat   Updated README wi...
90
91
      # The following is the same as `bundle ant`. But for demonstration purposes,
      # we use the extended syntax here.
b84833b4c   Shrikant Sharat   Add readme.
92
      bundle https://github.com/robbyrussell/oh-my-zsh.git plugins/ant
7ba3548fd   Shrikant Sharat   Updated README wi...
93
94
  This would install the ant plugin from robbyrussell's oh-my-zsh repo. Of course,
  github url's can be shortened.
b84833b4c   Shrikant Sharat   Add readme.
95
96
  
      bundle robbyrussell/oh-my-zsh plugins/ant
7ba3548fd   Shrikant Sharat   Updated README wi...
97
98
  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   Shrikant Sharat   Add readme.
99
100
101
102
103
  
  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
7ba3548fd   Shrikant Sharat   Updated README wi...
104
105
  Which picks up the default for the `url` argument, and uses the `loc` given to
  it.
7e0aca7ce   Shrikant Sharat   Add notes about b...
106

7ba3548fd   Shrikant Sharat   Updated README wi...
107
108
  *Note* that you can mix and match positional and keyword arguments. But you
  can't have positional arguments after keyword arguments.
b84833b4c   Shrikant Sharat   Add readme.
109
110
111
112
113
  
      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.
7ba3548fd   Shrikant Sharat   Updated README wi...
114
      bundle --loc=plugins/ant --url=robbyrussell/oh-my-zsh
5e26a8e26   Shrikant Sharat   Docs on using inl...
115

7ba3548fd   Shrikant Sharat   Updated README wi...
116
117
118
119
  In addition to the above discussed arguments, `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   Shrikant Sharat   Docs on using inl...
120

7ba3548fd   Shrikant Sharat   Updated README wi...
121
122
123
124
  You can use this `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   Shrikant Sharat   Docs on using inl...
125

7ba3548fd   Shrikant Sharat   Updated README wi...
126
  ## bundle-update
5e26a8e26   Shrikant Sharat   Docs on using inl...
127

7ba3548fd   Shrikant Sharat   Updated README wi...
128
129
  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   Shrikant Sharat   Docs on using inl...
130

7ba3548fd   Shrikant Sharat   Updated README wi...
131
      bundle-update
5e26a8e26   Shrikant Sharat   Docs on using inl...
132

7ba3548fd   Shrikant Sharat   Updated README wi...
133
134
135
136
137
  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   Shrikant Sharat   Add readme.
138

de2f0c562   Shrikant Sharat   Add a note in REA...
139
  ## bundle-list
7ba3548fd   Shrikant Sharat   Updated README wi...
140
141
  Use this command to list out the currently *loaded* plugins. Keep in mind that
  this includes any bundles installed on-the-fly.
de2f0c562   Shrikant Sharat   Add a note in REA...
142

7ba3548fd   Shrikant Sharat   Updated README wi...
143
144
  Takes no arguments. Gives out the repo url and the plugin's location under the
  repo.
de2f0c562   Shrikant Sharat   Add a note in REA...
145

b84833b4c   Shrikant Sharat   Add readme.
146
  ## bundle-cleanup
7ba3548fd   Shrikant Sharat   Updated README wi...
147
148
149
  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   Shrikant Sharat   Add readme.
150
151
152
153
154
  
  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
7ba3548fd   Shrikant Sharat   Updated README wi...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
  This is a shortcut to
  
      bundle --loc=lib
  
  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
  the `bundle-lib` short cut. You have to do that directly with the `bundle`
  command.
  
  This is present only for legacy reasons and *might* (or might not) be removed in
  the future.
  
  Use
b84833b4c   Shrikant Sharat   Add readme.
169
170
171
172
173
174
175
176
177
178
179
180
181
182
  
      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.
7ba3548fd   Shrikant Sharat   Updated README wi...
183
184
  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`.
1af74ea9e   Shrikant Sharat   Load completions ...
185
186
187
188
189
190
191
192
193
194
195
196
197
  ## 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.
b84833b4c   Shrikant Sharat   Add readme.
198
199
200
  # Configuration
  
  The following environment variables can be set to customize the behavior of
7ba3548fd   Shrikant Sharat   Updated README wi...
201
  antigen. Make sure you set them *before* source-ing `antigen.zsh`.
b84833b4c   Shrikant Sharat   Add readme.
202
203
204
205
  
  `ANTIGEN_DEFAULT_REPO_URL` &mdash; 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   Shrikant Sharat   Use ADOTDIR as th...
206
207
208
  `ADOTDIR` &mdash; 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   Shrikant Sharat   Add readme.
209

911cc8cb5   Shrikant Sharat   Use ADOTDIR as th...
210
211
212
  **Note**: `ANTIGEN_REPO_CACHE` & `ANTIGEN_BUNDLE_DIR` &mdash; These variables
  were used previously but are now removed. Please use `ADOTDIR` instead, as
  mentioned above.
b84833b4c   Shrikant Sharat   Add readme.
213
214
  
  # Meta
7ba3548fd   Shrikant Sharat   Updated README wi...
215
216
217
  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   Shrikant Sharat   Add readme.
218

5c124ed5a   Shrikant Sharat   Add link to proje...
219
  Any comments/suggestions/feedback welcome. Please join the discussion on the
7ba3548fd   Shrikant Sharat   Updated README wi...
220
221
  [reddit page][] of this project. Also, follow me on twitter,
  [@sharat87](twitter).
5c124ed5a   Shrikant Sharat   Add link to proje...
222

b84833b4c   Shrikant Sharat   Add readme.
223
224
225
  [Vundle]: https://github.com/gmarik/vundle
  [oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh
  [issue]: https://github.com/sharat87/antigen/issues
7ba3548fd   Shrikant Sharat   Updated README wi...
226
  [license]: http://mit.sharats.me
5c124ed5a   Shrikant Sharat   Add link to proje...
227
  [reddit page]: http://www.reddit.com/r/commandline/comments/u4f26/antigen_a_plugin_manager_for_zsh_shell/
7ba3548fd   Shrikant Sharat   Updated README wi...
228
  [twitter]: http://twitter.com/sharat87