GitHub codespaces - write code in web browser

After coming home with Microsoft, more and more good and free things come to GitHub. This time, a long-awaited features are in beta, invitation-only, and it is GitHub Codespaces.

1. Extremely short introduction

Codespaces, in short, is a Linux virtual machine running vscode server and allows you to access it via any web browser.

Microsoft introduces its codespaces first in Visual Studio Online, using your Azure account to charge. “GitHub codespaces” is in the early access stage, so everything is free for now.

To request early access to GitHub codespaces, here is the link: https://github.com/features/codespaces

2. Using GitHub codespaces

When you’re invited to use codespaces, your GitHub’s repositories will have another option in open button

open button

2.1. Change theme

The default theme for VSCode is light. Light attracting bugs. So we need to change it to dark

The typical themes used by vscode is not working, so we need to use an extension developed by GitHub called github theme

themes

Sadly, the icon theme is fixed with 1 of the two default set.

2.2. Settings

Except for some settings related to themes and icons that have no effect, almost all other settings are the same. You can just copy and paste the settings from your local vscode to codespaces vscode

2.3. Install your programming language extensions

I think every programming language extension worked as it should be, but first, you will need to set up the development environment in Linux.

For example, to use Java, you will need to install JDK on Linux, then Java Extension Pack for a complete list of Java extensions in vscode.

C/C++ and Python extensions are pre-installed

When you open a project, based on the language, some language extension will be pre-installed

2.4. Work with multiple repository

By default, one codespace can only work with one repository. I will use the SSH key to have access to every repository on my Github.

  1. Generate SSH key
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. Add ssh key to ssh agent
$ eval "$(ssh-agent -s)"
> Agent pid xxxxx
$ ssh-add ~/.ssh/id_rsa
  1. Add the public key to GitHub

Add the key to settings at SSH settings

  1. Change repo remote URL from HTTPS to SSH
git remote set-url origin git@github.com:<Username>/<Project>.git

That’s it

3. Some interesting things I found

  • The codespaces running on Debian 9.13 - lsb_release -a
  • 4GB of RAM - free -m
  • Using 2 core of the Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz - less /proc/cpuinfo and cat /proc/cpuinfo | grep processor | wc -l

The vscode version is the latest Insider version, so expect some errors and unstable features