Commit 4f87835bac074648b5f5108fd499ee67cd04b26f

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

Squashed 'repos/robbyrussell/oh-my-zsh/' changes from 8c84342..e44aa50

e44aa50 Merge pull request #4535 from robbyrussell/mcornella-patch-1
e9de366 Update custom location command and fix code format
ba20b98 Merge pull request #4016 from coopermaruyama/master
9264d75 Fix typo.
405ee83 Merge pull request #4500 from sachin21/modify_a_condition
d06f4d0 Fix backwards logic in uninstaller once and for all
a1755e6 Refactor for method in plugins/rake-fast/rake-fast.plugin.zsh
4e42e1f Fix conditional in uninstall prompt
b2010a0 Fix syntax error in confirmation prompt of uninstall.sh
ca5632b Fix syntax error in #4515 on certain shells
78dc858 Revert "Make install script safer"

git-subtree-dir: repos/robbyrussell/oh-my-zsh
git-subtree-split: e44aa50301cbdb9c713193263e6c0c5a9a5798c0

Showing 5 changed files with 117 additions and 123 deletions Inline Diff

1 ![Oh My Zsh](https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png) 1 ![Oh My Zsh](https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png)
2 2
3 3
4 Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again. 4 Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again.
5 5
6 __Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. 6 __Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often.
7 7
8 To learn more, visit [ohmyz.sh](http://ohmyz.sh) and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. 8 To learn more, visit [ohmyz.sh](http://ohmyz.sh) and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter.
9 9
10 ## Getting Started 10 ## Getting Started
11 11
12 12
13 ### Prerequisites 13 ### Prerequisites
14 14
15 __Disclaimer:__ _Oh My Zsh works best on Mac OS X and Linux._ 15 __Disclaimer:__ _Oh My Zsh works best on Mac OS X and Linux._
16 16
17 * Unix-based operating system (Mac OS X or Linux) 17 * Unix-based operating system (Mac OS X or Linux)
18 * [Zsh](http://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing-ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH) 18 * [Zsh](http://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing-ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH)
19 * `curl` or `wget` should be installed 19 * `curl` or `wget` should be installed
20 * `git` should be installed 20 * `git` should be installed
21 21
22 ### Basic Installation 22 ### Basic Installation
23 23
24 Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`. 24 Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`.
25 25
26 #### via curl 26 #### via curl
27 27
28 `sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"` 28 ```shell
29 sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
30 ```
29 31
30 #### via wget 32 #### via wget
31 33
32 `sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"` 34 ```shell
35 sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
36 ```
33 37
34 ## Using Oh My Zsh 38 ## Using Oh My Zsh
35 39
36 ### Plugins 40 ### Plugins
37 41
38 Oh My Zsh comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. 42 Oh My Zsh comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available.
39 43
40 #### Enabling Plugins 44 #### Enabling Plugins
41 45
42 If you spot a plugin (or several) that you would like to use with Oh My Zsh, you will need to edit the `~/.zshrc` file. Once you open it with your favorite editor, you'll see a spot to list all the plugins that you'd like Oh My Zsh to load in initialization. 46 If you spot a plugin (or several) that you would like to use with Oh My Zsh, you will need to edit the `~/.zshrc` file. Once you open it with your favorite editor, you'll see a spot to list all the plugins that you'd like Oh My Zsh to load in initialization.
43 47
44 For example, this line might begin to look like... 48 For example, this line might begin to look like...
45 49
46 ```shell 50 ```shell
47 plugins=(git bundler osx rake ruby) 51 plugins=(git bundler osx rake ruby)
48 ``` 52 ```
49 53
50 #### Using Plugins 54 #### Using Plugins
51 55
52 Most plugins (should! we're working on this) include a __README__, which documents how to use them. 56 Most plugins (should! we're working on this) include a __README__, which documents how to use them.
53 57
54 ### Themes 58 ### Themes
55 59
56 We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out! 60 We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out!
57 61
58 #### Selecting a Theme 62 #### Selecting a Theme
59 63
60 _Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just right (for him)._ 64 _Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just right (for him)._
61 65
62 Once you find a theme that you want to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like: 66 Once you find a theme that you want to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
63 67
64 ```shell 68 ```shell
65 ZSH_THEME="robbyrussell" 69 ZSH_THEME="robbyrussell"
66 ``` 70 ```
67 71
68 To use a different theme, simply change the value to match the name of your desired theme. For example: 72 To use a different theme, simply change the value to match the name of your desired theme. For example:
69 73
70 ```shell 74 ```shell
71 ZSH_THEME="agnoster" # (this is one of the fancy ones) 75 ZSH_THEME="agnoster" # (this is one of the fancy ones)
72 ``` 76 ```
73 77
74 Open up a new terminal window and your prompt should look something like... 78 Open up a new terminal window and your prompt should look something like...
75 79
76 ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) 80 ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
77 81
78 In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). 82 In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes).
79 83
80 If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. 84 If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
81 85
82 86
83 ```shell 87 ```shell
84 ZSH_THEME="random" # (...please let it be pie... please be some pie..) 88 ZSH_THEME="random" # (...please let it be pie... please be some pie..)
85 ``` 89 ```
86 90
87 91
88 ## Advanced Topics 92 ## Advanced Topics
89 93
90 If you're the type that likes to get their hands dirty, these sections might resonate. 94 If you're the type that likes to get their hands dirty, these sections might resonate.
91 95
92 ### Advanced Installation 96 ### Advanced Installation
93 97
94 Some users may want to change the default path, or manually install Oh My Zsh. 98 Some users may want to change the default path, or manually install Oh My Zsh.
95 99
96 #### Custom Directory 100 #### Custom Directory
97 101
98 The default location is `~/.oh-my-zsh` (hidden in your home directory) 102 The default location is `~/.oh-my-zsh` (hidden in your home directory)
99 103
100 If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this: 104 If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
101 105
102 ```shell 106 ```shell
103 curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh 107 export ZSH="~/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
104 ``` 108 ```
105 109
106 #### Manual Installation 110 #### Manual Installation
107 111
108 ##### 1. Clone the repository: 112 ##### 1. Clone the repository:
109 113
110 ```shell 114 ```shell
111 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh 115 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
112 ``` 116 ```
113 117
114 ##### 2. *Optionally*, backup your existing `~/.zshrc` file: 118 ##### 2. *Optionally*, backup your existing `~/.zshrc` file:
115 119
116 ```shell 120 ```shell
117 cp ~/.zshrc ~/.zshrc.orig 121 cp ~/.zshrc ~/.zshrc.orig
118 ``` 122 ```
119 123
120 ##### 3. Create a new zsh configuration file 124 ##### 3. Create a new zsh configuration file
121 125
122 You can create a new zsh config file by copying the template that we included for you. 126 You can create a new zsh config file by copying the template that we included for you.
123 127
124 ```shell 128 ```shell
125 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc 129 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
126 ``` 130 ```
127 131
128 ##### 4. Change your default shell 132 ##### 4. Change your default shell
129 133
130 ```shell 134 ```shell
131 chsh -s /bin/zsh 135 chsh -s /bin/zsh
132 ``` 136 ```
133 137
134 ##### 5. Initialize your new zsh configuration 138 ##### 5. Initialize your new zsh configuration
135 139
136 Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. 140 Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
137 141
138 ### Installation Problems 142 ### Installation Problems
139 143
140 If you have any hiccups installing, here are a few common fixes. 144 If you have any hiccups installing, here are a few common fixes.
141 145
142 * You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`. 146 * You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
143 * If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. 147 * If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
144 148
145 ### Custom Plugins and Themes 149 ### Custom Plugins and Themes
146 150
147 If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory. 151 If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
148 152
149 If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin. 153 If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin.
150 154
151 If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`. 155 If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
152 156
153 ## Getting Updates 157 ## Getting Updates
154 158
155 By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`: 159 By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`:
156 160
157 ```shell 161 ```shell
158 DISABLE_UPDATE_PROMPT=true 162 DISABLE_UPDATE_PROMPT=true
159 ``` 163 ```
160 164
161 To disable automatic upgrades, set the following in your `~/.zshrc`: 165 To disable automatic upgrades, set the following in your `~/.zshrc`:
162 166
163 ```shell 167 ```shell
164 DISABLE_AUTO_UPDATE=true 168 DISABLE_AUTO_UPDATE=true
165 ``` 169 ```
166 170
167 ### Manual Updates 171 ### Manual Updates
168 172
169 If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run: 173 If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
170 174
171 ```shell 175 ```shell
172 upgrade_oh_my_zsh 176 upgrade_oh_my_zsh
173 ``` 177 ```
174 178
175 Magic! 179 Magic!
176 180
177 ## Uninstalling Oh My Zsh 181 ## Uninstalling Oh My Zsh
178 182
179 Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup. 183 Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
180 184
181 If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration. 185 If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration.
182 186
183 ## Contributing 187 ## Contributing
184 188
185 I'm far from being a [Zsh](http://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! 189 I'm far from being a [Zsh](http://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
186 190
187 We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. 191 We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can.
188 192
189 ### Do NOT send us themes 193 ### Do NOT send us themes
190 194
191 We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. 195 We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page.
192 196
193 ## Contributors 197 ## Contributors
194 198
195 Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help from our contributors, it wouldn't be so awesome. 199 Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help from our contributors, it wouldn't be so awesome.
196 200
197 Thank you so much! 201 Thank you so much!
198 202
199 ## Follow Us 203 ## Follow Us
200 204
201 We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. 205 We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it.
202 206
203 ## Merchandise 207 ## Merchandise
204 208
205 We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town! 209 We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town!
206 210
207 ## License 211 ## License
208 212
209 Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt). 213 Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt).
210 214
plugins/coffee/coffee.plugin.zsh
1 #!/bin/zsh 1 #!/bin/zsh
2 2
3 # compile a string of coffeescript and print to output 3 # compile a string of coffeescript and print to output
4 cf () { 4 cf () {
5 coffee -peb "$1" 5 coffee -peb "$1"
6 } 6 }
7 # compile & copy to clipboard 7 # compile & copy to clipboard
8 cfc () { 8 cfc () {
9 cf "$1" | clipcopy 9 cf "$1" | clipcopy
10 } 10 }
11 11
12 # compile from clipboard & print 12 # compile from clipboard & print
13 alias cfp='coffeeMe "$(clippaste)"' 13 alias cfp='cf "$(clippaste)"'
14 14
15 # compile from clipboard and copy to clipboard 15 # compile from clipboard and copy to clipboard
16 alias cfpc='cfp | clipcopy' 16 alias cfpc='cfp | clipcopy'
17 17
plugins/rake-fast/rake-fast.plugin.zsh
1 _rake_refresh () { 1 _rake_refresh () {
2 if [ -f .rake_tasks ]; then 2 if [ -f .rake_tasks ]; then
3 rm .rake_tasks 3 rm .rake_tasks
4 fi 4 fi
5 echo "Generating .rake_tasks..." > /dev/stderr 5 echo "Generating .rake_tasks..." > /dev/stderr
6 _rake_generate 6 _rake_generate
7 cat .rake_tasks 7 cat .rake_tasks
8 } 8 }
9 9
10 _rake_does_task_list_need_generating () { 10 _rake_does_task_list_need_generating () {
11 if [ ! -f .rake_tasks ]; then return 0; 11 [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]]
12 else
13 if [[ "$OSTYPE" = darwin* ]]; then
14 accurate=$(stat -f%m .rake_tasks)
15 changed=$(stat -f%m Rakefile)
16 else
17 accurate=$(stat -c%Y .rake_tasks)
18 changed=$(stat -c%Y Rakefile)
19 fi
20 return $(expr $accurate '>=' $changed)
21 fi
22 } 12 }
23 13
24 _rake_generate () { 14 _rake_generate () {
25 rake --silent --tasks | cut -d " " -f 2 > .rake_tasks 15 rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
26 } 16 }
27 17
28 _rake () { 18 _rake () {
29 if [ -f Rakefile ]; then 19 if [ -f Rakefile ]; then
30 if _rake_does_task_list_need_generating; then 20 if _rake_does_task_list_need_generating; then
31 echo "\nGenerating .rake_tasks..." > /dev/stderr 21 echo "\nGenerating .rake_tasks..." > /dev/stderr
32 _rake_generate 22 _rake_generate
33 fi 23 fi
34 compadd `cat .rake_tasks` 24 compadd `cat .rake_tasks`
35 fi 25 fi
36 } 26 }
37 27
38 compdef _rake rake 28 compdef _rake rake
39 alias rake_refresh='_rake_refresh' 29 alias rake_refresh='_rake_refresh'
40 30
1 function main() { 1 main() {
2 # Use colors, but only if connected to a terminal, and that terminal 2 # Use colors, but only if connected to a terminal, and that terminal
3 # supports them. 3 # supports them.
4 if which tput >/dev/null 2>&1; then 4 if which tput >/dev/null 2>&1; then
5 ncolors=$(tput colors) 5 ncolors=$(tput colors)
6 fi 6 fi
7 if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then 7 if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
8 RED="$(tput setaf 1)" 8 RED="$(tput setaf 1)"
9 GREEN="$(tput setaf 2)" 9 GREEN="$(tput setaf 2)"
10 YELLOW="$(tput setaf 3)" 10 YELLOW="$(tput setaf 3)"
11 BLUE="$(tput setaf 4)" 11 BLUE="$(tput setaf 4)"
12 BOLD="$(tput bold)" 12 BOLD="$(tput bold)"
13 NORMAL="$(tput sgr0)" 13 NORMAL="$(tput sgr0)"
14 else 14 else
15 RED="" 15 RED=""
16 GREEN="" 16 GREEN=""
17 YELLOW="" 17 YELLOW=""
18 BLUE="" 18 BLUE=""
19 BOLD="" 19 BOLD=""
20 NORMAL="" 20 NORMAL=""
21 fi 21 fi
22 22
23 # Only enable exit-on-error after the non-critical colorization stuff, 23 # Only enable exit-on-error after the non-critical colorization stuff,
24 # which may fail on systems lacking tput or terminfo 24 # which may fail on systems lacking tput or terminfo
25 set -e 25 set -e
26 26
27 CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l) 27 CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
28 if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then 28 if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
29 printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n" 29 printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
30 exit 30 exit
31 fi 31 fi
32 unset CHECK_ZSH_INSTALLED 32 unset CHECK_ZSH_INSTALLED
33 33
34 if [ ! -n "$ZSH" ]; then 34 if [ ! -n "$ZSH" ]; then
35 ZSH=~/.oh-my-zsh 35 ZSH=~/.oh-my-zsh
36 fi 36 fi
37 37
38 if [ -d "$ZSH" ]; then 38 if [ -d "$ZSH" ]; then
39 printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n" 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" 40 printf "You'll need to remove $ZSH if you want to re-install.\n"
41 exit 41 exit
42 fi 42 fi
43 43
44 # Prevent the cloned repository from having insecure permissions. Failing to do 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 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 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 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". 48 # precedence over umasks except for filesystems mounted with option "noacl".
49 umask g-w,o-w 49 umask g-w,o-w
50 50
51 printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n" 51 printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
52 hash git >/dev/null 2>&1 || { 52 hash git >/dev/null 2>&1 || {
53 echo "Error: git is not installed" 53 echo "Error: git is not installed"
54 exit 1 54 exit 1
55 } 55 }
56 env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { 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" 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"
66 exit 1 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 fi 68 fi
68 fi
69 69
70 printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n" 70 printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
71 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then 71 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
72 printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n"; 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; 73 mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
74 fi 74 fi
75 75
76 printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n" 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 77 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
78 sed "/^export ZSH=/ c\\ 78 sed "/^export ZSH=/ c\\
79 export ZSH=$ZSH 79 export ZSH=$ZSH
80 " ~/.zshrc > ~/.zshrc-omztemp 80 " ~/.zshrc > ~/.zshrc-omztemp
81 mv -f ~/.zshrc-omztemp ~/.zshrc 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" 83 printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
84 sed "/export PATH=/ c\\ 84 sed "/export PATH=/ c\\
85 export PATH=\"$PATH\" 85 export PATH=\"$PATH\"
86 " ~/.zshrc > ~/.zshrc-omztemp 86 " ~/.zshrc > ~/.zshrc-omztemp
87 mv -f ~/.zshrc-omztemp ~/.zshrc 87 mv -f ~/.zshrc-omztemp ~/.zshrc
88 88
89 # If this user's login shell is not already "zsh", attempt to switch. 89 # If this user's login shell is not already "zsh", attempt to switch.
90 TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') 90 TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
91 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then 91 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
92 # If this platform provides a "chsh" command (not Cygwin), do it, man! 92 # If this platform provides a "chsh" command (not Cygwin), do it, man!
93 if hash chsh >/dev/null 2>&1; then 93 if hash chsh >/dev/null 2>&1; then
94 printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n" 94 printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
95 chsh -s $(grep /zsh$ /etc/shells | tail -1) 95 chsh -s $(grep /zsh$ /etc/shells | tail -1)
96 # Else, suggest the user do so manually. 96 # Else, suggest the user do so manually.
97 else 97 else
98 printf "I can't change your shell automatically because this system does not have chsh.\n" 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" 99 printf "${BLUE}Please manually change your default shell to zsh!${NORMAL}\n"
100 fi
100 fi 101 fi
101 fi
102 102
103 printf "${GREEN}" 103 printf "${GREEN}"
104 echo ' __ __ ' 104 echo ' __ __ '
105 echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' 105 echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
106 echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' 106 echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
107 echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' 107 echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
108 echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' 108 echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
109 echo ' /____/ ....is now installed!' 109 echo ' /____/ ....is now installed!'
110 echo '' 110 echo ''
111 echo '' 111 echo ''
112 echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.' 112 echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
113 echo '' 113 echo ''
1 read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation 1 read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
2 if ! [[ $confirmation =~ ^[yY]$ ]] 2 if [ "$confirmation" != y ] && [ "$confirmation" != Y ]
3 then 3 then
4 echo "Uninstall cancelled" 4 echo "Uninstall cancelled"
5 exit 5 exit
6 fi 6 fi
7 7
8 echo "Removing ~/.oh-my-zsh" 8 echo "Removing ~/.oh-my-zsh"
9 if [ -d ~/.oh-my-zsh ] 9 if [ -d ~/.oh-my-zsh ]
10 then 10 then
11 rm -rf ~/.oh-my-zsh 11 rm -rf ~/.oh-my-zsh
12 fi 12 fi
13 13
14 echo "Looking for original zsh config..." 14 echo "Looking for original zsh config..."
15 if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ] 15 if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]
16 then 16 then
17 echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc"; 17 echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
18 18
19 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] 19 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
20 then 20 then
21 ZSHRC_SAVE=".zshrc.omz-uninstalled-`date +%Y%m%d%H%M%S`"; 21 ZSHRC_SAVE=".zshrc.omz-uninstalled-`date +%Y%m%d%H%M%S`";
22 echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}"; 22 echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
23 mv ~/.zshrc ~/${ZSHRC_SAVE}; 23 mv ~/.zshrc ~/${ZSHRC_SAVE};
24 fi 24 fi
25 25
26 mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc; 26 mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
27 27
28 source ~/.zshrc; 28 source ~/.zshrc;
29 else 29 else
30 if hash chsh >/dev/null 2>&1 30 if hash chsh >/dev/null 2>&1
31 then 31 then
32 echo "Switching back to bash" 32 echo "Switching back to bash"
33 chsh -s /bin/bash 33 chsh -s /bin/bash
34 else 34 else
35 echo "You can edit /etc/passwd to switch your default shell back to bash" 35 echo "You can edit /etc/passwd to switch your default shell back to bash"
36 fi 36 fi
37 fi 37 fi
38 38
39 echo "Thanks for trying out Oh My Zsh. It's been uninstalled." 39 echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
40 40