Commit e85891281960d8ee8e5de08a75fbee9d04296cce

Authored by mj
Exists in master and in 2 other branches 02-merge, dev

Merge commit '4f87835bac074648b5f5108fd499ee67cd04b26f' into 03-UPDATE

Showing 5 changed files Side-by-side Diff

1   -function main() {
2   -# Use colors, but only if connected to a terminal, and that terminal
3   -# supports them.
4   -if which tput >/dev/null 2>&1; then
5   - ncolors=$(tput colors)
6   -fi
7   -if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
8   - RED="$(tput setaf 1)"
9   - GREEN="$(tput setaf 2)"
10   - YELLOW="$(tput setaf 3)"
11   - BLUE="$(tput setaf 4)"
12   - BOLD="$(tput bold)"
13   - NORMAL="$(tput sgr0)"
14   -else
15   - RED=""
16   - GREEN=""
17   - YELLOW=""
18   - BLUE=""
19   - BOLD=""
20   - NORMAL=""
21   -fi
  1 +main() {
  2 + # Use colors, but only if connected to a terminal, and that terminal
  3 + # supports them.
  4 + if which tput >/dev/null 2>&1; then
  5 + ncolors=$(tput colors)
  6 + fi
  7 + if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
  8 + RED="$(tput setaf 1)"
  9 + GREEN="$(tput setaf 2)"
  10 + YELLOW="$(tput setaf 3)"
  11 + BLUE="$(tput setaf 4)"
  12 + BOLD="$(tput bold)"
  13 + NORMAL="$(tput sgr0)"
  14 + else
  15 + RED=""
  16 + GREEN=""
  17 + YELLOW=""
  18 + BLUE=""
  19 + BOLD=""
  20 + NORMAL=""
  21 + fi
22 22  
23   -# Only enable exit-on-error after the non-critical colorization stuff,
24   -# which may fail on systems lacking tput or terminfo
25   -set -e
  23 + # Only enable exit-on-error after the non-critical colorization stuff,
  24 + # which may fail on systems lacking tput or terminfo
  25 + set -e
26 26  
27   -CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
28   -if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
29   - printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
30   - exit
31   -fi
32   -unset CHECK_ZSH_INSTALLED
  27 + CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
  28 + if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
  29 + printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
  30 + exit
  31 + fi
  32 + unset CHECK_ZSH_INSTALLED
33 33  
34   -if [ ! -n "$ZSH" ]; then
35   - ZSH=~/.oh-my-zsh
36   -fi
  34 + if [ ! -n "$ZSH" ]; then
  35 + ZSH=~/.oh-my-zsh
  36 + fi
37 37  
38   -if [ -d "$ZSH" ]; then
39   - printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
40   - printf "You'll need to remove $ZSH if you want to re-install.\n"
41   - exit
42   -fi
  38 + if [ -d "$ZSH" ]; then
  39 + printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
  40 + printf "You'll need to remove $ZSH if you want to re-install.\n"
  41 + exit
  42 + fi
43 43  
44   -# Prevent the cloned repository from having insecure permissions. Failing to do
45   -# so causes compinit() calls to fail with "command not found: compdef" errors
46   -# for users with insecure umasks (e.g., "002", allowing group writability). Note
47   -# that this will be ignored under Cygwin by default, as Windows ACLs take
48   -# precedence over umasks except for filesystems mounted with option "noacl".
49   -umask g-w,o-w
  44 + # Prevent the cloned repository from having insecure permissions. Failing to do
  45 + # so causes compinit() calls to fail with "command not found: compdef" errors
  46 + # for users with insecure umasks (e.g., "002", allowing group writability). Note
  47 + # that this will be ignored under Cygwin by default, as Windows ACLs take
  48 + # precedence over umasks except for filesystems mounted with option "noacl".
  49 + umask g-w,o-w
50 50  
51   -printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
52   -hash git >/dev/null 2>&1 || {
53   - echo "Error: git is not installed"
54   - exit 1
55   -}
56   -env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
57   - printf "Error: git clone of oh-my-zsh repo failed\n"
58   - exit 1
59   -}
60   -
61   -# The Windows (MSYS) Git is not compatible with normal use on cygwin
62   -if [ "$OSTYPE" = cygwin ]; then
63   - if git --version | grep msysgit > /dev/null; then
64   - echo "Error: Windows/MSYS Git is not supported on Cygwin"
65   - echo "Error: Make sure the Cygwin git package is installed and is first on the path"
  51 + printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
  52 + hash git >/dev/null 2>&1 || {
  53 + echo "Error: git is not installed"
  54 + exit 1
  55 + }
  56 + env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
  57 + printf "Error: git clone of oh-my-zsh repo failed\n"
66 58 exit 1
  59 + }
  60 +
  61 + # The Windows (MSYS) Git is not compatible with normal use on cygwin
  62 + if [ "$OSTYPE" = cygwin ]; then
  63 + if git --version | grep msysgit > /dev/null; then
  64 + echo "Error: Windows/MSYS Git is not supported on Cygwin"
  65 + echo "Error: Make sure the Cygwin git package is installed and is first on the path"
  66 + exit 1
  67 + fi
