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