1

I have a few devcontainer configurations that I use with both the Visual Studio Code Remote Container extensions and GitHub Codespaces to teach classroom topics.

I have a sample here on GitHub: https://github.com/seesharprun/how-to-sql-query

I want to figure out how to open a file and the Markdown preview on launch when someone opens this project in a devcontainer (either using Code or Codespaces).

VSCode.dev seems to do this already: https://open.vscode.dev/seesharprun/how-to-sql-query

This would allow me to open something like a default *.cs file or the preview of a readme.md file with instructions on how to complete the "lab" for students.

I have looked at https://containers.dev/ to learn more about the JSON schema definition. I have seen things like the postCreateCommand, postAttachCommand and the postStartCommand. I tried using the command code readme.md --reuse-window with postAttachCommand, but that didn't seem to work. I also looked at tasks but couldn't find anything to help there either.

sidney.andrews
  • 5,146
  • 3
  • 23
  • 29

1 Answers1

3

Per Jonathan Carter on Twitter, there's a customizations.codespaces.openFiles property that takes an array of files to open on launch. Here's a link to the documentation.

The property allows you to open the files in their default editor. It doesn't quite allow you to open the Markdown file as a preview (like VSCode.dev) but it solved my problem.

sidney.andrews
  • 5,146
  • 3
  • 23
  • 29