67 68 fi
68   -fi
69 69  
70   -printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
71   -if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
72   - printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
73   - mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
74   -fi
  70 + printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
  71 + if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
  72 + printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
  73 + mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
  74 + fi
75 75  
76   -printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
77   -cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
78   -sed "/^export ZSH=/ c\\
79   -export ZSH=$ZSH
80   -" ~/.zshrc > ~/.zshrc-omztemp
81   -mv -f ~/.zshrc-omztemp ~/.zshrc
  76 + printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
  77 + cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
  78 + sed "/^export ZSH=/ c\\
  79 + export ZSH=$ZSH
  80 + " ~/.zshrc > ~/.zshrc-omztemp
  81 + mv -f ~/.zshrc-omztemp ~/.zshrc
82 82  
83   -printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
84   -sed "/export PATH=/ c\\
85   -export PATH=\"$PATH\"
86   -" ~/.zshrc > ~/.zshrc-omztemp
87   -mv -f ~/.zshrc-omztemp ~/.zshrc
  83 + printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
  84 + sed "/export PATH=/ c\\
  85 + export PATH=\"$PATH\"
  86 + " ~/.zshrc > ~/.zshrc-omztemp
  87 + mv -f ~/.zshrc-omztemp ~/.zshrc
88 88  
89   -# If this user's login shell is not already "zsh", attempt to switch.
90   -TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
91   -if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
92   - # If this platform provides a "chsh" command (not Cygwin), do it, man!
93   - if hash chsh >/dev/null 2>&1; then
94   - printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
95   - chsh -s $(grep /zsh$ /etc/shells | tail -1)
96   - # Else, suggest the user do so manually.
97   - else
98   - printf "I can't change your shell automatically because this system does not have chsh.\n"
99   - printf "${BLUE}Please manually change your default shell to zsh!${NORMAL}\n"
  89 + # If this user's login shell is not already "zsh", attempt to switch.
  90 + TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
  91 + if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
  92 + # If this platform provides a "chsh" command (not Cygwin), do it, man!
  93 + if hash chsh >/dev/null 2>&1; then
  94 + printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
  95 + chsh -s $(grep /zsh$ /etc/shells | tail -1)
  96 + # Else, suggest the user do so manually.
  97 + else
  98 + printf "I can't change your shell automatically because this system does not have chsh.\n"
  99 + printf "${BLUE}Please manually change your default shell to zsh!${NORMAL}\n"
  100 + fi
100 101 fi
101   -fi
102 102  
103   -printf "${GREEN}"
104   -echo ' __ __ '
105   -echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
106   -echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
107   -echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
108   -echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
109   -echo ' /____/ ....is now installed!'
110   -echo ''
111   -echo ''
112   -echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
113   -echo ''
114   -echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
115   -echo ''
116   -echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.'
117   -echo ''
118   -printf "${NORMAL}"
119   -env zsh
  103 + printf "${GREEN}"
  104 + echo ' __ __ '
  105 + echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
  106 + echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
  107 + echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
  108 + echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
  109 + echo ' /____/ ....is now installed!'
  110 + echo ''
  111 + echo ''
  112 + echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
  113 + echo ''
  114 + echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
  115 + echo ''
  116 + echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.'
  117 + echo ''
  118 + printf "${NORMAL}"
  119 + env zsh
120 120 }
121 121  
122 122 main