forked from SethMilliken/binfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mvim
executable file
·113 lines (104 loc) · 2.89 KB
/
mvim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
#
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).
# First, check "All the Usual Suspects" for the location of the Vim.app bundle.
# You can short-circuit this by setting the VIM_APP_DIR environment variable
# or by un-commenting and editing the following line:
# VIM_APP_DIR=/Applications
# Peek at the name used to invoke this script, and set options
# accordingly.
name="`basename "$0"`"
gui=
opts=""
# GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac
# Nofork
case "$name" in *n) opts="$opts -f";; esac
# Restricted mode
case "$name" in r*) opts="$opts -Z";; esac
macvimName="MacVim.app"
# vimdiff, view, and ex mode
case "$name" in
*vimdiff)
opts="$opts -dO"
;;
*view)
opts="$opts -R"
;;
*ex)
opts="$opts -e"
;;
*tvim)
macvimName="Tasks.app"
opts="$opts --remote-tab-wait-silent"
gui=true
;;
*svim)
macvimName="SourceCode.app"
opts="$opts --remote-tab-wait-silent"
gui=true
;;
*hvim)
macvimName="Research.app"
opts="$opts --remote-tab-wait-silent"
gui=true
;;
*dvim)
macvimName="Todo.app"
opts="$opts --remote-tab-wait-silent"
gui=true
;;
*wvim)
macvimName="Vimwiki.app"
opts="$opts --remote-tab-wait-silent"
gui=true
;;
*vimperator)
macvimName="Scratch.app"
opts="$opts --remote-tab-wait-silent"
gui=true
;;
gvimdiff)
macvimName="MacVim.app"
opts="$opts --remote-tab-silent"
gui=true
;;
esac
if [ -z "$VIM_APP_DIR" ]
then
myDir="`dirname "$0"`"
myAppDir="$myDir/../Applications"
for i in ~/Applications ~/Applications/vim $myDir $myDir/vim $myAppDir $myAppDir/vim /Applications /Applications/vim /Applications/Utilities /Applications/Utilities/vim; do
if [ -x "$i/$macvimName" ]; then
VIM_APP_DIR="$i"
break
fi
done
fi
binary="$VIM_APP_DIR/$macvimName/Contents/MacOS/Vim"
if [ -z "$VIM_APP_DIR" ]
then
# echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app."
binary=`which vim`
name=vim
fi
# Last step: fire up vim.
# The program should fork by default when started in GUI mode, but it does
# not; we work around this when this script is invoked as "gvim" or "rgview"
# etc., but not when it is invoked as "vim -g".
if [ "$gui" ]; then
# Note: this isn't perfect, because any error output goes to the
# terminal instead of the console log.
# But if you use open instead, you will need to fully qualify the
# path names for any filenames you specify, which is hard.
exec "$binary" -g $opts ${1:+"$@"}
else
exec "$binary" $opts ${1:+"$@"}
fi