From a32a0d6ded1ad51280eb3215e2e9374a83bba3dd Mon Sep 17 00:00:00 2001 From: Bruno 21 Date: Sat, 9 Jan 2021 15:05:29 +0100 Subject: [PATCH] 5 scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +update colors strings +update parameter ‘—nodistract’ --- plugins.d/gem.sh | 21 ++++++++++++++------- plugins.d/homebrew.sh | 7 ++----- plugins.d/mas.sh | 31 ++++++++++++++++++++----------- plugins.d/node.sh | 6 +++--- plugins.d/pecl.sh | 25 +++++++++++++++---------- 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/plugins.d/gem.sh b/plugins.d/gem.sh index ae5d1e3..36de652 100755 --- a/plugins.d/gem.sh +++ b/plugins.d/gem.sh @@ -5,13 +5,20 @@ # https://guides.rubygems.org/what-is-a-gem/ # No distract mode -no_distract=false +[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false -if [[ $1 == "--nodistract" ]]; then - no_distract=true -fi +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bold="\033[1m" +bold_under="\033[1;4m" +redbox="\033[1;41m" +redbold="\033[1;31m" +red="\033[31m" +yellow="\033[33m" +reset="\033[0m" -echo -e "\033[1m 💍 Gem (Ruby) \033[0m" +echo -e "${bold} 💍 Gem (Ruby) ${reset}" echo "" @@ -21,7 +28,7 @@ upd=$(echo "$gem_outdated" | awk '{print $1}') if [ -n "$upd" ]; then nb=$(echo "$upd" | wc -w | xargs) - echo -e "\\033[1;41m $nb \033[0m \033[4mavailables updates:\033[0m" + echo -e "${redbox} $nb ${reset} ${underline}availables updates:${reset}" echo "$gem_outdated" echo "" @@ -38,5 +45,5 @@ if [ -n "$upd" ]; then fi done else - echo -e "\033[4mNo gem updates.\033[0m" + echo -e "${underline}No gem updates.${reset}" fi diff --git a/plugins.d/homebrew.sh b/plugins.d/homebrew.sh index 2fea155..3bb7e5b 100755 --- a/plugins.d/homebrew.sh +++ b/plugins.d/homebrew.sh @@ -15,7 +15,7 @@ display_info=true declare -a cask_to_not_update=() # No distract mode (no user interaction)(Casks with 'latest' version number won't be updated) -no_distract=false +[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false # Some Casks have auto_updates true or version :latest. Homebrew Cask cannot track versions of those apps. # 'latest=true' force Homebrew to update those apps. @@ -59,9 +59,6 @@ notification() { fi } -if [[ $1 == "--nodistract" ]]; then no_distract=true; fi -if [[ $1 == "--latest" ]]; then latest=true; fi - get_info_cask() { info="$1" app="$2" @@ -204,7 +201,7 @@ echo -e "\n🍺 ${underline}Updating packages...${reset}\n" if [ -n "$upd_pkg_notpinned" ]; then if [ "$no_distract" = false ]; then - a=$(echo -e "Do you wanna run \033[1mbrew upgrade "$upd_pkg_notpinned"\033[0m ? (y/n/a) ") + a=$(echo -e "Do you wanna run ${bold}brew upgrade "$upd_pkg_notpinned"${reset} ? (y/n/a) ") # yes/no/all read -p "$a" choice diff --git a/plugins.d/mas.sh b/plugins.d/mas.sh index 12c1af3..a645dac 100755 --- a/plugins.d/mas.sh +++ b/plugins.d/mas.sh @@ -3,16 +3,25 @@ # Mac Appstore plugin for KYMSU # https://github.com/welcoMattic/kymsu -echo -e "\033[1m🍏 Mac App Store updates come fast as lightning \033[0m" - # No distract mode (no user interaction) -no_distract=false +[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false -if [[ $1 == "--nodistract" ]]; then - no_distract=true -fi +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bold="\033[1m" +bold_under="\033[1;4m" +redbox="\033[1;41m" +redbold="\033[1;31m" +red="\033[31m" +yellow="\033[33m" +reset="\033[0m" + + +echo -e "${bold}🍏 Mac App Store updates come fast as lightning ${reset}" + +echo -e "https://github.com/mas-cli/mas" -# https://github.com/mas-cli/mas # On teste si mas est installé if hash mas 2>/dev/null; then @@ -21,13 +30,13 @@ if hash mas 2>/dev/null; then echo "$massy" if [ -n "$(mas outdated)" ]; then - echo -e "\033[4mAvailables updates:\033[0m" + echo -e "${underline}Availables updates:${reset}" echo "$massy" | cut -d " " -f2-5 echo "" if [ "$no_distract" = false ]; then - a=$(echo -e "Do you wanna run \033[1mmas upgrade\033[0m ? (y/n)") + a=$(echo -e "Do you wanna run \033[1mmas upgrade${reset} ? (y/n)") read -pr "$a" choice case "$choice" in y|Y|o ) mas upgrade;; @@ -40,10 +49,10 @@ if hash mas 2>/dev/null; then fi else - echo -e "\033[4mNo availables mas updates.\033[0m" + echo -e "${italic}No availables mas updates.${reset}" fi else - echo "Please install mas: brew install mas" + echo -e "Please install mas: ${italic}brew install mas${reset}" fi echo "" diff --git a/plugins.d/node.sh b/plugins.d/node.sh index f3d1cee..4d5b699 100755 --- a/plugins.d/node.sh +++ b/plugins.d/node.sh @@ -12,7 +12,7 @@ display_info=true # No distract mode (no user interaction) -[[ $1 == "--nodistract" ]] && no_distract=true || no_distract=false +[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false # Set ls_color to '' for output nvm list in default colors, else '--no-colors' # ls_color='--no-colors' @@ -125,9 +125,9 @@ elif [ -f "/usr/local/opt/nvm/nvm.sh" ]; then fi -echo -e "\033[3mNote:" +echo -e "${italic}Note:" echo -e "N/A: version \"10.18.0 -> N/A\" is not yet installed." -echo -e "You need to run \"nvm install 10.18.0\" to install it before using it.\033[0m" +echo -e "You need to run \"nvm install 10.18.0\" to install it before using it.${reset}" echo "" diff --git a/plugins.d/pecl.sh b/plugins.d/pecl.sh index 401ebdf..f4c61bd 100755 --- a/plugins.d/pecl.sh +++ b/plugins.d/pecl.sh @@ -10,10 +10,19 @@ # Settings: # No distract mode (no user interaction) -no_distract=false +[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false # ######################################### +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bgd="\033[1;4;31m" +red="\033[1;31m" +bold="\033[1m" +box="\033[1;41m" +reset="\033[0m" + notification() { sound="Basso" title="Homebrew" @@ -27,15 +36,11 @@ notification() { } -if [[ $1 == "--nodistract" ]]; then - no_distract=true -fi - -echo -e "\033[1m🐘 pecl \033[0m" +echo -e "${bold}🐘 pecl ${reset}" echo "" -echo -e "\033[1m❗️ plugin en test (beta) \033[0m" +echo -e "${bold}❗️ plugin en test (beta) ${reset}" echo "" # /usr/local/Cellar/php/7.4.11/bin/pecl @@ -60,7 +65,7 @@ pecl_upgrade=$($php_path/pecl list-upgrades) if [ -n "$pecl_upgrade" ]; then - echo -e "\033[4mExtensions update:\033[0m" + echo -e "${underline}Extensions update:${reset}" echo "" echo "$pecl_upgrade" @@ -117,11 +122,11 @@ notif2="$conf_php was modified in the last 5 minutes" test=$(find "$dir" -name "$name" -mmin -5 -maxdepth 1) if [ -n "$test" ]; then - echo -e "\033[1;31m❗️ ️$notif2\033[0m" + echo -e "${red}❗️ ️$notif2${reset}" notification "$notif2" echo "" - a=$(echo -e "Do you want to edit \033[1m$conf_php\033[0m file ? (y/n)") + a=$(echo -e "Do you want to edit ${bold}$conf_php${reset} file ? (y/n)") read -p "$a" choice if [ "$choice" == "y" ]; then $EDITOR "$conf_php"