Skip to content

Instantly share code, notes, and snippets.

@ctataryn
Last active January 24, 2020 17:34
Show Gist options
  • Save ctataryn/6bc5242752833872ddb883c2562fb31d to your computer and use it in GitHub Desktop.
Save ctataryn/6bc5242752833872ddb883c2562fb31d to your computer and use it in GitHub Desktop.
A script that lets you execute gVim for Windows within WSL
#!/bin/bash
#################################################################
# place this script on your $PATH and chmod it to be executable
#################################################################
# assumes C:\ is mounted to /c, change any occurance of /c to /mnt/c if
# you are using the default WSL mount point for C:\
CMD='/c/Windows/System32/cmd.exe'
#location of gvim
GVIM='/c/Program Files (x86)/Vim/vim81/gvim.exe'
FILE=`realpath "${1:-.}"`
if [[ $FILE == /c/* ]] ;
then
FILE=${FILE/\/c\//C:\\}
else
# replace the first forward slash
FILE=${FILE/\//\\\\wsl\$\\Ubuntu\\}
fi
# replace the rest
FILE=${FILE//\//\\}
echo Launch gvim for file: $FILE
`"$GVIM" $FILE` &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment