|
| 1 | +<!-- |
| 2 | + <<< Author notes: Step 4 >>> |
| 3 | + Start this step by acknowledging the previous step. |
| 4 | + Define terms and link to docs.github.com. |
| 5 | +--> |
| 6 | + |
| 7 | +## Step 4: Personalize your codespace! |
| 8 | + |
| 9 | +_Nicely done customizing your codespace!_ :partying_face: |
| 10 | + |
| 11 | +When using any development environment, customizing the settings and tools to your preferences and workflows is an important step. GitHub Codespaces offers two main ways of personalizing your codespace: `Settings Sync` with VS Code and `dotfiles`. |
| 12 | + |
| 13 | +`Dotfiles` will be the focus of this activity. |
| 14 | + |
| 15 | +**What are `dotfiles`?** Dotfiles are files and folders on Unix-like systems starting with . that control the configuration of applications and shells on your system. You can store and manage your dotfiles in a repository on GitHub. |
| 16 | + |
| 17 | +Let's see how this works! |
| 18 | + |
| 19 | +### :keyboard: Activity: Enable a `dotfile` for your codespace |
| 20 | + |
| 21 | +1. Start from the landing page of your repository. |
| 22 | +1. In the upper-right corner of any page, click your profile photo, and then click **Settings**. |
| 23 | +1. In the **Code, planning, and automation** section of the sidebar, click **Codespaces**. |
| 24 | +1. Under **Dotfiles**, select **Automatically install dotfiles** so that GitHub Codespaces automatically installs your dotfiles into every new codespace you create. |
| 25 | +1. Click **Select repository** and then choose your current skills working repository as the repository from which to install dotfiles. |
| 26 | + |
| 27 | +### :keyboard: Activity: Add a `dotfile` to your repository and run your codespace |
| 28 | + |
| 29 | +1. Start from the landing page of your repository. |
| 30 | +1. Click the **Code** button located in the middle of the page. |
| 31 | +1. Click the **Codespaces** tab on the box that pops up. |
| 32 | +1. Click the **Create codespace on main** button. |
| 33 | + |
| 34 | + > Wait about **2 minutes** for the codespace to spin itself up. |
| 35 | +
|
| 36 | +1. Verify your codespace is running. The browser should contain a VS Code web-based editor and a terminal should be present such as the below: |
| 37 | + |
| 38 | +  |
| 39 | + |
| 40 | +1. From inside the codespace in the VS Code explorer window, create a new file `setup.sh`. |
| 41 | +1. Enter the following code into the file: |
| 42 | + |
| 43 | + ```bash |
| 44 | + #!/bin/bash |
| 45 | + |
| 46 | + sudo apt-get update |
| 47 | + sudo apt-get install sl |
| 48 | + echo "export PATH=\$PATH:/usr/games" >> ~/.bashrc |
| 49 | + ``` |
| 50 | + |
| 51 | +1. Save the file. |
| 52 | + > **Note**: The file should autosave. |
| 53 | +1. Commit the file changes. From the VS Code terminal enter: |
| 54 | + |
| 55 | + ```shell |
| 56 | + git add setup.sh --chmod=+x |
| 57 | + git commit -m "Adding setup.sh from the codespace!" |
| 58 | + ``` |
| 59 | + |
| 60 | +1. Push the changes back to your repository. From the VS Code terminal, enter: |
| 61 | + |
| 62 | + ```shell |
| 63 | + git push |
| 64 | + ``` |
| 65 | + |
| 66 | +1. Switch back to the homepage of your repository and view the `setup.sh` to verify the new code was pushed to your repository. |
| 67 | +1. Close the codespace web browser tab. |
| 68 | +1. Click the **Create codespace on main** button. |
| 69 | + |
| 70 | + > Wait about **2 minutes** for the codespace to spin itself up. |
| 71 | +
|
| 72 | +1. Verify your codespace is running, as you did previously. |
| 73 | +1. Verify the `setup.sh` file is present in your VS Code editor. |
| 74 | +1. From the VS Code terminal, type or paste: |
| 75 | + |
| 76 | + ```shell |
| 77 | + sl |
| 78 | + ``` |
| 79 | + |
| 80 | +1. Enjoy the show! |
| 81 | +1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step. |
0 commit comments