Last active
October 22, 2019 13:30
-
-
Save tylerszabo/57d9f42bd421b12601f2800f92fc3053 to your computer and use it in GitHub Desktop.
Launch GVim from Cygwin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (C) 2018-2019 Tyler Szabo | |
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | |
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
# See <http://www.gnu.org/licenses/>. | |
TEMPFILE_NAME=gvim-`date +%s`-${RANDOM}.bat | |
TEMPFILE=$TMP/$TEMPFILE_NAME | |
TEMPFILE_W=`cygpath --windows --absolute --long-name "$TEMPFILE"` | |
TARGET= | |
if [ "$1" = "" ] ; then | |
TARGET=`cygpath --windows --absolute --long-name "."` | |
else | |
TARGET=`cygpath --windows --absolute --long-name "$@" | tr '\n' ' '` | |
fi | |
WIN_GVIM=`where gvim.exe 2> /dev/null | head -n 1 | tr -d '\r\n'` | |
if [ -n $WIN_GVIM ] ; then | |
WIN_GVIM=`where gvim.bat 2> /dev/null | head -n 1 | tr -d '\r\n'` | |
START_MODE=_nostart | |
fi | |
WIN_GVIM=`cygpath "$WIN_GVIM" --windows --absolute --long-name` | |
unix2dos > $TEMPFILE << EOF | |
goto run$START_MODE | |
:run_nostart | |
"$WIN_GVIM" $TARGET | |
GOTO finish | |
:run | |
START "gvim" "$WIN_GVIM" $TARGET | |
GOTO finish | |
:finish | |
DEL %~f0 | |
EOF | |
chmod +x $TEMPFILE | |
explorer.exe "$TEMPFILE_W" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment