Commit ec9febf8cfe63dca6f0e6f309e0a8a07a950e43e
1 parent
38b0b0409e
Fix themes not being loaded.
The `-`'s were being replaced to `_`'s even in the value of the given argument, whereas the intention was to just replace them in the name of the argument. This is now fixed.
Showing 1 changed file with 6 additions and 3 deletions Inline Diff
antigen.zsh
1 | #!/bin/zsh | 1 | #!/bin/zsh |
2 | 2 | ||
3 | # Each line in this string has the following entries separated by a space | 3 | # Each line in this string has the following entries separated by a space |
4 | # character. | 4 | # character. |
5 | # <repo-url>, <plugin-location>, <bundle-type> | 5 | # <repo-url>, <plugin-location>, <bundle-type> |
6 | # FIXME: Is not kept local by zsh! | 6 | # FIXME: Is not kept local by zsh! |
7 | local _ANTIGEN_BUNDLE_RECORD="" | 7 | local _ANTIGEN_BUNDLE_RECORD="" |
8 | 8 | ||
9 | # Syntaxes | 9 | # Syntaxes |
10 | # antigen-bundle <url> [<loc>=/] | 10 | # antigen-bundle <url> [<loc>=/] |
11 | # Keyword only arguments: | 11 | # Keyword only arguments: |
12 | # branch - The branch of the repo to use for this bundle. | 12 | # branch - The branch of the repo to use for this bundle. |
13 | antigen-bundle () { | 13 | antigen-bundle () { |
14 | 14 | ||
15 | # Bundle spec arguments' default values. | 15 | # Bundle spec arguments' default values. |
16 | local url="$ANTIGEN_DEFAULT_REPO_URL" | 16 | local url="$ANTIGEN_DEFAULT_REPO_URL" |
17 | local loc=/ | 17 | local loc=/ |
18 | local branch= | 18 | local branch= |
19 | local no_local_clone=false | 19 | local no_local_clone=false |
20 | local btype=plugin | 20 | local btype=plugin |
21 | 21 | ||
22 | # Set spec values based on the positional arguments. | 22 | # Set spec values based on the positional arguments. |
23 | local position_args | 23 | local position_args |
24 | position_args=(url loc) | 24 | position_args=(url loc) |
25 | local i=1 | 25 | local i=1 |
26 | while ! [[ -z $1 || $1 == --*=* ]]; do | 26 | while ! [[ -z $1 || $1 == --*=* ]]; do |
27 | local arg_name="${position_args[$i]}" | 27 | local arg_name="${position_args[$i]}" |
28 | local arg_value="$1" | 28 | local arg_value="$1" |
29 | eval "local $arg_name='$arg_value'" | 29 | eval "local $arg_name='$arg_value'" |
30 | shift | 30 | shift |
31 | i=$(($i + 1)) | 31 | i=$(($i + 1)) |
32 | done | 32 | done |
33 | 33 | ||
34 | # Set spec values from keyword arguments, if any. The remaining arguments | 34 | # Set spec values from keyword arguments, if any. The remaining arguments |
35 | # are all assumed to be keyword arguments. | 35 | # are all assumed to be keyword arguments. |
36 | while [[ $1 == --* ]]; do | 36 | while [[ $1 == --* ]]; do |
37 | # Remove the `--` at the start and replace the rest of `-`'s to `_`'s. | 37 | # Remove the `--` at the start. |
38 | local arg="${${1#--}//-/_}" | 38 | local arg="${1#--}" |
39 | 39 | ||
40 | if [[ $arg != *=* ]]; then | 40 | if [[ $arg != *=* ]]; then |
41 | arg="$arg=true" | 41 | arg="$arg=true" |
42 | fi | 42 | fi |
43 | 43 | ||
44 | local arg_name="${arg%\=*}" | 44 | # Get the name of the arg and replace the `-`'s to `_`'s. |
45 | local arg_name="${${arg%\=*}//-/_}" | ||
46 | |||
47 | # Get the value of the arg. | ||
45 | local arg_value="${arg#*\=}" | 48 | local arg_value="${arg#*\=}" |
46 | 49 | ||
47 | eval "local $arg_name='$arg_value'" | 50 | eval "local $arg_name='$arg_value'" |
48 | shift | 51 | shift |
49 | done | 52 | done |
50 | 53 | ||
51 | # Check if url is just the plugin name. Super short syntax. | 54 | # Check if url is just the plugin name. Super short syntax. |
52 | if [[ "$url" != */* ]]; then | 55 | if [[ "$url" != */* ]]; then |
53 | loc="plugins/$url" | 56 | loc="plugins/$url" |
54 | url="$ANTIGEN_DEFAULT_REPO_URL" | 57 | url="$ANTIGEN_DEFAULT_REPO_URL" |
55 | fi | 58 | fi |
56 | 59 | ||
57 | # Resolve the url. | 60 | # Resolve the url. |
58 | url="$(-antigen-resolve-bundle-url "$url")" | 61 | url="$(-antigen-resolve-bundle-url "$url")" |
59 | 62 | ||
60 | # Add the branch information to the url. | 63 | # Add the branch information to the url. |
61 | if [[ ! -z $branch ]]; then | 64 | if [[ ! -z $branch ]]; then |
62 | url="$url|$branch" | 65 | url="$url|$branch" |
63 | fi | 66 | fi |
64 | 67 | ||
65 | # Add it to the record. | 68 | # Add it to the record. |
66 | _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype $no_local_clone" | 69 | _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype $no_local_clone" |
67 | 70 | ||
68 | # Ensure a clone exists for this repo, if needed. | 71 | # Ensure a clone exists for this repo, if needed. |
69 | if ! [[ $url == /* && $no_local_clone == true ]]; then | 72 | if ! [[ $url == /* && $no_local_clone == true ]]; then |
70 | -antigen-ensure-repo "$url" | 73 | -antigen-ensure-repo "$url" |
71 | fi | 74 | fi |
72 | 75 | ||
73 | # Load the plugin. | 76 | # Load the plugin. |
74 | -antigen-load "$url" "$loc" "$btype" "$no_local_clone" | 77 | -antigen-load "$url" "$loc" "$btype" "$no_local_clone" |
75 | 78 | ||
76 | } | 79 | } |
77 | 80 | ||
78 | -antigen-resolve-bundle-url () { | 81 | -antigen-resolve-bundle-url () { |
79 | # Given an acceptable short/full form of a bundle's repo url, this function | 82 | # Given an acceptable short/full form of a bundle's repo url, this function |
80 | # echoes the full form of the repo's clone url. | 83 | # echoes the full form of the repo's clone url. |
81 | 84 | ||
82 | local url="$1" | 85 | local url="$1" |
83 | 86 | ||
84 | # Expand short github url syntax: `username/reponame` | 87 | # Expand short github url syntax: `username/reponame` |
85 | if [[ $url != git://* && \ | 88 | if [[ $url != git://* && \ |
86 | $url != https://* && \ | 89 | $url != https://* && \ |
87 | $url != /* && \ | 90 | $url != /* && \ |
88 | $url != git@github.com:*/* | 91 | $url != git@github.com:*/* |
89 | ]]; then | 92 | ]]; then |
90 | url="https://github.com/${url%.git}.git" | 93 | url="https://github.com/${url%.git}.git" |
91 | fi | 94 | fi |
92 | 95 | ||
93 | echo "$url" | 96 | echo "$url" |
94 | } | 97 | } |
95 | 98 | ||
96 | antigen-bundles () { | 99 | antigen-bundles () { |
97 | # Bulk add many bundles at one go. Empty lines and lines starting with a `#` | 100 | # Bulk add many bundles at one go. Empty lines and lines starting with a `#` |
98 | # are ignored. Everything else is given to `antigen-bundle` as is, no | 101 | # are ignored. Everything else is given to `antigen-bundle` as is, no |
99 | # quoting rules applied. | 102 | # quoting rules applied. |
100 | 103 | ||
101 | local line | 104 | local line |
102 | 105 | ||
103 | grep -v '^\s*$\|^#' | while read line; do | 106 | grep -v '^\s*$\|^#' | while read line; do |
104 | # Using `eval` so that we can use the shell-style quoting in each line | 107 | # Using `eval` so that we can use the shell-style quoting in each line |
105 | # piped to `antigen-bundles`. | 108 | # piped to `antigen-bundles`. |
106 | eval "antigen-bundle $line" | 109 | eval "antigen-bundle $line" |
107 | done | 110 | done |
108 | } | 111 | } |
109 | 112 | ||
110 | antigen-update () { | 113 | antigen-update () { |
111 | # Update your bundles, i.e., `git pull` in all the plugin repos. | 114 | # Update your bundles, i.e., `git pull` in all the plugin repos. |
112 | -antigen-echo-record \ | 115 | -antigen-echo-record \ |
113 | | awk '{print $1}' \ | 116 | | awk '{print $1}' \ |
114 | | sort -u \ | 117 | | sort -u \ |
115 | | while read url; do | 118 | | while read url; do |
116 | echo "**** Pulling $url" | 119 | echo "**** Pulling $url" |
117 | -antigen-ensure-repo --update --verbose "$url" | 120 | -antigen-ensure-repo --update --verbose "$url" |
118 | echo | 121 | echo |
119 | done | 122 | done |
120 | } | 123 | } |
121 | 124 | ||
122 | -antigen-get-clone-dir () { | 125 | -antigen-get-clone-dir () { |
123 | # Takes a repo url and gives out the path that this url needs to be cloned | 126 | # Takes a repo url and gives out the path that this url needs to be cloned |
124 | # to. Doesn't actually clone anything. | 127 | # to. Doesn't actually clone anything. |
125 | # TODO: Memoize? | 128 | # TODO: Memoize? |
126 | 129 | ||
127 | # The url given. | 130 | # The url given. |
128 | local url="$1" | 131 | local url="$1" |
129 | 132 | ||
130 | # Echo the full path to the clone directory. | 133 | # Echo the full path to the clone directory. |
131 | echo -n $ADOTDIR/repos/ | 134 | echo -n $ADOTDIR/repos/ |
132 | echo "$url" | sed \ | 135 | echo "$url" | sed \ |
133 | -e 's./.-SLASH-.g' \ | 136 | -e 's./.-SLASH-.g' \ |
134 | -e 's.:.-COLON-.g' \ | 137 | -e 's.:.-COLON-.g' \ |
135 | -e 's.|.-PIPE-.g' | 138 | -e 's.|.-PIPE-.g' |
136 | } | 139 | } |
137 | 140 | ||
138 | -antigen-get-clone-url () { | 141 | -antigen-get-clone-url () { |
139 | # Takes a repo's clone dir and gives out the repo's original url that was | 142 | # Takes a repo's clone dir and gives out the repo's original url that was |
140 | # used to create the given directory path. | 143 | # used to create the given directory path. |
141 | # TODO: Memoize? | 144 | # TODO: Memoize? |
142 | echo "$1" | sed \ | 145 | echo "$1" | sed \ |
143 | -e "s:^$ADOTDIR/repos/::" \ | 146 | -e "s:^$ADOTDIR/repos/::" \ |
144 | -e 's.-SLASH-./.g' \ | 147 | -e 's.-SLASH-./.g' \ |
145 | -e 's.-COLON-.:.g' \ | 148 | -e 's.-COLON-.:.g' \ |
146 | -e 's.-PIPE-.|.g' | 149 | -e 's.-PIPE-.|.g' |
147 | } | 150 | } |
148 | 151 | ||
149 | -antigen-ensure-repo () { | 152 | -antigen-ensure-repo () { |
150 | 153 | ||
151 | # Ensure that a clone exists for the given repo url and branch. If the first | 154 | # Ensure that a clone exists for the given repo url and branch. If the first |
152 | # argument is `--update` and if a clone already exists for the given repo | 155 | # argument is `--update` and if a clone already exists for the given repo |
153 | # and branch, it is pull-ed, i.e., updated. | 156 | # and branch, it is pull-ed, i.e., updated. |
154 | 157 | ||
155 | # Argument defaults. | 158 | # Argument defaults. |
156 | # Check if we have to update. | 159 | # Check if we have to update. |
157 | local update=false | 160 | local update=false |
158 | # Verbose output. | 161 | # Verbose output. |
159 | local verbose=false | 162 | local verbose=false |
160 | 163 | ||
161 | # Load any boolean arguments specified. | 164 | # Load any boolean arguments specified. |
162 | while [[ $1 == --* ]]; do | 165 | while [[ $1 == --* ]]; do |
163 | eval "local '${1#--}=true'" | 166 | eval "local '${1#--}=true'" |
164 | shift | 167 | shift |
165 | done | 168 | done |
166 | 169 | ||
167 | # Get the clone's directory as per the given repo url and branch. | 170 | # Get the clone's directory as per the given repo url and branch. |
168 | local url="$1" | 171 | local url="$1" |
169 | local clone_dir="$(-antigen-get-clone-dir $url)" | 172 | local clone_dir="$(-antigen-get-clone-dir $url)" |
170 | 173 | ||
171 | # Clone if it doesn't already exist. | 174 | # Clone if it doesn't already exist. |
172 | if [[ ! -d $clone_dir ]]; then | 175 | if [[ ! -d $clone_dir ]]; then |
173 | git clone "${url%|*}" "$clone_dir" | 176 | git clone "${url%|*}" "$clone_dir" |
174 | elif $update; then | 177 | elif $update; then |
175 | # Save current revision. | 178 | # Save current revision. |
176 | old_rev="$(git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ | 179 | old_rev="$(git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ |
177 | rev-parse HEAD)" | 180 | rev-parse HEAD)" |
178 | # Pull changes if update requested. | 181 | # Pull changes if update requested. |
179 | git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ | 182 | git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ |
180 | pull | 183 | pull |
181 | # Get the new revision. | 184 | # Get the new revision. |
182 | new_rev="$(git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ | 185 | new_rev="$(git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ |
183 | rev-parse HEAD)" | 186 | rev-parse HEAD)" |
184 | fi | 187 | fi |
185 | 188 | ||
186 | # If its a specific branch that we want, checkout that branch. | 189 | # If its a specific branch that we want, checkout that branch. |
187 | if [[ $url == *\|* ]]; then | 190 | if [[ $url == *\|* ]]; then |
188 | git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ | 191 | git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ |
189 | checkout "${url#*|}" | 192 | checkout "${url#*|}" |
190 | fi | 193 | fi |
191 | 194 | ||
192 | if ! [[ -z $old_rev || $old_rev == $new_rev ]]; then | 195 | if ! [[ -z $old_rev || $old_rev == $new_rev ]]; then |
193 | echo Updated from ${old_rev:0:7} to ${new_rev:0:7}. | 196 | echo Updated from ${old_rev:0:7} to ${new_rev:0:7}. |
194 | if $verbose; then | 197 | if $verbose; then |
195 | git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ | 198 | git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \ |
196 | log --oneline --reverse --no-merges --stat '@{1}..' | 199 | log --oneline --reverse --no-merges --stat '@{1}..' |
197 | fi | 200 | fi |
198 | fi | 201 | fi |
199 | 202 | ||
200 | } | 203 | } |
201 | 204 | ||
202 | -antigen-load () { | 205 | -antigen-load () { |
203 | 206 | ||
204 | local url="$1" | 207 | local url="$1" |
205 | local loc="$2" | 208 | local loc="$2" |
206 | local btype="$3" | 209 | local btype="$3" |
207 | local no_local_clone="$4" | 210 | local no_local_clone="$4" |
208 | 211 | ||
209 | # The full location where the plugin is located. | 212 | # The full location where the plugin is located. |
210 | local location | 213 | local location |
211 | if ! [[ $url == /* && $no_local_clone == true ]]; then | 214 | if ! [[ $url == /* && $no_local_clone == true ]]; then |
212 | location="$(-antigen-get-clone-dir "$url")/$loc" | 215 | location="$(-antigen-get-clone-dir "$url")/$loc" |
213 | else | 216 | else |
214 | location="$url" | 217 | location="$url" |
215 | fi | 218 | fi |
216 | 219 | ||
217 | if [[ $btype == theme ]]; then | 220 | if [[ $btype == theme ]]; then |
218 | 221 | ||
219 | # Of course, if its a theme, the location would point to the script | 222 | # Of course, if its a theme, the location would point to the script |
220 | # file. | 223 | # file. |
221 | source "$location" | 224 | source "$location" |
222 | 225 | ||
223 | else | 226 | else |
224 | 227 | ||
225 | # Source the plugin script | 228 | # Source the plugin script |
226 | # FIXME: I don't know. Looks very very ugly. Needs a better | 229 | # FIXME: I don't know. Looks very very ugly. Needs a better |
227 | # implementation once tests are ready. | 230 | # implementation once tests are ready. |
228 | local script_loc="$(ls "$location" | grep -m1 '\.plugin\.zsh$')" | 231 | local script_loc="$(ls "$location" | grep -m1 '\.plugin\.zsh$')" |
229 | 232 | ||
230 | if [[ -f $script_loc ]]; then | 233 | if [[ -f $script_loc ]]; then |
231 | # If we have a `*.plugin.zsh`, source it. | 234 | # If we have a `*.plugin.zsh`, source it. |
232 | source "$script_loc" | 235 | source "$script_loc" |
233 | 236 | ||
234 | elif [[ ! -z "$(ls "$location" | grep -m1 '\.zsh$')" ]]; then | 237 | elif [[ ! -z "$(ls "$location" | grep -m1 '\.zsh$')" ]]; then |
235 | # If there is no `*.plugin.zsh` file, source *all* the `*.zsh` | 238 | # If there is no `*.plugin.zsh` file, source *all* the `*.zsh` |
236 | # files. | 239 | # files. |
237 | for script ($location/*.zsh(N)) source "$script" | 240 | for script ($location/*.zsh(N)) source "$script" |
238 | 241 | ||
239 | elif [[ ! -z "$(ls "$location" | grep -m1 '\.sh$')" ]]; then | 242 | elif [[ ! -z "$(ls "$location" | grep -m1 '\.sh$')" ]]; then |
240 | # If there are no `*.zsh` files either, we look for and source any | 243 | # If there are no `*.zsh` files either, we look for and source any |
241 | # `*.sh` files instead. | 244 | # `*.sh` files instead. |
242 | for script ($location/*.sh(N)) source "$script" | 245 | for script ($location/*.sh(N)) source "$script" |
243 | 246 | ||
244 | fi | 247 | fi |
245 | 248 | ||
246 | # Add to $fpath, for completion(s). | 249 | # Add to $fpath, for completion(s). |
247 | fpath=($location $fpath) | 250 | fpath=($location $fpath) |
248 | 251 | ||
249 | fi | 252 | fi |
250 | 253 | ||
251 | } | 254 | } |
252 | 255 | ||
253 | antigen-cleanup () { | 256 | antigen-cleanup () { |
254 | 257 | ||
255 | # Cleanup unused repositories. | 258 | # Cleanup unused repositories. |
256 | 259 | ||
257 | local force=false | 260 | local force=false |
258 | if [[ $1 == --force ]]; then | 261 | if [[ $1 == --force ]]; then |
259 | force=true | 262 | force=true |
260 | fi | 263 | fi |
261 | 264 | ||
262 | if [[ ! -d "$ADOTDIR/repos" || -z "$(ls "$ADOTDIR/repos/")" ]]; then | 265 | if [[ ! -d "$ADOTDIR/repos" || -z "$(ls "$ADOTDIR/repos/")" ]]; then |
263 | echo "You don't have any bundles." | 266 | echo "You don't have any bundles." |
264 | return 0 | 267 | return 0 |
265 | fi | 268 | fi |
266 | 269 | ||
267 | # Find directores in ADOTDIR/repos, that are not in the bundles record. | 270 | # Find directores in ADOTDIR/repos, that are not in the bundles record. |
268 | local unused_clones="$(comm -13 \ | 271 | local unused_clones="$(comm -13 \ |
269 | <(-antigen-echo-record \ | 272 | <(-antigen-echo-record \ |
270 | | awk '{print $1}' \ | 273 | | awk '{print $1}' \ |
271 | | while read line; do | 274 | | while read line; do |
272 | -antigen-get-clone-dir "$line" | 275 | -antigen-get-clone-dir "$line" |
273 | done \ | 276 | done \ |
274 | | sort -u) \ | 277 | | sort -u) \ |
275 | <(ls -d "$ADOTDIR/repos/"* | sort -u))" | 278 | <(ls -d "$ADOTDIR/repos/"* | sort -u))" |
276 | 279 | ||
277 | if [[ -z $unused_clones ]]; then | 280 | if [[ -z $unused_clones ]]; then |
278 | echo "You don't have any unidentified bundles." | 281 | echo "You don't have any unidentified bundles." |
279 | return 0 | 282 | return 0 |
280 | fi | 283 | fi |
281 | 284 | ||
282 | echo 'You have clones for the following repos, but are not used.' | 285 | echo 'You have clones for the following repos, but are not used.' |
283 | echo "$unused_clones" \ | 286 | echo "$unused_clones" \ |
284 | | while read line; do | 287 | | while read line; do |
285 | -antigen-get-clone-url "$line" | 288 | -antigen-get-clone-url "$line" |
286 | done \ | 289 | done \ |
287 | | sed -e 's/^/ /' -e 's/|/, branch /' | 290 | | sed -e 's/^/ /' -e 's/|/, branch /' |
288 | 291 | ||
289 | if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then | 292 | if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then |
290 | echo | 293 | echo |
291 | echo | 294 | echo |
292 | echo "$unused_clones" | while read line; do | 295 | echo "$unused_clones" | while read line; do |
293 | echo -n "Deleting clone for $(-antigen-get-clone-url "$line")..." | 296 | echo -n "Deleting clone for $(-antigen-get-clone-url "$line")..." |
294 | rm -rf "$line" | 297 | rm -rf "$line" |
295 | echo ' done.' | 298 | echo ' done.' |
296 | done | 299 | done |
297 | else | 300 | else |
298 | echo | 301 | echo |
299 | echo Nothing deleted. | 302 | echo Nothing deleted. |
300 | fi | 303 | fi |
301 | } | 304 | } |
302 | 305 | ||
303 | antigen-lib () { | 306 | antigen-lib () { |
304 | antigen-bundle --loc=lib | 307 | antigen-bundle --loc=lib |
305 | } | 308 | } |
306 | 309 | ||
307 | antigen-theme () { | 310 | antigen-theme () { |
308 | local name="${1:-robbyrussell}" | 311 | local name="${1:-robbyrussell}" |
309 | antigen-bundle --loc=themes/$name.zsh-theme --btype=theme | 312 | antigen-bundle --loc=themes/$name.zsh-theme --btype=theme |
310 | } | 313 | } |
311 | 314 | ||
312 | antigen-apply () { | 315 | antigen-apply () { |
313 | # Initialize completion. | 316 | # Initialize completion. |
314 | # TODO: Only load completions if there are any changes to the bundle | 317 | # TODO: Only load completions if there are any changes to the bundle |
315 | # repositories. | 318 | # repositories. |
316 | compinit -i | 319 | compinit -i |
317 | } | 320 | } |
318 | 321 | ||
319 | antigen-list () { | 322 | antigen-list () { |
320 | # List all currently installed bundles | 323 | # List all currently installed bundles |
321 | if [[ -z "$_ANTIGEN_BUNDLE_RECORD" ]]; then | 324 | if [[ -z "$_ANTIGEN_BUNDLE_RECORD" ]]; then |
322 | echo "You don't have any bundles." >&2 | 325 | echo "You don't have any bundles." >&2 |
323 | return 1 | 326 | return 1 |
324 | else | 327 | else |
325 | -antigen-echo-record | sort -u | 328 | -antigen-echo-record | sort -u |
326 | fi | 329 | fi |
327 | } | 330 | } |
328 | 331 | ||
329 | antigen-help () { | 332 | antigen-help () { |
330 | cat <<EOF | 333 | cat <<EOF |
331 | Antigen is a plugin management system for zsh. It makes it easy to grab awesome | 334 | Antigen is a plugin management system for zsh. It makes it easy to grab awesome |
332 | shell scripts and utilities, put up on github. For further details and complete | 335 | shell scripts and utilities, put up on github. For further details and complete |
333 | documentation, visit the project's page at 'http://antigen.sharats.me'. | 336 | documentation, visit the project's page at 'http://antigen.sharats.me'. |
334 | EOF | 337 | EOF |
335 | } | 338 | } |
336 | 339 | ||
337 | # A syntax sugar to avoid the `-` when calling antigen commands. With this | 340 | # A syntax sugar to avoid the `-` when calling antigen commands. With this |
338 | # function, you can write `antigen-bundle` as `antigen bundle` and so on. | 341 | # function, you can write `antigen-bundle` as `antigen bundle` and so on. |
339 | antigen () { | 342 | antigen () { |
340 | local cmd="$1" | 343 | local cmd="$1" |
341 | shift | 344 | shift |
342 | "antigen-$cmd" "$@" | 345 | "antigen-$cmd" "$@" |
343 | } | 346 | } |
344 | 347 | ||
345 | # Echo the bundle specs as in the record. The first line is not echoed since it | 348 | # Echo the bundle specs as in the record. The first line is not echoed since it |
346 | # is a blank line. | 349 | # is a blank line. |
347 | -antigen-echo-record () { | 350 | -antigen-echo-record () { |
348 | echo "$_ANTIGEN_BUNDLE_RECORD" | sed -n '1!p' | 351 | echo "$_ANTIGEN_BUNDLE_RECORD" | sed -n '1!p' |
349 | } | 352 | } |
350 | 353 | ||
351 | -antigen-env-setup () { | 354 | -antigen-env-setup () { |
352 | # Pre-startup initializations | 355 | # Pre-startup initializations |
353 | -set-default ANTIGEN_DEFAULT_REPO_URL \ | 356 | -set-default ANTIGEN_DEFAULT_REPO_URL \ |
354 | https://github.com/robbyrussell/oh-my-zsh.git | 357 | https://github.com/robbyrussell/oh-my-zsh.git |
355 | -set-default ADOTDIR $HOME/.antigen | 358 | -set-default ADOTDIR $HOME/.antigen |
356 | 359 | ||
357 | # Load the compinit module | 360 | # Load the compinit module |
358 | autoload -U compinit | 361 | autoload -U compinit |
359 | 362 | ||
360 | # Without the following, `compdef` function is not defined. | 363 | # Without the following, `compdef` function is not defined. |
361 | compinit -i | 364 | compinit -i |
362 | } | 365 | } |
363 | 366 | ||
364 | # Same as `export $1=$2`, but will only happen if the name specified by `$1` is | 367 | # Same as `export $1=$2`, but will only happen if the name specified by `$1` is |
365 | # not already set. | 368 | # not already set. |
366 | -set-default () { | 369 | -set-default () { |
367 | local arg_name="$1" | 370 | local arg_name="$1" |
368 | local arg_value="$2" | 371 | local arg_value="$2" |
369 | eval "test -z \"\$$arg_name\" && export $arg_name='$arg_value'" | 372 | eval "test -z \"\$$arg_name\" && export $arg_name='$arg_value'" |
370 | } | 373 | } |
371 | 374 | ||
372 | -antigen-env-setup | 375 | -antigen-env-setup |
373 | 376 |