Include a script to install macvim as system/user level vim commands
Instructions: Replace the template text and remove irrelevant text (including this line)
Is your feature request about something that is currently impossible or hard to do? Please describe the problem. Include a script to MacVim installation for users to use MacVim as system or user level vim commands (vim, view, vimdiff, etc.)
Describe the solution you'd like Include a script to MacVim installation, maybe in /Application/MacVim/Contents/scripts/install_macvim_links
The script could look like:
#!/bin/sh
MVIM_DIR="/Applications/MacVim.app/Contents/bin"
DEST_DIR="$HOME/.local/bin"
mkdir -p "$DEST_DIR"
(
cd "$MVIM_DIR" || {
echo "Cannot change to dir $MVIM_DIR"
exit 2
}
for fn in vim vimdiff view gvim gvimdiff gview; do
target="$(pwd)/$fn"
echo "Linking $target into $DEST_DIR..."
ln -sf "$target" "$DEST_DIR"
done
)
Describe alternatives you've considered Leave the suffer to the users
Additional context https://superuser.com/a/1697239/114255
I use following in my zshrc. It sets alias vim default to GUI MacVim if no ssh connection and not root. If GUI MacVim is used, EDITOR set to wait MacVim in foreground.
I don't use MacVim executable for execution from command line as something with -f didn't work back in the day.
unset _mvim
if [[ "$UID" -ne 0 && -z "${SSH_CLIENT}" && -z "${SSH_CONNECTION}" && -z ${SSH_TTY} ]]; then
_mvim=/Applications/MacVim.app/Contents/MacOS/MacVim
fi
# try to alias vim to MacVim GUI, and to terminal vim otherwise
alias_executable vim $_mvim /Applications/MacVim.app/Contents/MacOS/Vim /opt/local/bin/vim /usr/local/bin/vim /usr/bin/vim /bin/vim vim vi
_mvim=$(whence vim)
if [[ $_mvim == "/Applications/MacVim.app/Contents/MacOS/MacVim" ]]; then
alias vim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
export EDITOR="$(whence vim) -f"
else
_mvim=$(whence vim)
if [[ -n $_mvim ]]; then
export EDITOR=$_mvim
fi
fi
unset _mvim