918d26e7dbcb907e673df24242c9688cd89019b9
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/tools/install.sh b/tools/install.sh
2index aebd2837175a610e1876ddd473219b131528f1c7..4b1a6ba7e1651180159aaf73587f48d01a54b1e9 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -1,8 +1,26 @@
6 set -e
7
8+# Use colors, but only if connected to a terminal, and that terminal
9+# supports them.
10+ncolors=$(tput colors)
11+if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
12+ RED="$(tput setaf 1)"
13+ GREEN="$(tput setaf 2)"
14+ YELLOW="$(tput setaf 3)"
15+ BLUE="$(tput setaf 4)"
16+ BOLD="$(tput bold)"
17+ NORMAL="$(tput sgr0)"
18+else
19+ RED=""
20+ GREEN=""
21+ YELLOW=""
22+ BLUE=""
23+ BOLD=""
24+ NORMAL=""
25+fi
26 CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
27 if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
28- echo "\033[0;33m Zsh is not installed!\033[0m Please install zsh first!"
29+ printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
30 exit
31 fi
32 unset CHECK_ZSH_INSTALLED
33@@ -12,7 +30,8 @@ if [ ! -n "$ZSH" ]; then
34 fi
35
36 if [ -d "$ZSH" ]; then
37- echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install"
38+ printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
39+ printf "You'll need to remove $ZSH if you want to re-install.\n"
40 exit
41 fi
42
43@@ -23,26 +42,26 @@ fi
44 # precedence over umasks except for filesystems mounted with option "noacl".
45 umask g-w,o-w
46
47-echo "\033[0;34mCloning Oh My Zsh...\033[0m"
48+printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
49 hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
50- echo "git not installed"
51+ printf "git not installed\n"
52 exit
53 }
54
55-echo "\033[0;34mLooking for an existing zsh config...\033[0m"
56+printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
57 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
58- echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m";
59+ printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
60 mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
61 fi
62
63-echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
64+printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
65 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
66 sed "/^export ZSH=/ c\\
67 export ZSH=$ZSH
68 " ~/.zshrc > ~/.zshrc-omztemp
69 mv -f ~/.zshrc-omztemp ~/.zshrc
70
71-echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
72+printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
73 sed "/export PATH=/ c\\
74 export PATH=\"$PATH\"
75 " ~/.zshrc > ~/.zshrc-omztemp
76@@ -52,22 +71,28 @@ mv -f ~/.zshrc-omztemp ~/.zshrc
77 if [ "$(expr "$SHELL" : '.*/\(.*\)')" != "zsh" ]; then
78 # If this platform provides a "chsh" command (not Cygwin), do it, man!
79 if hash chsh >/dev/null 2>&1; then
80- echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
81+ printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
82 chsh -s $(grep /zsh$ /etc/shells | tail -1)
83 # Else, suggest the user do so manually.
84 else
85- echo "\033[0;34mPlease manually change your default shell to zsh!\033[0m"
86+ printf "${BLUE}Please manually change your default shell to zsh!${NORMAL}\n"
87 fi
88 fi
89
90-echo "\033[0;32m"' __ __ '"\033[0m"
91-echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
92-echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
93-echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
94-echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
95-echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m"
96-echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m"
97-echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m"
98-echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m"
99+printf "${GREEN}"
100+echo ' __ __ '
101+echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
102+echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
103+echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
104+echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
105diff --git a/tools/upgrade.sh b/tools/upgrade.sh
106index e06e4f331498fb4bec38e52f924ba3dccd5c8660..65af6e36843d805621cd71d60275c2ff84692780 100644
107--- a/tools/upgrade.sh
108+++ b/tools/upgrade.sh
109@@ -1,16 +1,37 @@
110-printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh"
111+
112+# Use colors, but only if connected to a terminal, and that terminal
113+# supports them.
114+ncolors=$(tput colors)
115+if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
116+ RED="$(tput setaf 1)"
117+ GREEN="$(tput setaf 2)"
118+ YELLOW="$(tput setaf 3)"
119+ BLUE="$(tput setaf 4)"
120+ BOLD="$(tput bold)"
121+ NORMAL="$(tput sgr0)"
122+else
123+ RED=""
124+ GREEN=""
125+ YELLOW=""
126+ BLUE=""
127+ BOLD=""
128+ NORMAL=""
129+fi
130+
131+printf "${BLUE}%s${NORMAL}\n" "Upgrading Oh My Zsh"
132 cd "$ZSH"
133 if git pull --rebase --stat origin master
134 then
135- printf '\033[0;32m%s\033[0m\n' ' __ __ '
136- printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
137- printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
138- printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
139- printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
140- printf '\033[0;32m%s\033[0m\n' ' /____/ '
141- printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
142- 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'
143- printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/'
144+ printf '%s' "$GREEN"
145+ printf '%s\n' ' __ __ '
146+ printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
147+ printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
148+ printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
149+ printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
150+ printf '%s\n' ' /____/ '
151+ printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
152+ printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
153+ printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/"
154 else
155- printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'
156+ printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
157 fi