Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index ff2e3e9171da433ee9364dad4de2075d6a6ff9d0..8ff1219b0ccb3dea5db0e74a26a7a99ff798cb5f 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -1,45 +1,60 @@
6 set -e
7
8-BLUE="\033[0;34m"
9-GREEN="\033[0;32m"
10-YELLOW="\033[0;33m"
11-NOCOLOR="\033[0m"
12+# Use colors, but only if connected to a terminal, and that terminal
13+# supports them.
14+ncolors=$(tput colors)
15+if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
16+ RED=="$(tput setaf 1)"
17+ GREEN="$(tput setaf 2)"
18+ YELLOW="$(tput setaf 3)"
19+ BLUE="$(tput setaf 4)"
20+ BOLD="$(tput bold)"
21+ NORMAL="$(tput sgr0)"
22+else
23+ RED=""
24+ GREEN=""
25+ YELLOW=""
26+ BLUE=""
27+ BOLD=""
28+ NORMAL=""
29+fi
30
31 if [ ! -n "$ZSH" ]; then
32 ZSH=~/.oh-my-zsh
33 fi
34
35 if [ -d "$ZSH" ]; then
36- printf "${YELLOW}You already have Oh My Zsh installed.${NOCOLOR} You'll need to remove $ZSH if you want to install\n"
37+ printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
38+ printf "You'll need to remove $ZSH if you want to re-install.\n"
39 exit
40 fi
41
42-printf "${BLUE}Cloning Oh My Zsh...${NOCOLOR}\n"
43+printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
44 hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
45 printf "git not installed\n"
46 exit
47 }
48
49-printf "${BLUE}Looking for an existing zsh config...${NOCOLOR}\n"
50+printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
51 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
52- printf "${YELLOW}Found ~/.zshrc.${NOCOLOR} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NOCOLOR}\n";
53+ printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
54 mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
55 fi
56
57-printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NOCOLOR}\n"
58+printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
59 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
60 sed -i -e "/^export ZSH=/ c\\
61 export ZSH=$ZSH
62 " ~/.zshrc
63
64-printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NOCOLOR}\n"
65+printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
66 sed -i -e "/export PATH=/ c\\
67 export PATH=\"$PATH\"
68 " ~/.zshrc
69
70 TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
71 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
72- printf "${BLUE}Time to change your default shell to zsh!${NOCOLOR}\n"
73+ printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
74 chsh -s $(grep /zsh$ /etc/shells | tail -1)
75 fi
76 unset TEST_CURRENT_SHELL
77@@ -59,5 +74,5 @@ echo 'p.s. Follow us at http://twitter.com/ohmyzsh.'
78 echo ''
79 echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.'
80 echo ''
81-printf "${NOCOLOR}"
82+printf "${NORMAL}"
83 env zsh
84diff --git a/tools/upgrade.sh b/tools/upgrade.sh
85index 5f0a81f1d1e6e057a56c705ffa80fe5391f0f875..4929054c925f82cb551321ad22875a3a9ce218df 100644
86--- a/tools/upgrade.sh
87+++ b/tools/upgrade.sh
88@@ -1,16 +1,37 @@
89-printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh"
90+
91+# Use colors, but only if connected to a terminal, and that terminal
92+# supports them.
93+ncolors=$(tput colors)
94+if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
95+ RED=="$(tput setaf 1)"
96+ GREEN="$(tput setaf 2)"
97+ YELLOW="$(tput setaf 3)"
98+ BLUE="$(tput setaf 4)"
99+ BOLD="$(tput bold)"
100+ NORMAL="$(tput sgr0)"
101+else
102+ RED=""
103+ GREEN=""
104+ YELLOW=""
105+ BLUE=""
106+ BOLD=""
107+ NORMAL=""
108+fi
109+
110+printf "${BLUE}%s${NORMAL}\n" "Upgrading Oh My Zsh"
111 cd "$ZSH"
112 if git pull --rebase --stat origin master
113 then
114- printf '\033[0;32m%s\033[0m\n' ' __ __ '
115- printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
116- printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
117- printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
118- printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
119- printf '\033[0;32m%s\033[0m\n' ' /____/ '
120- printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
121- 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'
122- printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/'
123+ printf '%s' "$GREEN"
124+ printf '%s\n' ' __ __ '
125+ printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
126+ printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
127+ printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
128+ printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
129+ printf '%s\n' ' /____/ '
130+ printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
131+ printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: http://twitter.com/ohmyzsh"
132+ printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/"
133 else
134- printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'
135+ printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
136 fi