1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:40:03 +08:00
SpaceVim/install.sh

79 lines
2.0 KiB
Bash
Raw Normal View History

2017-01-04 00:20:25 +08:00
#!/usr/bin/env bash
#
# Reset
Color_off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Blue='\033[0;34m' # Blue
need_cmd () {
2017-01-04 23:42:54 +08:00
if ! hash "$1" &>/dev/null; then
echo -e "${Red}need '$1' (command not found)${Color_off}"
exit 1
2017-01-04 00:20:25 +08:00
fi
}
fetch_repo () {
2017-01-04 23:42:54 +08:00
if [[ -d "$HOME/.SpaceVim" ]]; then
git -C "$HOME/.SpaceVim" pull
ret=$?
echo -e "${Blue}Successfully update SpaceVim${Color_off}"
2017-01-04 00:20:25 +08:00
else
2017-01-04 23:42:54 +08:00
git clone https://github.com/SpaceVim/SpaceVim.git "$HOME/.SpaceVim"
ret=$?
echo -e "${Blue}Successfully clone SpaceVim${Color_off}"
2017-01-04 00:20:25 +08:00
fi
}
install_vim () {
2017-01-04 23:42:54 +08:00
if [[ -f "$HOME/.vimrc" ]]; then
mv "$HOME/.vimrc" "$HOME/.vimrc_back"
ret=$?
echo -e "${Blue}BackUp $HOME/.vimrc${Color_off}"
2017-01-04 00:20:25 +08:00
fi
2017-01-04 23:42:54 +08:00
if [[ -d "$HOME/.vim" ]]; then
if [[ "$(readlink $HOME/.vim)" =~ \.SpaceVim$ ]]; then
2017-01-04 23:42:54 +08:00
echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
2017-01-04 00:20:25 +08:00
else
2017-01-04 23:42:54 +08:00
mv "$HOME/.vim" "$HOME/.vim_back"
ret=$?
echo -e "${Blue}BackUp $HOME/.vim${Color_off}"
ln -s "$HOME/.SpaceVim" "$HOME/.vim"
echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
2017-01-04 00:20:25 +08:00
fi
else
2017-01-04 23:42:54 +08:00
ln -s "$HOME/.SpaceVim" "$HOME/.vim"
echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
2017-01-04 00:20:25 +08:00
fi
}
install_neovim () {
2017-01-04 23:42:54 +08:00
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.SpaceVim$ ]]; then
2017-01-04 23:42:54 +08:00
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
2017-01-04 00:20:25 +08:00
else
2017-01-04 23:42:54 +08:00
mv "$HOME/.config/nvim" "$HOME/.config/nvim_back"
ret=$?
echo -e "${Blue}BackUp $HOME/.config/nvim${Color_off}"
ln -s "$HOME/.SpaceVim" "$HOME/.config/nvim"
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
2017-01-04 00:20:25 +08:00
fi
else
2017-01-04 23:42:54 +08:00
ln -s "$HOME/.SpaceVim" "$HOME/.config/nvim"
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
2017-01-04 00:20:25 +08:00
fi
}
need_cmd 'git'
fetch_repo
install_vim
install_neovim