Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
f9444392
Commit
f9444392
authored
May 30, 2016
by
Marc Cornellà
Browse files
installer: reorganise and add comments
parent
73ef051a
Changes
1
Show whitespace changes
Inline
Side-by-side
tools/install.sh
View file @
f9444392
#!/bin/sh
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
#
# As an alternative, you can download the install script separately and
# run it afterwards with `sh install.sh'
#
set
-e
set
-e
# Test command existence (POSIX compatible)
# Default location
ZSH
=
${
ZSH
:-
~/.oh-my-zsh
}
command_exists
()
{
command_exists
()
{
command
-v
"
$@
"
>
/dev/null 2>&1
command
-v
"
$@
"
>
/dev/null 2>&1
}
}
...
@@ -30,17 +41,15 @@ main() {
...
@@ -30,17 +41,15 @@ main() {
fi
fi
if
!
command_exists zsh
;
then
if
!
command_exists zsh
;
then
printf
"
${
YELLOW
}
Zsh is not installed!
${
NORMAL
}
Please install zsh first!
\n
"
echo
"
${
YELLOW
}
Zsh is not installed!
${
NORMAL
}
Please install zsh first!"
exit
1
exit
1
fi
fi
if
[
!
-n
"
$ZSH
"
]
;
then
ZSH
=
~/.oh-my-zsh
fi
if
[
-d
"
$ZSH
"
]
;
then
if
[
-d
"
$ZSH
"
]
;
then
printf
"
${
YELLOW
}
You already have Oh My Zsh installed.
${
NORMAL
}
\n
"
cat
<<-
EOF
printf
"You'll need to remove
$ZSH
if you want to re-install.
\n
"
${
YELLOW
}
You already have Oh My Zsh installed.
${
NORMAL
}
You'll need to remove
$ZSH
if you want to re-install.
EOF
exit
1
exit
1
fi
fi
...
@@ -51,31 +60,34 @@ main() {
...
@@ -51,31 +60,34 @@ main() {
# precedence over umasks except for filesystems mounted with option "noacl".
# precedence over umasks except for filesystems mounted with option "noacl".
umask
g-w,o-w
umask
g-w,o-w
printf
"
${
BLUE
}
Cloning Oh My Zsh...
${
NORMAL
}
\n
"
echo
"
${
BLUE
}
Cloning Oh My Zsh...
${
NORMAL
}
"
command_exists git
||
{
command_exists git
||
{
echo
"Error: git is not installed"
echo
"Error: git is not installed"
exit
1
exit
1
}
}
# The Windows (MSYS) Git is not compatible with normal use on cygwin
if
[
"
$OSTYPE
"
=
cygwin
]
;
then
if
[
"
$OSTYPE
"
=
cygwin
]
&&
git
--version
|
grep
-q
msysgit
;
then
if
git
--version
|
grep
msysgit
>
/dev/null
;
then
cat
<<-
EOF
echo
"Error: Windows/MSYS Git is not supported on Cygwin"
Error: Windows/MSYS Git is not supported on Cygwin
echo
"Error: Make sure the Cygwin git package is installed and is first on the path"
Error: Make sure the Cygwin git package is installed and is first on the
$PATH
EOF
exit
1
exit
1
fi
fi
fi
env
git clone
--depth
=
1 https://github.com/robbyrussell/oh-my-zsh.git
"
$ZSH
"
||
{
git clone
--depth
=
1 https://github.com/robbyrussell/oh-my-zsh.git
"
$ZSH
"
||
{
printf
"Error: git clone of oh-my-zsh repo failed
\n
"
echo
"Error: git clone of oh-my-zsh repo failed"
exit
1
exit
1
}
}
printf
"
${
BLUE
}
Looking for an existing zsh config...
${
NORMAL
}
\n
"
echo
"
${
BLUE
}
Looking for an existing zsh config...
${
NORMAL
}
"
if
[
-f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
if
[
-f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
printf
"
${
YELLOW
}
Found ~/.zshrc.
${
NORMAL
}
${
GREEN
}
Backing up to ~/.zshrc.pre-oh-my-zsh
${
NORMAL
}
\n
"
;
echo
"
${
YELLOW
}
Found ~/.zshrc.
${
GREEN
}
Backing up to ~/.zshrc.pre-oh-my-zsh
.
${
NORMAL
}
"
mv
~/.zshrc ~/.zshrc.pre-oh-my-zsh
;
mv
~/.zshrc ~/.zshrc.pre-oh-my-zsh
;
fi
fi
printf
"
${
BLUE
}
Using the Oh My Zsh template file and adding it to ~/.zshrc
${
NORMAL
}
\n
"
echo
"
${
BLUE
}
Using the Oh My Zsh template file and adding it to ~/.zshrc.
${
NORMAL
}
"
cp
"
$ZSH
/templates/zshrc.zsh-template"
~/.zshrc
cp
"
$ZSH
/templates/zshrc.zsh-template"
~/.zshrc
sed
"/^export ZSH=/ c
\\
sed
"/^export ZSH=/ c
\\
export ZSH=
\"
$ZSH
\"
export ZSH=
\"
$ZSH
\"
...
@@ -87,31 +99,36 @@ export ZSH=\"$ZSH\"
...
@@ -87,31 +99,36 @@ export ZSH=\"$ZSH\"
if
[
"
$TEST_CURRENT_SHELL
"
!=
"zsh"
]
;
then
if
[
"
$TEST_CURRENT_SHELL
"
!=
"zsh"
]
;
then
# If this platform provides a "chsh" command (not Cygwin), do it, man!
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if
command_exists chsh
;
then
if
command_exists chsh
;
then
printf
"
${
BLUE
}
Time to change your default shell to zsh!
${
NORMAL
}
\n
"
echo
"
${
BLUE
}
Time to change your default shell to zsh!
${
NORMAL
}
"
chsh
-s
$(
grep
/zsh
$
/etc/shells |
tail
-1
)
chsh
-s
$(
grep
/zsh
$
/etc/shells |
tail
-1
)
# Else, suggest the user do so manually.
# Else, suggest the user do so manually.
else
else
printf
"I can't change your shell automatically because this system does not have chsh.
\n
"
cat
<<-
EOF
printf
"
${
BLUE
}
Please manually change your default shell to zsh!
${
NORMAL
}
\n
"
I can't change your shell automatically because this system does not have chsh.
${
BLUE
}
Please manually change your default shell to zsh
${
NORMAL
}
EOF
fi
fi
fi
fi
printf
"
${
GREEN
}
"
printf
"
$GREEN
"
echo
' __ __ '
cat
<<-
'
EOF
'
echo
' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
__ __
echo
' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
____ / /_ ____ ___ __ __ ____ _____/ /_
echo
'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
/ __
\/
__
\
/ __ `__
\/
/ / / /_ / / ___/ __
\
echo
'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
echo
' /____/ ....is now installed!'
\_
___/_/ /_/ /_/ /_/ /_/
\_
_, / /___/____/_/ /_/
echo
''
/____/ ....is now installed!
echo
''
echo
'Please look over the ~/.zshrc file to select plugins, themes, and options.'
echo
''
Please look over the ~/.zshrc file to select plugins, themes, and options.
echo
'p.s. Follow us at https://twitter.com/ohmyzsh'
echo
''
p.s. Follow us on https://twitter.com/ohmyzsh
echo
'p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh'
echo
''
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
printf
"
${
NORMAL
}
"
EOF
printf
"
$NORMAL
"
env
zsh
-l
env
zsh
-l
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment