From 29c803a3fe18fa5fc1b1abd098108b57adead640 Mon Sep 17 00:00:00 2001 From: hubwriter Date: Thu, 27 Oct 2022 17:32:07 +0100 Subject: [PATCH] Add new Codespaces article for the `openFiles` property (#31978) Co-authored-by: Sophie <29382425+sophietheking@users.noreply.github.com> Co-authored-by: Isaac Brown <101839405+isaacmbrown@users.noreply.github.com> --- content/codespaces/guides.md | 2 + ...iles-in-the-codespaces-for-a-repository.md | 50 +++++++++++++++++++ .../index.md | 1 + ...um-specification-for-codespace-machines.md | 4 +- .../codespaces/edit-devcontainer-json.md | 1 + 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 content/codespaces/setting-up-your-project-for-codespaces/automatically-opening-files-in-the-codespaces-for-a-repository.md create mode 100644 data/reusables/codespaces/edit-devcontainer-json.md diff --git a/content/codespaces/guides.md b/content/codespaces/guides.md index 60fb6c4782..cb9038bcac 100644 --- a/content/codespaces/guides.md +++ b/content/codespaces/guides.md @@ -15,6 +15,8 @@ includeGuides: - /codespaces/setting-up-your-project-for-codespaces/setting-up-your-python-project-for-codespaces - /codespaces/setting-up-your-project-for-codespaces/setting-up-your-dotnet-project-for-codespaces - /codespaces/setting-up-your-project-for-codespaces/setting-up-your-java-project-for-codespaces + - /codespaces/setting-up-your-project-for-codespaces/setting-a-minimum-specification-for-codespace-machines + - /codespaces/setting-up-your-project-for-codespaces/automatically-opening-files-in-the-codespaces-for-a-repository - /codespaces/setting-up-your-project-for-codespaces/adding-a-codespaces-badge - /codespaces/setting-up-your-codespace/configuring-codespaces-for-your-project - /codespaces/setting-up-your-codespace/personalizing-codespaces-for-your-account diff --git a/content/codespaces/setting-up-your-project-for-codespaces/automatically-opening-files-in-the-codespaces-for-a-repository.md b/content/codespaces/setting-up-your-project-for-codespaces/automatically-opening-files-in-the-codespaces-for-a-repository.md new file mode 100644 index 0000000000..e77e284122 --- /dev/null +++ b/content/codespaces/setting-up-your-project-for-codespaces/automatically-opening-files-in-the-codespaces-for-a-repository.md @@ -0,0 +1,50 @@ +--- +title: Automatically opening files in the codespaces for a repository +shortTitle: Automatically opening files +intro: 'You can set particular files to be opened automatically whenever someone creates a codespace for your repository and opens the codespace in the {% data variables.product.prodname_vscode %} web client.' +permissions: People with write permissions to a repository can create or edit the codespace configuration. +versions: + fpt: '*' + ghec: '*' +type: how_to +topics: + - Codespaces + - Set up +--- + +## Overview + +If there's a particular file that's useful for people to see when they create a codespace for your repository, you can set this file to be opened automatically in the {% data variables.product.prodname_vscode_shortname %} web client. You set this up in the dev container configuration file for your repository. + +The file, or files, you specify are only opened the first time a codespace is opened in the web client. If the person closes the specified files, those files are not automatically reopened the next time that person opens or restarts the codespace. + +{% note %} + +**Note**: This automation only applies to the {% data variables.product.prodname_vscode_shortname %} web client, not to the {% data variables.product.prodname_vscode_shortname %} desktop application, or other supported editors. + +{% endnote %} + +## Setting files to be opened automatically + +{% data reusables.codespaces.edit-devcontainer-json %} +1. Edit the `devcontainer.json` file, adding a `customizations.codespaces.openFiles` property. The `customizations` property resides at the top level of the file, within the enclosing JSON object. For example: + + ```json{:copy} + "customizations": { + "codespaces": { + "openFiles": [ + "README.md", + "scripts/tsconfig.json", + "docs/main/CODING_STANDARDS.md" + ] + } + } + ``` + + The value of the `openFiles` property is an array of one or more files in your repository. The paths are relative to the root of the repository (absolute paths are not supported). The files are opened in the web client in the order specified, with the first file in the array displayed in the editor. + +1. Save the file and commit your changes to the required branch of the repository. + +## Further reading + +- "[Introduction to dev containers](/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)" diff --git a/content/codespaces/setting-up-your-project-for-codespaces/index.md b/content/codespaces/setting-up-your-project-for-codespaces/index.md index dd269bee1a..1f56d69b82 100644 --- a/content/codespaces/setting-up-your-project-for-codespaces/index.md +++ b/content/codespaces/setting-up-your-project-for-codespaces/index.md @@ -17,6 +17,7 @@ children: - /setting-up-your-java-project-for-codespaces - /setting-up-your-python-project-for-codespaces - /setting-a-minimum-specification-for-codespace-machines + - /automatically-opening-files-in-the-codespaces-for-a-repository - /adding-a-codespaces-badge --- diff --git a/content/codespaces/setting-up-your-project-for-codespaces/setting-a-minimum-specification-for-codespace-machines.md b/content/codespaces/setting-up-your-project-for-codespaces/setting-a-minimum-specification-for-codespace-machines.md index 6c4a927d39..9bd36a5a2a 100644 --- a/content/codespaces/setting-up-your-project-for-codespaces/setting-a-minimum-specification-for-codespace-machines.md +++ b/content/codespaces/setting-up-your-project-for-codespaces/setting-a-minimum-specification-for-codespace-machines.md @@ -27,8 +27,8 @@ If your project needs a certain level of compute power, you can configure {% dat ## Setting a minimum machine specification -1. {% data variables.product.prodname_github_codespaces %} for your repository are configured in a `devcontainer.json` file. If your repository does not already contain a `devcontainer.json` file, add one now. See "[Add a dev container configuration to your repository](/free-pro-team@latest/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces)." -1. Edit the `devcontainer.json` file, adding a `hostRequirements` property such as this: +{% data reusables.codespaces.edit-devcontainer-json %} +1. Edit the `devcontainer.json` file, adding the `hostRequirements` property at the top level of the file, within the enclosing JSON object. For example: ```json{:copy} "hostRequirements": { diff --git a/data/reusables/codespaces/edit-devcontainer-json.md b/data/reusables/codespaces/edit-devcontainer-json.md new file mode 100644 index 0000000000..55c57eee95 --- /dev/null +++ b/data/reusables/codespaces/edit-devcontainer-json.md @@ -0,0 +1 @@ +1. {% data variables.product.prodname_github_codespaces %} for your repository are configured in a `devcontainer.json` file. If your repository does not already contain a `devcontainer.json` file, add one now. See "[Add a dev container configuration to your repository](/free-pro-team@latest/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces)." \ No newline at end of file