19ea867a3a5cc118fd84560275db05354a4aed0b

Author
Andrew Janke <janke@pobox.com>
Committer
Andrew Janke <andrew@apjanke.net>
Date

Message

install.sh: use portable printf instead of echo

Diff

 1diff --git a/tools/install.sh b/tools/install.sh
 2index c83a6f23d0776abec9a189f90d0846d8d3036ab0..ff2e3e9171da433ee9364dad4de2075d6a6ff9d0 100755
 3--- a/tools/install.sh
 4+++ b/tools/install.sh
 5@@ -1,52 +1,63 @@
 6 set -e
 7 
 8+BLUE="\033[0;34m"
 9+GREEN="\033[0;32m"
10+YELLOW="\033[0;33m"
11+NOCOLOR="\033[0m"
12+
13 if [ ! -n "$ZSH" ]; then
14   ZSH=~/.oh-my-zsh
15 fi
16 
17 if [ -d "$ZSH" ]; then
18-  echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install"
19+  printf "${YELLOW}You already have Oh My Zsh installed.${NOCOLOR} You'll need to remove $ZSH if you want to install\n"
20   exit
21 fi
22 
23-echo "\033[0;34mCloning Oh My Zsh...\033[0m"
24+printf "${BLUE}Cloning Oh My Zsh...${NOCOLOR}\n"
25 hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
26-  echo "git not installed"
27+  printf "git not installed\n"
28   exit
29 }
30 
31-echo "\033[0;34mLooking for an existing zsh config...\033[0m"
32+printf "${BLUE}Looking for an existing zsh config...${NOCOLOR}\n"
33 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
34-  echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m";
35+  printf "${YELLOW}Found ~/.zshrc.${NOCOLOR} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NOCOLOR}\n";
36   mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
37 fi
38 
39-echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
40+printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NOCOLOR}\n"
41 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
42 sed -i -e "/^export ZSH=/ c\\
43 export ZSH=$ZSH
44 " ~/.zshrc
45 
46-echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
47+printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NOCOLOR}\n"
48 sed -i -e "/export PATH=/ c\\
49 export PATH=\"$PATH\"
50 " ~/.zshrc
51 
52 TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
53 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
54-    echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
55+    printf "${BLUE}Time to change your default shell to zsh!${NOCOLOR}\n"
56     chsh -s $(grep /zsh$ /etc/shells | tail -1)
57 fi
58 unset TEST_CURRENT_SHELL
59 
60-echo "\033[0;32m"'         __                                     __   '"\033[0m"
61-echo "\033[0;32m"'  ____  / /_     ____ ___  __  __   ____  _____/ /_  '"\033[0m"
62-echo "\033[0;32m"' / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ '"\033[0m"
63-echo "\033[0;32m"'/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / '"\033[0m"
64-echo "\033[0;32m"'\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  '"\033[0m"
65-echo "\033[0;32m"'                        /____/                       ....is now installed!'"\033[0m"
66-echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m"
67-echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m"
68-echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m"
69+printf "${GREEN}"
70+echo '         __                                     __   '
71+echo '  ____  / /_     ____ ___  __  __   ____  _____/ /_  '
72+echo ' / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ '
73+echo '/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / '
74+echo '\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  '
75+echo '                        /____/                       ....is now installed!'
76+echo ''
77+echo ''
78+echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
79+echo ''
80+echo 'p.s. Follow us at http://twitter.com/ohmyzsh.'
81+echo ''
82+echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.'
83+echo ''
84+printf "${NOCOLOR}"
85 env zsh
86-. ~/.zshrc