summaryrefslogtreecommitdiff
path: root/tools/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/install.sh')
-rwxr-xr-xtools/install.sh32
1 files changed, 12 insertions, 20 deletions
diff --git a/tools/install.sh b/tools/install.sh
index 8cba52085..2fb87cdaf 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -24,12 +24,10 @@ main() {
# which may fail on systems lacking tput or terminfo
set -e
- CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
- if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
+ if ! command -v zsh >/dev/null 2>&1; then
printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
exit
fi
- unset CHECK_ZSH_INSTALLED
if [ ! -n "$ZSH" ]; then
ZSH=~/.oh-my-zsh
@@ -49,15 +47,10 @@ main() {
umask g-w,o-w
printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
- hash git >/dev/null 2>&1 || {
+ command -v git >/dev/null 2>&1 || {
echo "Error: git is not installed"
exit 1
}
- env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
- printf "Error: git clone of oh-my-zsh repo failed\n"
- exit 1
- }
-
# The Windows (MSYS) Git is not compatible with normal use on cygwin
if [ "$OSTYPE" = cygwin ]; then
if git --version | grep msysgit > /dev/null; then
@@ -66,6 +59,11 @@ main() {
exit 1
fi
fi
+ env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$ZSH" || {
+ printf "Error: git clone of oh-my-zsh repo failed\n"
+ exit 1
+ }
+
printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
@@ -74,20 +72,14 @@ main() {
fi
printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
- cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
+ cp "$ZSH"/templates/zshrc.zsh-template ~/.zshrc
sed "/^export ZSH=/ c\\
- export ZSH=$ZSH
- " ~/.zshrc > ~/.zshrc-omztemp
- mv -f ~/.zshrc-omztemp ~/.zshrc
-
- printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
- sed "/export PATH=/ c\\
- export PATH=\"$PATH\"
+ export ZSH=\"$ZSH\"
" ~/.zshrc > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc
# If this user's login shell is not already "zsh", attempt to switch.
- TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
+ TEST_CURRENT_SHELL=$(basename "$SHELL")
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if hash chsh >/dev/null 2>&1; then
@@ -113,10 +105,10 @@ main() {
echo ''
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 'p.p.s. Get stickers and t-shirts at https://shop.planetargon.com.'
echo ''
printf "${NORMAL}"
- env zsh
+ env zsh -l
}
main