You may have both stable and insiders releases of Visual Studio Code installed. If you're like me, you'll end up trying to open a file with the code
command when you meant code-insiders
. This little edit makes it so that the code
script knows that and opens it in the right place for you.
- Make sure to have installed the
code
andcode-insiders
command into your path by using the command palette - Edit the
code
command (e.g.code "$(which code)"
) - Add the following to the script, after the remote terminal handling but before everything else:
IS_VS_CODE_RUNNING="$(test "$(ps aux | grep "/[A]pplications/Visual Studio Code.app/Contents/MacOS/Electron")" && echo 1 || echo 0)"
IS_VS_CODE_INSIDERS_RUNNING="$(test "$(ps aux | grep "/[A]pplications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron")" && echo 1 || echo 0)"
if [ $IS_VS_CODE_RUNNING -eq 0 ] && [ $IS_VS_CODE_INSIDERS_RUNNING -eq 1 ]; then
# VS Code Insiders is running, so let's open it in there.
code-insiders "$@"
exit $?
fi
Now, if you are only running the Insiders version of Visual Studio Code, using the code
command will be equivalent to running code-insiders
.