Enable removing plugins via CLI executable

This commit is contained in:
Bruno Sutic
2015-08-03 00:29:01 +02:00
parent b2a2581a6a
commit 19da205b0b
7 changed files with 107 additions and 12 deletions

View File

@ -4,6 +4,33 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/shared_functions.sh"
TMUX_ECHO_FLAG="$1"
# True if invoked as tmux mapping or tmux command,
# false if invoked via command line wrapper from `bin/` directory.
use_tmux_echo() {
[ "$TMUX_ECHO_FLAG" == "--tmux-echo" ]
}
if use_tmux_echo; then
# use tmux specific echo-ing
echo_ok() {
echo_message "$*"
}
echo_err() {
echo_message "$*"
}
else
echo_ok() {
echo "$*"
}
echo_err() {
fail_helper "$*"
}
fi
clean_plugins() {
local plugins plugin plugin_directory
plugins="$(shared_get_tpm_plugins_list)"
@ -15,22 +42,20 @@ clean_plugins() {
*"${plugin}"*) : ;;
*)
[ "${plugin}" = "tpm" ] && continue
echo_message "Removing \"$plugin\""
rm -rf "${plugin_directory}"
echo_ok "Removing \"$plugin\""
rm -rf "${plugin_directory}" >/dev/null 2>&1
[ -d "${plugin_directory}" ] &&
echo_message " \"$plugin\" clean fail" ||
echo_message " \"$plugin\" clean success"
echo_err " \"$plugin\" clean fail" ||
echo_ok " \"$plugin\" clean success"
;;
esac
done
}
main() {
reload_tmux_environment
shared_set_tpm_path_constant
ensure_tpm_path_exists
clean_plugins
reload_tmux_environment
end_message
exit_value_helper
}
main