|
8 | 8 | # Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This |
9 | 9 | # version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico |
10 | 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 |
| 11 | +# |
15 | 12 |
|
16 | | -if [ -z "$VIM_APP_DIR" ] |
17 | | -then |
18 | | - myDir="`dirname "$0"`" |
19 | | - myAppDir="$myDir/../Applications" |
20 | | - suspects=( |
21 | | - /Applications |
22 | | - ~/Applications |
23 | | - /Applications/vim |
24 | | - ~/Applications/vim |
25 | | - $myDir |
26 | | - $myDir/vim |
27 | | - $myAppDir |
28 | | - $myAppDir/vim |
29 | | - /Applications/Utilities |
30 | | - /Applications/Utilities/vim |
31 | | - ) |
32 | | - for i in ${suspects[@]}; do |
33 | | - if [ -x "$i/MacVim.app" ]; then |
34 | | - VIM_APP_DIR="$i" |
35 | | - break |
36 | | - fi |
| 13 | +# Find Vim executable |
| 14 | +if [ -L $0 ]; then |
| 15 | + # readlink -f |
| 16 | + curdir=`pwd -P` |
| 17 | + self_path=$0 |
| 18 | + cd `dirname $self_path` |
| 19 | + while [ -L $self_path ]; do |
| 20 | + self_path=`readlink $self_path` |
| 21 | + cd `dirname $self_path` |
| 22 | + self_path=`basename $self_path` |
37 | 23 | done |
| 24 | + binary="`pwd -P`/../MacOS/Vim" |
| 25 | + cd $curdir |
| 26 | +else |
| 27 | + binary="`dirname "$0"`/../MacOS/Vim" |
38 | 28 | fi |
39 | | -if [ -z "$VIM_APP_DIR" ] |
40 | | -then |
41 | | - echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app." |
| 29 | +if ! [ -x $binary ]; then |
| 30 | + echo "Sorry, cannot find Vim executable." |
42 | 31 | exit 1 |
43 | 32 | fi |
44 | | -binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim" |
45 | 33 |
|
46 | 34 | # Next, peek at the name used to invoke this script, and set options |
47 | 35 | # accordingly. |
|
0 commit comments