1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 20:10:05 +08:00

Improve install script

This commit is contained in:
wsdjeg 2017-01-07 00:31:30 +08:00
parent 1bf75fdfe7
commit 1e1f23f4d0

View File

@ -18,11 +18,9 @@ need_cmd () {
fetch_repo () { fetch_repo () {
if [[ -d "$HOME/.SpaceVim" ]]; then if [[ -d "$HOME/.SpaceVim" ]]; then
git -C "$HOME/.SpaceVim" pull git -C "$HOME/.SpaceVim" pull
ret=$?
echo -e "${Blue}Successfully update SpaceVim${Color_off}" echo -e "${Blue}Successfully update SpaceVim${Color_off}"
else else
git clone https://github.com/SpaceVim/SpaceVim.git "$HOME/.SpaceVim" git clone https://github.com/SpaceVim/SpaceVim.git "$HOME/.SpaceVim"
ret=$?
echo -e "${Blue}Successfully clone SpaceVim${Color_off}" echo -e "${Blue}Successfully clone SpaceVim${Color_off}"
fi fi
} }
@ -30,7 +28,6 @@ fetch_repo () {
install_vim () { install_vim () {
if [[ -f "$HOME/.vimrc" ]]; then if [[ -f "$HOME/.vimrc" ]]; then
mv "$HOME/.vimrc" "$HOME/.vimrc_back" mv "$HOME/.vimrc" "$HOME/.vimrc_back"
ret=$?
echo -e "${Blue}BackUp $HOME/.vimrc${Color_off}" echo -e "${Blue}BackUp $HOME/.vimrc${Color_off}"
fi fi
@ -39,7 +36,6 @@ install_vim () {
echo -e "${Blue}Installed SpaceVim for vim${Color_off}" echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
else else
mv "$HOME/.vim" "$HOME/.vim_back" mv "$HOME/.vim" "$HOME/.vim_back"
ret=$?
echo -e "${Blue}BackUp $HOME/.vim${Color_off}" echo -e "${Blue}BackUp $HOME/.vim${Color_off}"
ln -s "$HOME/.SpaceVim" "$HOME/.vim" ln -s "$HOME/.SpaceVim" "$HOME/.vim"
echo -e "${Blue}Installed SpaceVim for vim${Color_off}" echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
@ -56,7 +52,6 @@ install_neovim () {
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}" echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
else else
mv "$HOME/.config/nvim" "$HOME/.config/nvim_back" mv "$HOME/.config/nvim" "$HOME/.config/nvim_back"
ret=$?
echo -e "${Blue}BackUp $HOME/.config/nvim${Color_off}" echo -e "${Blue}BackUp $HOME/.config/nvim${Color_off}"
ln -s "$HOME/.SpaceVim" "$HOME/.config/nvim" ln -s "$HOME/.SpaceVim" "$HOME/.config/nvim"
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}" echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
@ -67,12 +62,83 @@ install_neovim () {
fi fi
} }
uninstall_vim () {
if [[ -d "$HOME/.vim" ]]; then
if [[ "$(readlink $HOME/.vim)" =~ \.SpaceVim$ ]]; then
rm "$HOME/.vim"
echo -e "${Blue}Uninstall SpaceVim for vim${Color_off}"
if [[ -d "$HOME/.vim_back" ]]; then
mv "$HOME/.vim_back" "$HOME/.vim"
echo -e "${Blue}Recover $HOME/.vim${Color_off}"
fi
fi
fi
if [[ -f "$HOME/.vimrc_back" ]]; then
mv "$HOME/.vimrc_back" "$HOME/.vimrc"
echo -e "${Blue}Recover $HOME/.vimrc${Color_off}"
fi
}
uninstall_neovim () {
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.SpaceVim$ ]]; then
rm "$HOME/.config/nvim"
echo -e "${Blue}Uninstall SpaceVim for neovim${Color_off}"
if [[ -d "$HOME/.config/nvim_back" ]]; then
mv "$HOME/.config/nvim_back" "$HOME/.config/nvim"
echo -e "${Blue}Recover $HOME/.config/nvim${Color_off}"
fi
fi
fi
}
usage () {
echo "SpaceVim install script : V 0.1.0-dev"
echo " Install SpaceVim for vim and neovim"
echo " curl -sLf https://raw.githubusercontent.com/SpaceVim/SpaceVim/dev/install.sh | bash"
echo " Install SpaceVim for vim only or neovim only"
echo " curl -sLf https://raw.githubusercontent.com/SpaceVim/SpaceVim/dev/install.sh | bash -s -- install vim"
echo " or"
echo " curl -sLf https://raw.githubusercontent.com/SpaceVim/SpaceVim/dev/install.sh | bash -s -- install neovim"
echo " Uninstall SpaceVim"
echo " curl -sLf https://raw.githubusercontent.com/SpaceVim/SpaceVim/dev/install.sh | bash -s -- uninstall"
}
if [ $# -gt 0 ]
then
case $1 in
uninstall)
uninstall_vim
uninstall_neovim
exit 0
;;
install)
need_cmd 'git' need_cmd 'git'
fetch_repo fetch_repo
if [ $# -eq 2 ]
install_vim then
case $2 in
neovim)
install_neovim
exit 0
;;
vim)
install_vim
exit 0
esac
fi
install_vim
install_neovim
exit 0
;;
-h)
usage
exit 0
esac
fi
# if no argv, installer will install SpaceVim
need_cmd 'git'
fetch_repo
install_vim
install_neovim install_neovim