+# run vim or drop file in parent vim instance if inside vim terminal
+function vim {
+    if [[ -z "${VIM_TERMINAL}" ]]; then
+        # Not in VIM_TERMINAL, simply run vim with all arguments
+        command vim "$@"
+        return
+    fi
+
+    for f in "$@"; do
+        if [[ "${f:0:1}" == "-" ]]; then
+            echo "Running in Vim's terminal, not accepting options!" >&2
+            return 1
+        fi
+    done
+    for f in "$@"; do
+        # drop the file onto the running vim instance
+        # see :h terminal-communication
+        echo -e "\e]51;[\"drop\", \"$f\"]\a"
+    done
+}