Commit a12d3140ac03267fbe534ae5af127d1d17f538b5
1 parent
2ac7c0cb0a
Removed bundle-install. Works without it.
Showing 1 changed file with 19 additions and 69 deletions Side-by-side Diff
antigen.zsh
| ... | ... | @@ -2,8 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | # Each line in this string has the following entries separated by a space |
| 4 | 4 | # character. |
| 5 | -# <repo-url>, <plugin-location>, <repo-local-clone-dir>, | |
| 6 | -# <bundle-type> | |
| 5 | +# <repo-url>, <plugin-location>, <bundle-type> | |
| 7 | 6 | # FIXME: Is not kept local by zsh! |
| 8 | 7 | local _ANTIGEN_BUNDLE_RECORD="" |
| 9 | 8 | |
| ... | ... | @@ -48,17 +47,24 @@ bundle () { |
| 48 | 47 | url="https://github.com/$url.git" |
| 49 | 48 | fi |
| 50 | 49 | |
| 51 | - # Plugin's repo will be cloned here. | |
| 52 | - local clone_dir="$ADOTDIR/repos/$(echo "$url" \ | |
| 53 | - | sed -e 's/\.git$//' -e 's./.-SLASH-.g' -e 's.:.-COLON-.g')" | |
| 54 | - | |
| 55 | 50 | # Add it to the record. |
| 56 | - _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $clone_dir $btype" | |
| 51 | + _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype" | |
| 52 | + | |
| 53 | + -antigen-ensure-repo "$url" | |
| 57 | 54 | |
| 58 | - -antigen-ensure-repo "$url" "$clone_dir" | |
| 55 | + bundle-load "$url" "$loc" "$btype" | |
| 59 | 56 | |
| 60 | - bundle-load "$clone_dir/$loc" "$btype" | |
| 57 | +} | |
| 61 | 58 | |
| 59 | +-antigen-get-clone-dir () { | |
| 60 | + # Takes a repo url and gives out the path that this url needs to be cloned | |
| 61 | + # to. Doesn't actually clone anything. | |
| 62 | + # TODO: Memoize? | |
| 63 | + echo -n $ADOTDIR/repos/ | |
| 64 | + echo "$1" | sed \ | |
| 65 | + -e 's/\.git$//' \ | |
| 66 | + -e 's./.-SLASH-.g' \ | |
| 67 | + -e 's.:.-COLON-.g' | |
| 62 | 68 | } |
| 63 | 69 | |
| 64 | 70 | -antigen-ensure-repo () { |
| ... | ... | @@ -73,7 +79,7 @@ bundle () { |
| 73 | 79 | local install_bundles="" |
| 74 | 80 | |
| 75 | 81 | local url="$1" |
| 76 | - local clone_dir="$2" | |
| 82 | + local clone_dir="$(-antigen-get-clone-dir $url)" | |
| 77 | 83 | |
| 78 | 84 | if ! echo "$handled_repos" | grep -Fqm1 "$url"; then |
| 79 | 85 | if [[ ! -d $clone_dir ]]; then |
| ... | ... | @@ -87,63 +93,6 @@ bundle () { |
| 87 | 93 | |
| 88 | 94 | } |
| 89 | 95 | |
| 90 | -bundle-install () { | |
| 91 | - | |
| 92 | - local update=false | |
| 93 | - if [[ $1 == --update ]]; then | |
| 94 | - update=true | |
| 95 | - shift | |
| 96 | - fi | |
| 97 | - | |
| 98 | - mkdir -p "$ADOTDIR/bundles" | |
| 99 | - | |
| 100 | - local handled_repos="" | |
| 101 | - local install_bundles="" | |
| 102 | - | |
| 103 | - if [[ $# != 0 ]]; then | |
| 104 | - # Record and install just the given plugin here and now. | |
| 105 | - bundle "$@" | |
| 106 | - install_bundles="$(-bundle-echo-record | tail -1)" | |
| 107 | - else | |
| 108 | - # Install all the plugins, previously recorded. | |
| 109 | - install_bundles="$(-bundle-echo-record)" | |
| 110 | - fi | |
| 111 | - | |
| 112 | - # If the above `if` is directly piped to the below `while`, the contents | |
| 113 | - # inside the `if` construct are run in a new subshell, so changes to the | |
| 114 | - # `$_ANTIGEN_BUNDLE_RECORD` variable are lost after the `if` construct | |
| 115 | - # finishes. So, we need the temporary `$install_bundles` variable. | |
| 116 | - echo "$install_bundles" | while read spec; do | |
| 117 | - | |
| 118 | - local name="$(echo "$spec" | awk '{print $1}')" | |
| 119 | - local url="$(echo "$spec" | awk '{print $2}')" | |
| 120 | - local loc="$(echo "$spec" | awk '{print $3}')" | |
| 121 | - local clone_dir="$(echo "$spec" | awk '{print $4}')" | |
| 122 | - local btype="$(echo "$spec" | awk '{print $5}')" | |
| 123 | - | |
| 124 | - if [[ -z "$(echo "$handled_repos" | grep -Fm1 "$url")" ]]; then | |
| 125 | - if [[ ! -d $clone_dir ]]; then | |
| 126 | - git clone "$url" "$clone_dir" | |
| 127 | - elif $update; then | |
| 128 | - git --git-dir "$clone_dir/.git" pull | |
| 129 | - fi | |
| 130 | - | |
| 131 | - handled_repos="$handled_repos\n$url" | |
| 132 | - fi | |
| 133 | - | |
| 134 | - bundle-load "$clone_dir/$loc" "$btype" | |
| 135 | - | |
| 136 | - done | |
| 137 | - | |
| 138 | - # Initialize completions after installing | |
| 139 | - bundle-apply | |
| 140 | - | |
| 141 | -} | |
| 142 | - | |
| 143 | -bundle-install! () { | |
| 144 | - bundle-install --update | |
| 145 | -} | |
| 146 | - | |
| 147 | 96 | bundle-cleanup () { |
| 148 | 97 | |
| 149 | 98 | if [[ ! -d "$ADOTDIR/bundles" || \ |
| ... | ... | @@ -182,8 +131,9 @@ bundle-cleanup () { |
| 182 | 131 | |
| 183 | 132 | bundle-load () { |
| 184 | 133 | |
| 185 | - local location="$1" | |
| 186 | - local btype="$2" | |
| 134 | + local url="$1" | |
| 135 | + local location="$(-antigen-get-clone-dir "$url")/$2" | |
| 136 | + local btype="$3" | |
| 187 | 137 | |
| 188 | 138 | if [[ $btype == theme ]]; then |
| 189 | 139 |