diff --git a/utils/install-vim.sh b/utils/install-vim.sh new file mode 100755 index 0000000000000000000000000000000000000000..bd951377b99f9165b0b6efea5fa3ad1ed80f04f7 --- /dev/null +++ b/utils/install-vim.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +echo -e "正在安装vim插件到你的家目录(~/)..." +echo -e "注意:此操作将会覆盖你原本的~/.vim目录" +echo -e "是否继续(yes/no)?" +read yesorno +echo -e "你选择了 ${yesorno}" + +HOME_VIM_DIR=~/.vim +HOME_VIMRC_DIR=~/.vimrc +HOME_VIM_BK_DIR=~/.vim-bk +HOME_VIMRC_BK_DIR=~/.vimrc-bk + + +if [ "$yesorno" = "y" ] || [ "$yesorno" = "yes" ] ; then + + # 复制安装 + if [ -e ./home/vim ] && [ -e ./home/vimrc ] ; then + # 备份~/.vim + if [ -e ${HOME_VIM_DIR} ]; then + if [ -e ${HOME_VIM_BK_DIR} ] ; then + rm -rf ${HOME_VIM_BK_DIR} + fi + mv ${HOME_VIM_DIR} ${HOME_VIM_BK_DIR} + fi + + # 备份~/.vimrc + if [ -e ${HOME_VIMRC_DIR} ]; then + if [ -e ${HOME_VIMRC_BK_DIR} ] ; then + rm -rf ${HOME_VIMRC_BK_DIR} + fi + mv ${HOME_VIMRC_DIR} ${HOME_VIMRC_BK_DIR} + fi + + #复制安装 + cp -r ./home/vim ~/.vim + cp ./home/vimrc ~/.vimrc + + exit 0 + else + echo -e "执行路径不对!请确保在仓库顶层目录执行:" + echo -e "./utils/install-vim.sh" + fi +elif [ "$yesorno" = "n" ] || [ "$yesorno" = "no" ] ; then + echo -e "取消安装" + + exit 0 +else + echo -e "只能输入\"yes\",\"y\",\"no\",\"n\"." + echo -e "终止安装" + + exit 1 +fi +