The preferred answer will work, but also sub-optimal and won't work if you are in an ssh remote linux host, if you follow those instructions you'll have other odd behaviors because it isn't aware of the IPC, for example you can't open a file in an existing vscode window, it will open in a new window - which is both annoying and slow.
The TLDR is you probably want:
https://github.com/chvolkmann/code-connect
I'll try to explain what this does:
There is a ~/.vscode-server where vscode sets up an IPC, if you echo $VSCODE_IPC_HOOK_CLI
you'll see something like:
echo $VSCODE_IPC_HOOK_CLI
/run/user/1000/vscode-ipc-b9c6c65d-7cdb-4169-ba06-caafb62e77f4.sock
The problem is, the path changes for each vscode-server instance, but inside the dir /run/user/1000/xxxx/bin/code
you'll find youur code.
If you find that code, then run code --locate-shell-integration-path bash
you'll see it output where to find the shell hooks, anyway there is a convoluted CLI which uses the VSCODE_IPC_HOOK_CLI + awk and then transmutes this into the vscode path, which is the same thing chvolkmanns code-connect does, so I use that.
once you have code setup at the IPC integration is very slick, you can also:
# add this .bashrc
export EDITOR="code -w -r"
# run this to setup GIT to use vscode
git config --global core.editor "code --new-window --wait"
ln -s "/mnt/c/Users/<username>/AppData/Local/Programs/Microsoft VS Code/bin/code" "/usr/local/bin/code"
I think you should be able to tell which situation you're in by first issuingls "/mnt/c/Program Files/Microsoft VS Code/bin/code"
. If there are no folders/files found, check the AppData/Local path instead and create the link to wherever VS code is installed. – Resolution