Skip to content

Instantly share code, notes, and snippets.

@avoidik
Forked from nickbudi/README.md
Last active August 28, 2020 10:57
Show Gist options
  • Save avoidik/b5eff961d3978f0581598e206eb66043 to your computer and use it in GitHub Desktop.
Save avoidik/b5eff961d3978f0581598e206eb66043 to your computer and use it in GitHub Desktop.
Cygwin git compatibility with VS Code (or other Windows programs) using cygpath

Cygwin Git + VS Code compatibility

Thanks and credit to mattn and ferreus on GitHub.

Check out wslpath if you're using the Windows Subsystem for Linux.

#!/bin/bash
# wrapper to convert linux paths to windows
# so vscode will work as a git editor with cygwin
# editor="/home/this/file.sh" in .gitconfig
# extract last argument (the file path)
for last; do true; done
# get all the initial command arguments
all="${@:1:$(($#-1))}"
# launch editor with windows path
code $all $(cygpath -w $last)
@echo off
REM wrapper to convert linux paths to windows
REM so vscode git integration will work with cygwin
REM "git.path"="C:\\this\\file.bat" in settings.json
setlocal
set PATH=C:\tools\cygwin\bin;%PATH%
if "%1" equ "rev-parse" goto rev_parse
git %*
goto :eof
:rev_parse
for /f %%1 in ('git %*') do cygpath -w %%1
@avoidik
Copy link
Author

avoidik commented Mar 30, 2020

{
    "terminal.integrated.shell.windows": "C:\\tools\\cygwin\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": [
        "--login",
        "-i"
    ],
    "terminal.integrated.env.windows": {
        "CHERE_INVOKING": "1"
    },
    "git.path": "C:\\tools\\cygwin\\cygpath-git-vscode.cmd"
}
git config --global user.name "Mona Lisa"
git config --global user.email "[email protected]"
git config --global core.editor cygpath-git-editor.sh
git config --global core.autocrlf true # input for linux/mac
git config --global credential.helper store
git config --system core.longpaths true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment