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
43b3126b
Commit
43b3126b
authored
Sep 23, 2015
by
Andrew Janke
Committed by
Marc Cornellà
Jun 03, 2019
Browse files
installer: use timestamped backups to preserve all old zshrcs
parent
153f5e11
Changes
2
Show whitespace changes
Inline
Side-by-side
tools/install.sh
View file @
43b3126b
...
@@ -84,10 +84,28 @@ setup_ohmyzsh() {
...
@@ -84,10 +84,28 @@ setup_ohmyzsh() {
}
}
setup_zshrc
()
{
setup_zshrc
()
{
# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
# with datestamp of installation that moved them aside, so we never actually
# destroy a user's original zshrc
echo
"
${
BLUE
}
Looking for an existing zsh config...
${
RESET
}
"
echo
"
${
BLUE
}
Looking for an existing zsh config...
${
RESET
}
"
# Must use this exact name so uninstall.sh can find it
OLD_ZSHRC
=
~/.zshrc.pre-oh-my-zsh
if
[
-f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
if
[
-f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
echo
"
${
YELLOW
}
Found ~/.zshrc.
${
GREEN
}
Backing up to ~/.zshrc.pre-oh-my-zsh.
${
RESET
}
"
if
[
-e
"
$OLD_ZSHRC
"
]
;
then
mv
~/.zshrc ~/.zshrc.pre-oh-my-zsh
OLD_OLD_ZSHRC
=
"
${
OLD_ZSHRC
}
-
$(
date
+%Y-%m-%d_%H-%M-%S
)
"
if
[
-e
"
$OLD_OLD_ZSHRC
"
]
;
then
error
"
$OLD_OLD_ZSHRC
exists. Can't back up
${
OLD_ZSHRC
}
"
error
"re-run the installer again in a couple of seconds"
exit
1
fi
mv
"
$OLD_ZSHRC
"
"
${
OLD_OLD_ZSHRC
}
"
echo
"
${
YELLOW
}
Found old ~/.zshrc.pre-oh-my-zsh."
\
"
${
GREEN
}
Backing up to
${
OLD_OLD_ZSHRC
}${
RESET
}
"
fi
echo
"
${
YELLOW
}
Found ~/.zshrc.
${
RESET
}
${
GREEN
}
Backing up to
${
OLD_ZSHRC
}${
RESET
}
"
mv
~/.zshrc
"
$OLD_ZSHRC
"
fi
fi
echo
"
${
BLUE
}
Using the Oh My Zsh template file and adding it to ~/.zshrc.
${
RESET
}
"
echo
"
${
BLUE
}
Using the Oh My Zsh template file and adding it to ~/.zshrc.
${
RESET
}
"
...
...
tools/uninstall.sh
View file @
43b3126b
...
@@ -10,16 +10,17 @@ if [ -d ~/.oh-my-zsh ]; then
...
@@ -10,16 +10,17 @@ if [ -d ~/.oh-my-zsh ]; then
fi
fi
echo
"Looking for original zsh config..."
echo
"Looking for original zsh config..."
if
[
-f
~/.zshrc.pre-oh-my-zsh
]
||
[
-h
~/.zshrc.pre-oh-my-zsh
]
;
then
ZSHRC_ORIG
=
~/.zshrc.pre-oh-my-zsh
echo
"Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc"
;
if
[
-e
"
$ZSHRC_ORIG
"
]
;
then
echo
"Found
$ZSHRC_ORIG
-- Restoring to ~/.zshrc"
if
[
-
f
~/.zshrc
]
||
[
-h
~/.zshrc
]
;
then
if
[
-
e
~/.zshrc
]
;
then
ZSHRC_SAVE
=
"
.zshrc.omz-uninstalled-
$(
date
+%Y%m%d%H%M%S
)
"
;
ZSHRC_SAVE
=
~/
.zshrc.omz-uninstalled-
$(
date
+%Y
-
%m
-
%d
_
%H
-
%M
-
%S
)
echo
"Found ~/.zshrc -- Renaming to
~/
${
ZSHRC_SAVE
}
"
;
echo
"Found ~/.zshrc -- Renaming to
${
ZSHRC_SAVE
}
"
mv
~/.zshrc
~/
"
${
ZSHRC_SAVE
}
"
;
mv
~/.zshrc
"
${
ZSHRC_SAVE
}
"
fi
fi
mv
~/.zshrc.pre-oh-my-zsh
~/.zshrc
;
mv
"
$ZSHRC_ORIG
"
~/.zshrc
echo
"Your original zsh config was restored. Please restart your session."
echo
"Your original zsh config was restored. Please restart your session."
else
else
...
...
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