Skip to content

Instantly share code, notes, and snippets.

@andru255
Last active February 1, 2018 05:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andru255/7640d92e8df6d1e4515c to your computer and use it in GitHub Desktop.
Save andru255/7640d92e8df6d1e4515c to your computer and use it in GitHub Desktop.

IMPORTANT NOTE: Tested in macOS

For use this bash it needs run in the $HOME folder and execute this command:

~ sudo chmod +x install_vim.sh

Then:

~ ./install_vim.sh

or:

~ bash install_vim.sh

If pass problems in the instalation can be pass the param "--uninstall" for remove the source folder and the program

~ bash install_vim.sh --uninstall

Motivations: https://gist.github.com/andru255/7176142

#!/bin/bash
#Script to install vim 7.4.803 from the vim mirror hosted in github
release="8.0.1451"
version="v${release}"
foldername="vim-${release}"
url="https://github.com/vim/vim/archive/$version.tar.gz"
uninstall_flag=$1
function main {
if [[ $uninstall_flag == "--uninstall" ]]; then
uninstall_vim
else
install_vim
install_success
fi
}
function install_vim {
echo "-->Go $HOME"
cd $HOME
echo "-->Creating the vim folder..."
mkdir vim
echo "-->Go to the created vim folder..."
cd $HOME/vim
echo "-->Invoque and untar from the mirror hosted in github ${url}"
curl -L $url | tar zx
echo "-->Go to to $foldername folder"
cd "$foldername"
echo "-->Cleaning existing build"
make distclean
echo "-->Executing And build with the default settings"
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp \
--enable-pythoninterp \
--with-python-config-dir=/usr/lib/python2.7/config \
--enable-fail-if-missing \
--enable-cscope
echo "-->creating the backup of /usr/bin/vim"
sudo mv /usr/bin/vim /usr/bin/vim-old
echo "-->Execute the installer with superuser mode, "
echo "-->basically the binary copy to the path /usr/local/bin"
sudo make install
echo "-->creating the /usr/local/bin link"
sudo ln -s /usr/local/bin/vim /usr/bin/vim
echo "-->Exporting the current path"
export PATH=/usr/local/bin:$PATH
echo "-->Go to $HOME path"
cd $HOME
echo "-->done!"
}
function uninstall_vim {
read -p "Are you sure to uninstall vim? (y/n)" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "-->Go to source folder"
cd "$HOME/vim/vim-$release"
echo "-->uninstalling..."
sudo make uninstall
echo "-->Welcome back old vim"
sudo mv /usr/bin/vim-old /usr/bin/vim
cd $HOME
sudo rm -fr "$HOME/vim/$foldername"
echo "-->done."
else
exit 1
fi
}
function install_success {
echo "-->vim has been successfully installed :D"
vim --version
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment