From 9d4a9e7cadf20a3e7069908b38a89a195289cce5 Mon Sep 17 00:00:00 2001 From: eggbean <815311+eggbean@users.noreply.github.com> Date: Mon, 3 Jul 2023 03:22:05 +0100 Subject: [PATCH] Colourise update response to make failure more apparent It is too easy to miss when an update fails, so this makes the result much quicker to understand --- bindings/update_plugins | 7 ++++++- scripts/update_plugin.sh | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bindings/update_plugins b/bindings/update_plugins index 28cc281..02cccad 100755 --- a/bindings/update_plugins +++ b/bindings/update_plugins @@ -7,6 +7,11 @@ # - shows a list of installed plugins # - starts a prompt to enter the name of the plugin that will be updated +if command -v tput >/dev/null; then + yellow=$(tput setaf 3) + norm=$(tput sgr0) +fi + CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPTS_DIR="$CURRENT_DIR/../scripts" HELPERS_DIR="$SCRIPTS_DIR/helpers" @@ -24,7 +29,7 @@ display_plugin_update_list() { # displaying only installed plugins if plugin_already_installed "$plugin"; then local plugin_name="$(plugin_name_helper "$plugin")" - tmux_echo " $plugin_name" + tmux_echo " ${yellow}${plugin_name}${norm}" fi done diff --git a/scripts/update_plugin.sh b/scripts/update_plugin.sh index e533664..4ebe94e 100755 --- a/scripts/update_plugin.sh +++ b/scripts/update_plugin.sh @@ -2,6 +2,13 @@ # this script handles core logic of updating plugins +if command -v tput >/dev/null; then + red=$(tput setaf 1) + green=$(tput setaf 2) + yellow=$(tput setaf 3) + norm=$(tput sgr0) +fi + CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" HELPERS_DIR="$CURRENT_DIR/helpers" @@ -29,10 +36,10 @@ update() { local plugin="$1" output output=$(pull_changes "$plugin" 2>&1) if (( $? == 0 )); then - echo_ok " \"$plugin\" update success" + echo_ok " \"${yellow}${plugin}${norm}\" ${green}update success${norm}" echo_ok "$(echo "$output" | sed -e 's/^/ | /')" else - echo_err " \"$plugin\" update fail" + echo_err " \"${yellow}${plugin}${norm}\" ${red}update fail${norm}" echo_err "$(echo "$output" | sed -e 's/^/ | /')" fi }