install.sh 2.29 KB
Newer Older
Andrew Vit's avatar
Andrew Vit committed
1
2
set -e

3
4
5
6
# 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
7
  RED="$(tput setaf 1)"
8
9
10
11
12
13
14
15
16
17
18
19
20
  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
21

22
if [ ! -n "$ZSH" ]; then
23
24
25
  ZSH=~/.oh-my-zsh
fi

26
if [ -d "$ZSH" ]; then
27
28
  printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
  printf "You'll need to remove $ZSH if you want to re-install.\n"
Robby Russell's avatar
Robby Russell committed
29
30
31
  exit
fi

32
printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
33
hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
34
  printf "git not installed\n"
35
  exit
Renan Cakirerk's avatar
Renan Cakirerk committed
36
}
Toon Claes's avatar
Toon Claes committed
37

38
printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
39
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
40
  printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
41
  mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
Robby Russell's avatar
Robby Russell committed
42
43
fi

44
printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
45
cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
46
47
sed -i -e "/^export ZSH=/ c\\
export ZSH=$ZSH
Andrew Vit's avatar
Andrew Vit committed
48
" ~/.zshrc
Robby Russell's avatar
Robby Russell committed
49

50
printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
51
52
53
sed -i -e "/export PATH=/ c\\
export PATH=\"$PATH\"
" ~/.zshrc
54

55
56
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
57
    printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
58
    chsh -s $(grep /zsh$ /etc/shells | tail -1)
59
fi
60
unset TEST_CURRENT_SHELL
Robby Russell's avatar
Robby Russell committed
61

62
63
64
65
66
67
68
69
70
71
72
printf "${GREEN}"
echo '         __                                     __   '
echo '  ____  / /_     ____ ___  __  __   ____  _____/ /_  '
echo ' / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ '
echo '/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / '
echo '\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  '
echo '                        /____/                       ....is now installed!'
echo ''
echo ''
echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
echo ''
73
echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
74
75
76
echo ''
echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.'
echo ''
77
printf "${NORMAL}"
78
env zsh