1
0
Fork 0
mirror of synced 2024-11-15 22:18:58 -05:00
tpm/scripts/update_plugin.sh

75 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/shared_functions.sh"
2014-08-05 13:02:42 -04:00
empty() {
[ -z "$1" ]
}
if_all() {
[ "$1" == "all" ]
}
cancel() {
exit 0
}
pull_changes() {
local plugin="$1"
local plugin_path=$(shared_plugin_path "$plugin")
cd $plugin_path &&
2015-02-08 09:38:55 -05:00
GIT_TERMINAL_PROMPT=0 git pull &&
GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
2014-08-05 13:02:42 -04:00
}
update() {
local plugin="$1"
echo_message "Updating \"$plugin\""
$(pull_changes "$plugin" > /dev/null 2>&1) &&
echo_message " \"$plugin\" update success" ||
echo_message " \"$plugin\" update fail"
}
update_all() {
local plugins="$(shared_get_tpm_plugins_list)"
for plugin in $plugins; do
2014-08-05 13:02:42 -04:00
local plugin_name="$(shared_plugin_name "$plugin")"
# updating only installed plugins
if plugin_already_installed "$plugin_name"; then
update "$plugin_name"
fi
done
}
2014-08-05 13:02:42 -04:00
handle_plugin_update() {
local arg="$1"
if empty "$arg"; then
cancel
elif if_all "$arg"; then
echo_message "Updating all plugins!"
echo_message ""
update_all
2014-08-05 13:02:42 -04:00
elif plugin_already_installed "$arg"; then
update "$arg"
else
display_message "It seems this plugin is not installed: $arg"
cancel
fi
}
main() {
2014-08-05 13:02:42 -04:00
local arg="$1"
shared_set_tpm_path_constant
2014-08-05 13:02:42 -04:00
handle_plugin_update "$arg"
reload_tmux_environment
end_message
}
2014-08-05 13:02:42 -04:00
main "$1"