3 # This shell script passes all its arguments to the binary inside the
4 # MacVim.app application bundle. If you make links to this script as view,
5 # gvim, etc., then it will peek at the name used to call it and set options
8 # Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
9 # version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
10 # Weber and Bjorn Winckler, Aug 13 2007).
11 # First, check "All the Usual Suspects" for the location of the Vim.app bundle.
12 # You can short-circuit this by setting the VIM_APP_DIR environment variable
13 # or by un-commenting and editing the following line:
14 # VIM_APP_DIR=/Applications
16 if [ -z "$VIM_APP_DIR" ]
18 myDir
="`dirname "$0"`"
19 myAppDir
="$myDir/../Applications"
20 for i
in ~
/Applications ~
/Applications
/vim
$myDir $myDir/vim
$myAppDir $myAppDir/vim
/Applications
/Applications
/vim
/Applications
/Utilities
/Applications
/Utilities
/vim
; do
21 if [ -x "$i/MacVim.app" ]; then
27 if [ -z "$VIM_APP_DIR" ]
29 echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app."
32 binary
="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim"
34 # Next, peek at the name used to invoke this script, and set options
37 name
="`basename "$0"`"
41 # GUI mode, implies forking
42 case "$name" in m
*|g
*|
rm*|rg
*) gui
=true
;; esac
45 case "$name" in r
*) opts
="$opts -Z";; esac
47 # vimdiff, view, and ex mode
60 # Last step: fire up vim.
61 # The program should fork by default when started in GUI mode, but it does
62 # not; we work around this when this script is invoked as "gvim" or "rgview"
63 # etc., but not when it is invoked as "vim -g".
65 # Note: this isn't perfect, because any error output goes to the
66 # terminal instead of the console log.
67 # But if you use open instead, you will need to fully qualify the
68 # path names for any filenames you specify, which is hard.
69 exec "$binary" -g $opts ${1:+"$@"}
71 exec "$binary" $opts ${1:+"$@"}