2014-05-18 18:35:55 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2015-08-03 09:12:45 -04:00
|
|
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
2014-05-18 18:35:55 -04:00
|
|
|
|
2015-08-03 11:40:50 -04:00
|
|
|
source "$HELPERS_DIR/plugin_functions.sh"
|
|
|
|
source "$HELPERS_DIR/utility.sh"
|
2014-05-18 18:35:55 -04:00
|
|
|
|
2015-08-03 09:12:45 -04:00
|
|
|
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
|
|
|
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
|
|
|
else # shell output functions
|
|
|
|
source "$HELPERS_DIR/shell_echo_functions.sh"
|
2015-07-29 17:36:49 -04:00
|
|
|
fi
|
|
|
|
|
2014-05-18 18:35:55 -04:00
|
|
|
clone() {
|
2021-08-14 05:00:04 -04:00
|
|
|
local plugin="$1"
|
2024-02-07 09:40:12 -05:00
|
|
|
[[ -z "$2" ]] && local branch="" || local branch="--branch $2"
|
|
|
|
if [[ ! $plugin == *"https://"* ]]; then
|
2021-08-14 03:41:26 -04:00
|
|
|
cd "$(tpm_path)" &&
|
2024-02-07 09:40:12 -05:00
|
|
|
GIT_TERMINAL_PROMPT=0 git clone $branch --single-branch --recursive "https://git::@github.com/$plugin" $plugin >/dev/null 2>&1
|
2021-08-14 03:41:26 -04:00
|
|
|
else
|
2024-02-07 09:40:12 -05:00
|
|
|
local basename_with_git="$(basename "$plugin")"
|
|
|
|
local basename="${basename_with_git%.git}"
|
2021-08-14 03:41:26 -04:00
|
|
|
cd "$(tpm_path)" &&
|
2024-02-07 09:40:12 -05:00
|
|
|
GIT_TERMINAL_PROMPT=0 git clone $branch --single-branch --recursive "$basename" $basename >/dev/null 2>&1
|
2021-08-14 03:41:26 -04:00
|
|
|
fi
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
clone_plugin() {
|
2015-07-29 17:36:49 -04:00
|
|
|
local plugin="$1"
|
2019-05-19 16:59:06 -04:00
|
|
|
local branch="$2"
|
|
|
|
clone "$plugin" "$branch" ||
|
|
|
|
clone "https://git::@github.com/$plugin" "$branch"
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
2015-07-29 17:36:49 -04:00
|
|
|
# clone plugin and produce output
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugin() {
|
2021-08-14 05:00:04 -04:00
|
|
|
local plugin="$1"
|
|
|
|
local branch="$2"
|
2015-08-03 11:40:50 -04:00
|
|
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
2014-08-05 14:50:47 -04:00
|
|
|
|
2014-08-05 12:45:59 -04:00
|
|
|
if plugin_already_installed "$plugin"; then
|
2015-07-29 17:36:49 -04:00
|
|
|
echo_ok "Already installed \"$plugin_name\""
|
2014-05-24 17:15:13 -04:00
|
|
|
else
|
2015-07-29 17:36:49 -04:00
|
|
|
echo_ok "Installing \"$plugin_name\""
|
2019-05-19 16:59:06 -04:00
|
|
|
clone_plugin "$plugin" "$branch" &&
|
2015-07-29 17:36:49 -04:00
|
|
|
echo_ok " \"$plugin_name\" download success" ||
|
|
|
|
echo_err " \"$plugin_name\" download fail"
|
2014-05-24 17:15:13 -04:00
|
|
|
fi
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugins() {
|
2015-08-03 11:40:50 -04:00
|
|
|
local plugins="$(tpm_plugins_list_helper)"
|
2014-05-24 17:15:13 -04:00
|
|
|
for plugin in $plugins; do
|
2024-02-07 09:40:12 -05:00
|
|
|
if [[ "$plugin" == *#* ]]; then
|
|
|
|
IFS='#' read -ra plugin <<< "$plugin"
|
|
|
|
install_plugin "${plugin[0]}" "${plugin[1]}"
|
|
|
|
elif [[ "$plugin" == *@* ]]; then
|
|
|
|
IFS='@' read -ra plugin <<< "$plugin"
|
|
|
|
install_plugin "${plugin[0]}" "${plugin[1]}"
|
|
|
|
else
|
|
|
|
install_plugin ${plugin}
|
|
|
|
fi
|
2014-05-24 17:15:13 -04:00
|
|
|
done
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
|
2015-07-22 13:13:01 -04:00
|
|
|
verify_tpm_path_permissions() {
|
2015-08-03 09:29:53 -04:00
|
|
|
local path="$(tpm_path)"
|
2015-07-22 13:13:01 -04:00
|
|
|
# check the write permission flag for all users to ensure
|
|
|
|
# that we have proper access
|
2015-08-03 09:29:53 -04:00
|
|
|
[ -w "$path" ] ||
|
|
|
|
echo_err "$path is not writable!"
|
2015-07-22 13:13:01 -04:00
|
|
|
}
|
|
|
|
|
2014-05-18 18:35:55 -04:00
|
|
|
main() {
|
2014-05-24 17:15:13 -04:00
|
|
|
ensure_tpm_path_exists
|
2015-07-22 13:13:01 -04:00
|
|
|
verify_tpm_path_permissions
|
2014-08-05 12:15:07 -04:00
|
|
|
install_plugins
|
2015-07-29 17:36:49 -04:00
|
|
|
exit_value_helper
|
2014-05-18 18:35:55 -04:00
|
|
|
}
|
|
|
|
main
|