Skip to content

Instantly share code, notes, and snippets.

@somewhatabstract
Last active October 12, 2022 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somewhatabstract/15f99bc9e94bd7d5db6ccf4125e05b3f to your computer and use it in GitHub Desktop.
Save somewhatabstract/15f99bc9e94bd7d5db6ccf4125e05b3f to your computer and use it in GitHub Desktop.
Modified `code` command to run `code-insiders` if `code-insiders` is running instead

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.

  1. Make sure to have installed the code and code-insiders command into your path by using the command palette
  2. Edit the code command (e.g. code "$(which code)")
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment