From 8cf610089d97cf1abbd5cf3e0fb28d63b4c25f51 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 6 Jul 2015 20:18:32 -0400 Subject: installer: use terminfo for portable escape sequences Do not use terminal visual effects if not connected to a terminal. --- tools/upgrade.sh | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'tools/upgrade.sh') diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 5f0a81f1d..4929054c9 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,16 +1,37 @@ -printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" + +# Use colors, but only if connected to a terminal, and that terminal +# supports them. +ncolors=$(tput colors) +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED=="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + BOLD="" + NORMAL="" +fi + +printf "${BLUE}%s${NORMAL}\n" "Upgrading Oh My Zsh" cd "$ZSH" if git pull --rebase --stat origin master then - printf '\033[0;32m%s\033[0m\n' ' __ __ ' - printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' - printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' - printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' - printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' - printf '\033[0;32m%s\033[0m\n' ' /____/ ' - printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/' + printf '%s' "$GREEN" + printf '%s\n' ' __ __ ' + printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' + printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' + printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' + printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' + printf '%s\n' ' /____/ ' + printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version." + printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: http://twitter.com/ohmyzsh" + printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/" else - printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' + printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?' fi -- cgit v1.2.3-70-g09d2 From de47e2df69fd4ac29fd887f5ab593f2f738f982a Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 16 Aug 2015 19:29:58 +0200 Subject: Use https instead of http --- tools/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/upgrade.sh') diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 5f0a81f1d..e06e4f331 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -9,7 +9,7 @@ then printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' printf '\033[0;32m%s\033[0m\n' ' /____/ ' printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh' + printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'https://twitter.com/ohmyzsh' printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/' else printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' -- cgit v1.2.3-70-g09d2 From fe92ea98e0633784508e85d6b756b1c3f667b2a4 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 18 Aug 2015 03:01:21 -0400 Subject: installer: switch twitter link to https --- tools/install.sh | 4 ++-- tools/upgrade.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/upgrade.sh') diff --git a/tools/install.sh b/tools/install.sh index 8ff1219b0..beec750c3 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -4,7 +4,7 @@ set -e # supports them. ncolors=$(tput colors) if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then - RED=="$(tput setaf 1)" + RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" @@ -70,7 +70,7 @@ echo '' echo '' echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.' echo '' -echo 'p.s. Follow us at http://twitter.com/ohmyzsh.' +echo 'p.s. Follow us at https://twitter.com/ohmyzsh.' echo '' echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.' echo '' diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 4929054c9..59b380116 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -30,7 +30,7 @@ then printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' printf '%s\n' ' /____/ ' printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version." - printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: http://twitter.com/ohmyzsh" + printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh" printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/" else printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?' -- cgit v1.2.3-70-g09d2 From 95296bb0c5fade33c6cda7ccc7139a35c2641b3a Mon Sep 17 00:00:00 2001 From: Frederic Crozat Date: Tue, 22 Sep 2015 16:46:22 +0200 Subject: also handle missing tput in upgrade script. --- tools/upgrade.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tools/upgrade.sh') diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 65af6e368..6e9696202 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,7 +1,10 @@ # Use colors, but only if connected to a terminal, and that terminal # supports them. -ncolors=$(tput colors) +tput=$(which tput) +if [ -n "$tput" ]; then + ncolors=$(tput colors) +fi if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" -- cgit v1.2.3-70-g09d2