Skip to content

Instantly share code, notes, and snippets.

@kena0ki
Last active April 2, 2020 04:11
Show Gist options
  • Save kena0ki/a46e15fe118250db71dc53150ac49c80 to your computer and use it in GitHub Desktop.
Save kena0ki/a46e15fe118250db71dc53150ac49c80 to your computer and use it in GitHub Desktop.
install vim from source on MacOS 10.15.4 with python3 and ruby

Prerequirments

  • Xcode command line tools.
  • Python3.
  • Ruby Stable.

Install or Update Vim

Run following script.

#!/bin/zsh -eu

echo -n "Input work directory (default to home) >> "
read WORKDIR
echo
test -z "$WORKDIR" && WORKDIR=~
test ! -e "$WORKDIR" && mkdir "$WORKDIR"
LOGFILE="$PWD"/"$WORKDIR"/vim/viminstall.log

cd "$WORKDIR"
test ! -e vim && git clone https://github.com/vim/vim.git
cd vim
git pull
make distclean # if you build Vim before
#PYTHON3CONF=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin # for python3 installed by offcial website
PYTHON3CONF=/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin # for python3 installed using homebrew
./configure \
  --enable-multibyte \
  --enable-perlinterp=dynamic \
  --enable-rubyinterp=dynamic \
  --with-ruby-command=`which ruby` \
  --enable-python3interp \
  --with-python3-config-dir="$PYTHON3CONF" \
  --enable-cscope \
  --enable-gui=auto \
  --with-features=huge \
  --enable-fontset \
  --enable-largefile \
  --disable-netbeans \
  --enable-fail-if-missing \
  --prefix=/usr/local | tee "$LOGFILE"
  # --with-x \ # X11 is no longer included with Mac. https://support.apple.com/en-gb/HT201341
echo
echo -n "OK to make? Hit Enter to continue."; read A
make >> "$LOGFILE"
cd src
./vim --version
echo -n "OK to make install? Hit Enter to continue."; read A
VIMPATH=`which vim`
if [ -n $VIMPATH ]; then
 BKUPPATH="$VIMPATH"`date +%s`
 sudo cp -p "$VIMPATH" "$VIMPATH"`date +%s` # back up current vim
 echo "Old vim was backed up to $BKUPPATH."
fi
sudo make install >> "$LOGFILE"
echo
echo "Done!! Log file: $LOGFILE"

exit

See also

https://gist.github.com/misraX/7ff0483ecaf84d476c194730740d6abe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment