Skip to content

Instantly share code, notes, and snippets.

@balinterdi
Created February 5, 2012 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balinterdi/1748477 to your computer and use it in GitHub Desktop.
Save balinterdi/1748477 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment