52fdae4b3d17f7ab602124ec8792865b5fc03236
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.editorconfig b/.editorconfig
2new file mode 100644
3index 0000000000000000000000000000000000000000..aa18e0e5cde98f57ffe1ea57610902d37993ae2d
4--- /dev/null
5+++ b/.editorconfig
6@@ -0,0 +1,10 @@
7+root = true
8+
9+[*]
10+end_of_line = lf
11+insert_final_newline = true
12+charset = utf-8
13+
14+[*.sh]
15+indent_size = 4
16+indent_style = tab
17diff --git a/README.md b/README.md
18index 38f6ae9f318733b77dc2ab070f6f7e84b28bd4bf..3924c3a920c6e233529f5f4318fc097c0cb8173c 100644
19--- a/README.md
20+++ b/README.md
21@@ -38,7 +38,18 @@ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/mas
22 #### via wget
23
24 ```shell
25-sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
26+sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
27+```
28+
29+#### Manual inspection
30+
31+It's a good idea to inspect the install script from projects you don't yet know. You can do
32+that by downloading the install script first, looking through it so everything looks normal,
33+then running it:
34+
35+```shell
36+curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
37+sh install.sh
38 ```
39
40 ## Using Oh My Zsh
41@@ -69,6 +80,8 @@ plugins=(
42 )
43 ```
44
45+_Note that the plugins are separated by whitespace. **Do not** use commas between them._
46+
47 #### Using Plugins
48
49 Most plugins (should! we're working on this) include a __README__, which documents how to use them.
50@@ -124,16 +137,53 @@ If you're the type that likes to get their hands dirty, these sections might res
51
52 ### Advanced Installation
53
54-Some users may want to change the default path, or manually install Oh My Zsh.
55+Some users may want to manually install Oh My Zsh, or change the default path or other settings that
56+the installer accepts (these settings are also documented at the top of the install script).
57
58 #### Custom Directory
59
60 The default location is `~/.oh-my-zsh` (hidden in your home directory)
61
62-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:
63+If you'd like to change the install directory with the `ZSH` environment variable, either by running
64+`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
65+like this:
66+
67+```shell
68+ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
69+```
70+
71+#### Unattended install
72+
73+If you're running the Oh My Zsh install script as part of an automated install, you can pass the
74+flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
75+the default shell, and also won't run `zsh` when the installation has finished.
76
77 ```shell
78-export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
79+curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
80+sh install.sh --unattended
81+```
82+
83+#### Installing from a forked repository
84+
85+The install script also accepts these variables to allow installation of a different repository:
86+
87+- `REPO` (default: `robbyrussell/oh-my-zsh`): this takes the form of `owner/repository`. If you set
88+ this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
89+
90+- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository
91+ clone. You can use this setting if you want to install from a fork that is not on GitHub (GitLab,
92+ Bitbucket...) or if you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`).
93+
94+ _NOTE: it's incompatible with setting the `REPO` variable. This setting will take precedence._
95+
96+- `BRANCH` (default: `master`): you can use this setting if you want to change the default branch to be
97+ checked out when cloning the repository. This might be useful for testing a Pull Request, or if you
98+ want to use a branch other than `master`.
99+
100+For example:
101+
102+```shell
103+REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
104 ```
105
106 #### Manual Installation
107@@ -161,9 +211,10 @@ cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
108 ##### 4. Change your default shell
109
110 ```shell
111-chsh -s /bin/zsh
112+chsh -s $(which zsh)
113 ```
114-You must log out and log back in to see this change.
115+
116+You must log out from your user session and log back in to see this change.
117
118 ##### 5. Initialize your new zsh configuration
119
120@@ -173,8 +224,10 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
121diff --git a/tools/install.sh b/tools/install.sh
122index 2e5e8fd43351a6242f5f45b9245d6e80e35092ec..d56d8addc7bbb10858d16e5d62d1feff3ca1b862 100755
123--- a/tools/install.sh
124+++ b/tools/install.sh
125@@ -1,114 +1,272 @@
126+#!/bin/sh
127+#
128+# This script should be run via curl:
129+# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
130+# or wget:
131+# sh -c "$(wget -qO- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
132+#
133+# As an alternative, you can first download the install script and run it afterwards:
134+# wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
135+# sh install.sh
136+#
137+# You can tweak the install behavior by setting variables when running the script. For
138+# example, to change the path to the Oh My Zsh repository:
139+# ZSH=~/.zsh sh install.sh
140+#
141+# Respects the following environment variables:
142+# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
143+# REPO - name of the GitHub repo to install from (default: robbyrussell/oh-my-zsh)
144+# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
145+# BRANCH - branch to check out immediately after install (default: master)
146+#
147+# Other options:
148+# CHSH - 'no' means the installer will not change the default shell (default: yes)
149+# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)
150+#
151+# You can also pass some arguments to the install script to set some these options:
152+# --skip-chsh: has the same behavior as setting CHSH to 'no'
153+# --unattended: sets both CHSH and RUNZSH to 'no'
154+# For example:
155+# sh install.sh --unattended
156+#
157+set -e
158+
159+# Default settings
160+ZSH=${ZSH:-~/.oh-my-zsh}
161+REPO=${REPO:-robbyrussell/oh-my-zsh}
162+REMOTE=${REMOTE:-https://github.com/${REPO}.git}
163+BRANCH=${BRANCH:-master}
164+
165+# Other options
166+CHSH=${CHSH:-yes}
167+RUNZSH=${RUNZSH:-yes}
168+
169+
170+command_exists() {
171+ command -v "$@" >/dev/null 2>&1
172+}
173+
174+error() {
175+ echo ${RED}"Error: $@"${RESET} >&2
176+}
177+
178+# Set up color sequences
179+setup_color() {
180+ ncolors=$(tput colors 2>/dev/null) || ncolors=0
181+
182+ # Only use colors if connected to a terminal that supports them
183+ if [ -t 1 ] && [ $ncolors -ge 8 ]; then
184+ RED="$(tput setaf 1)"
185+ GREEN="$(tput setaf 2)"
186+ YELLOW="$(tput setaf 3)"
187+ BLUE="$(tput setaf 4)"
188+ BOLD="$(tput bold)"
189+ RESET="$(tput sgr0)"
190+ else
191+ RED=$(printf '\033[31m')
192+ GREEN=$(printf '\033[32m')
193+ YELLOW=$(printf '\033[33m')
194+ BLUE=$(printf '\033[34m')
195+ BOLD=$(printf '\033[1m')
196+ RESET=$(printf '\033[m')
197+ fi
198+}
199+
200+setup_ohmyzsh() {
201+ # Prevent the cloned repository from having insecure permissions. Failing to do
202+ # so causes compinit() calls to fail with "command not found: compdef" errors
203+ # for users with insecure umasks (e.g., "002", allowing group writability). Note
204+ # that this will be ignored under Cygwin by default, as Windows ACLs take
205+ # precedence over umasks except for filesystems mounted with option "noacl".
206+ umask g-w,o-w
207+
208+ echo "${BLUE}Cloning Oh My Zsh...${RESET}"
209+
210+ command_exists git || {
211+ error "git is not installed"
212+ exit 1
213+ }
214+
215+ if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
216+ error "Windows/MSYS Git is not supported on Cygwin"
217+ error "Make sure the Cygwin git package is installed and is first on the \$PATH"
218+ exit 1
219+ fi
220+
221+ git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
222+ error "git clone of oh-my-zsh repo failed"
223+ exit 1
224+ }
225diff --git a/tools/uninstall.sh b/tools/uninstall.sh
226index bf2244be859720a99f10052ad64afc1b45978bee..da31a6a14d6520654aa7a4f590cc4a9e7706573f 100644
227--- a/tools/uninstall.sh
228+++ b/tools/uninstall.sh
229@@ -10,25 +10,35 @@ if [ -d ~/.oh-my-zsh ]; then
230 fi
231
232 echo "Looking for original zsh config..."
233-if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]; then
234- echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
235+ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
236+if [ -e "$ZSHRC_ORIG" ]; then
237+ echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
238
239- if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
240- ZSHRC_SAVE=".zshrc.omz-uninstalled-$(date +%Y%m%d%H%M%S)";
241- echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
242- mv ~/.zshrc ~/"${ZSHRC_SAVE}";
243+ if [ -e ~/.zshrc ]; then
244+ ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
245+ echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
246+ mv ~/.zshrc "${ZSHRC_SAVE}"
247 fi
248
249- mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
250+ mv "$ZSHRC_ORIG" ~/.zshrc
251
252- echo "Your original zsh config was restored. Please restart your session."
253-else
254- if hash chsh >/dev/null 2>&1; then
255- echo "Switching back to bash"
256- chsh -s /bin/bash
257+ echo "Your original zsh config was restored."
258+fi
259+
260+if hash chsh >/dev/null 2>&1; then
261+ if [ -f ~/.shell.pre-oh-my-zsh ]; then
262+ old_shell=$(cat ~/.shell.pre-oh-my-zsh)
263+ else
264+ old_shell=/bin/bash
265+ fi
266+ echo "Switching your shell back to '$old_shell':"
267+ if chsh -s "$old_shell"; then
268+ rm -f ~/.shell.pre-oh-my-zsh
269 else
270- echo "You can edit /etc/passwd to switch your default shell back to bash"
271+ echo "Could not change default shell. Change it manually by running chsh"
272+ echo "or editing the /etc/passwd file."
273 fi
274 fi
275
276 echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
277+echo "Don't forget to restart your terminal!"