public
Created

  • Download Gist
mvim_patch_tabs
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
diff --git a/src/MacVim/mvim b/src/MacVim/mvim
index 653cf78..5e6b0d7 100755
--- a/src/MacVim/mvim
+++ b/src/MacVim/mvim
@@ -13,6 +13,11 @@
# or by un-commenting and editing the following line:
# VIM_APP_DIR=/Applications
+tabs=true
+if [ "$1" = "-f" ]; then
+ tabs=false
+fi
+
if [ -z "$VIM_APP_DIR" ]
then
myDir="`dirname "$0"`"
@@ -36,7 +41,7 @@ binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim"
name="`basename "$0"`"
gui=
-opts=
+opts="-n"
# GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac
@@ -62,11 +67,23 @@ esac
# 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:+"$@"}
+ if $tabs && [[ `$binary --serverlist` = "VIM" ]]; then
+ if [ $# -eq 0 ]; then
+ exec "$binary" -g $opts --remote-tab-silent +edit .
+ else
+ exec "$binary" -g $opts --remote-tab-silent ${1:+"$@"}
+ fi
+ else
+ # 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.
+ if [ $# -eq 0 ]; then
+ exec "$binary" -g $opts .
+ else
+ exec "$binary" -g $opts ${1:+"$@"}
+ fi
+ fi
else
exec "$binary" $opts ${1:+"$@"}
fi

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.