2014-05-18 22:35:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2015-08-03 13:12:45 +00:00
|
|
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
2014-05-18 22:35:55 +00:00
|
|
|
|
2015-08-03 15:40:50 +00:00
|
|
|
source "$HELPERS_DIR/plugin_functions.sh"
|
|
|
|
source "$HELPERS_DIR/utility.sh"
|
2014-05-18 22:35:55 +00:00
|
|
|
|
2015-08-03 13:12:45 +00: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 21:36:49 +00:00
|
|
|
fi
|
|
|
|
|
2014-05-18 22:35:55 +00:00
|
|
|
clone() {
|
2015-07-29 21:36:49 +00:00
|
|
|
local plugin="$1"
|
2015-08-03 13:29:53 +00:00
|
|
|
cd "$(tpm_path)" &&
|
2015-07-31 21:23:57 +00:00
|
|
|
GIT_TERMINAL_PROMPT=0 git clone --recursive "$plugin" >/dev/null 2>&1
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# tries cloning:
|
|
|
|
# 1. plugin name directly - works if it's a valid git url
|
|
|
|
# 2. expands the plugin name to point to a github repo and tries cloning again
|
|
|
|
clone_plugin() {
|
2015-07-29 21:36:49 +00:00
|
|
|
local plugin="$1"
|
2014-05-24 21:15:13 +00:00
|
|
|
clone "$plugin" ||
|
2014-11-21 22:53:45 +00:00
|
|
|
clone "https://git::@github.com/$plugin"
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
2015-07-29 21:36:49 +00:00
|
|
|
# clone plugin and produce output
|
2014-08-05 16:15:07 +00:00
|
|
|
install_plugin() {
|
2014-08-05 18:50:47 +00:00
|
|
|
local plugin="$1"
|
2015-08-03 15:40:50 +00:00
|
|
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
2014-08-05 18:50:47 +00:00
|
|
|
|
2014-08-05 16:45:59 +00:00
|
|
|
if plugin_already_installed "$plugin"; then
|
2015-07-29 21:36:49 +00:00
|
|
|
echo_ok "Already installed \"$plugin_name\""
|
2014-05-24 21:15:13 +00:00
|
|
|
else
|
2015-07-29 21:36:49 +00:00
|
|
|
echo_ok "Installing \"$plugin_name\""
|
2014-05-24 21:15:13 +00:00
|
|
|
clone_plugin "$plugin" &&
|
2015-07-29 21:36:49 +00:00
|
|
|
echo_ok " \"$plugin_name\" download success" ||
|
|
|
|
echo_err " \"$plugin_name\" download fail"
|
2014-05-24 21:15:13 +00:00
|
|
|
fi
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
2014-08-05 16:15:07 +00:00
|
|
|
install_plugins() {
|
2015-08-03 15:40:50 +00:00
|
|
|
local plugins="$(tpm_plugins_list_helper)"
|
2014-05-24 21:15:13 +00:00
|
|
|
for plugin in $plugins; do
|
2014-08-05 16:15:07 +00:00
|
|
|
install_plugin "$plugin"
|
2014-05-24 21:15:13 +00:00
|
|
|
done
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
2015-07-22 17:13:01 +00:00
|
|
|
verify_tpm_path_permissions() {
|
2015-08-03 13:29:53 +00:00
|
|
|
local path="$(tpm_path)"
|
2015-07-22 17:13:01 +00:00
|
|
|
# check the write permission flag for all users to ensure
|
|
|
|
# that we have proper access
|
2015-08-03 13:29:53 +00:00
|
|
|
[ -w "$path" ] ||
|
|
|
|
echo_err "$path is not writable!"
|
2015-07-22 17:13:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 22:35:55 +00:00
|
|
|
main() {
|
2014-05-24 21:15:13 +00:00
|
|
|
ensure_tpm_path_exists
|
2015-07-22 17:13:01 +00:00
|
|
|
verify_tpm_path_permissions
|
2014-08-05 16:15:07 +00:00
|
|
|
install_plugins
|
2015-07-29 21:36:49 +00:00
|
|
|
exit_value_helper
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
main
|