0

I'm using Windows Subsystem for linux and the best text editor experience so far has been VS Code- Insiders with their WSL remote addon. However, despite repeated efforts I've only had partial success in replicating the functionality where within my WSL (zsh) terminal I can type code . or code XX to open a directory in code. I do have a function that works, opening the WSL directory in code insiders, but it does not go through the WSL interface somehow so I am using a powershell/ windows environment where I wanted all linux. This function works to some degree, and is provided.

I tried a simple alias (didn't work because of windows spaces in directory path). This version works - but I then have to ctrl + shift + p -> Remote WSL: Reopen Window In WSL.

function code(){
/mnt/c/Users/camer/AppData/Local/Programs/Microsoft\ VS\ Code\ Insiders/Code\ -\ Insiders.exe $1
}

I'd like the function to work as expected - when run within WSL it opens the windows (.exe) VSCode insiders with a WSL session already.

HaaLeo
  • 10,065
  • 3
  • 44
  • 55

2 Answers2

1

Try putting double quotes around $1.

Always double quote references to variables that are paths or filenames.

0

@Roadowl answered my question in the comments above. For reference I will paste the fixed function for copy/paste. Just change the directory to your path to Insiders on windows.


function code(){
/mnt/c/Users/camer/AppData/Local/Programs/Microsoft\ VS\ Code\ Insiders/Code\ -\ Insiders.exe "$1"
}