Last active
December 6, 2024 08:37
-
-
Save phoehnel/04ece56e055ce271d99c088680139c1f to your computer and use it in GitHub Desktop.
"left-click" open files in WSL vsCode on Windows
This file contains hidden or 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
:: This script solves the Problem, that opening files in vsCode from Windows will | |
:: always open them in a local Windows Workspace, even if your default Workspace is in WSL. | |
:: To get around this, this script passes the called Path to the code executable inside WSL. | |
:: How to Use: | |
:: 1. Place this Script in a persistent location on as Windows Computer (e.g. your home-dir) | |
:: 2. Right-Click a file in Windows, Choose "Open with" > "Other Program" | |
:: 3. At the very bottom choose "Select an App from your Computer" and locate this .bat file | |
:: --> Windows will open the file directly in WSL vsCode | |
@Echo Off | |
wsl.exe --cd "%__CD__:~,-1%" code "%~nx1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone knows a way to keep the VSCode icon while using this workaround, I would greatly appreciate it if you could reach out!