# # Antibody plugin manager # function __zspr_antibody_download { local DOWNLOAD_URL="https://github.com/getantibody/antibody/releases/download" local LATEST="$(curl -s https://raw.githubusercontent.com/getantibody/homebrew-tap/master/Formula/antibody.rb | grep url | cut -f8 -d'/')" local ANTIBODY_TMP="$(mktemp -d)" local ANTIBODY_TGZ="${ANTIBODY_TMP}/antibody.tar.gz" local ANTIBODY="${ANTIBODY_TMP}/antibody" echo "Downloading Antibody $LATEST for $(uname -s)_$(uname -m), please wait..." curl -s -L -o "${ANTIBODY_TGZ}" "${DOWNLOAD_URL}/${LATEST}/antibody_$(uname -s)_$(uname -m).tar.gz" tar -xf "${ANTIBODY_TGZ}" -C "${ANTIBODY_TMP}" # Move antibody to ~/.local/share/bin test -x "${ANTIBODY}" || { echo "Failed to find unpacked Antibody binary!" } mv "${ANTIBODY}" "${HOME}/.local/share/bin/antibody" # Test if antibody works __zspr_has_command "antibody" || echo "Could not get Antibody working!" # Clean up rm -rf "${ANTIBODY_TMP}" } function __zspr_antibody_init { __zspr_has_command "antibody" || __zspr_antibody_download source <(antibody init) } function __zspr_antibody_load_plugins { # Iterate over array and let antibody create plugins script for plugin in ${ZSHUPER_PLUGINS}; do echo "${plugin}"; done | antibody bundle } function __zspr_antibody_install_plugin { antibody bundle "${1}" } function __zspr_antibody_update_plugins { antibody update } function __zspr_antibody_has_plugin { local PLUGIN="$(echo -n "${1}" | sed 's#/#-SLASH-##g')" antibody list | grep -q "${PLUGIN}" return $? } # Set up antibody as a plugin manager ZSPR_PLM_FUNCTIONS[1]=__zspr_antibody_init ZSPR_PLM_FUNCTIONS[2]=__zspr_antibody_load_plugins ZSPR_PLM_FUNCTIONS[3]=__zspr_antibody_install_plugin ZSPR_PLM_FUNCTIONS[4]=__zspr_antibody_update_plugins ZSPR_PLM_FUNCTIONS[5]=__zspr_antibody_has_plugin