These scripts allow you to proxy commands (specifically git
, in this example) to the Windows Subsystem for Linux from the normal Windows command line environment. This allows you to work with a single installation of git (under your Linux distribution) instead of trying to manage two concurrent installations.
I explicitly created these scripts to allow using Git in Visual Studio Code without installing it under Windows.
Please note that I have not extensively tested edge cases! If you run into problems, please let me know!
- Install the scripts somewhere on your normal Windows drive; e.g.
C:\Users\USERNAME\dev\proxy_scripts
. - In VSC, modify your
settings.json
file and add thegit.path
setting pointing to yourgit.bat
file; e.g."git.path": "c:\\Users\\USERNAME\\dev\\proxy_scripts\\git.bat"
- Enjoy WSL git from the VSC GUI! (You might need to relaunch the app.)
If you want to proxy further commands, you can do so by duplicating git.bat
and changing the command that is getting invoked (so replace git
on line 6 with whatever command you want to proxy). Presumably, you could also add these scripts to your Windows PATH if you wanted to go the extra mile, though I'm not sure how that would interact with the WSL bash.exe
environment (could end up round-tripping everything uselessly, if your Windows binary locations occur earlier in the PATH than the WSL ones).
Please enjoy responsibly!
wsl-alias
offered a fantastic starting point for this approach and is a nifty project all around: https://github.com/leongrdic/wsl-aliaswsl-proxy
gave me the initial inspiration for writing simple proxy batch files: https://github.com/watzon/wsl-proxy
Hey,
Thanks for sharing script - it is really nice and seems to be working for VSC!
I have tried to use Git this way not only for VSC, but globally for Windows.
I have added proxy_script directory to PATH environment and command git is recognizable across multiple shells: ie. powershell.
However, I have the problem with making commands which chars like ' and "
For example: git commit
results in error like:
Error may be solved by commenting
in _proxy_cmd.bat, however I am not sure if this will not break something else.
Is there a reason why these characters have been added to the mapping as well?