---
title: Installing thoughtbot dotfiles on GitHub Codespaces
teaser: How I install my fork of the thougtbot dotfiles on GitHub Codespaces.
tags: devtools,configuration
author: Daniel Nolan
published_on: 2024-05-14
---

Consulting for large clients that have apps with complex stacks has us working with
Github Codespaces more frequently. Codespaces has a tight integration with
Visual Studio Code if that's your jam, but I personally use neovim, tmux, and a fork of
the [thoughtbot dotfiles](https://github.com/thoughtbot/dotfiles) manged by [rcm](https://github.com/thoughtbot/rcm) for my development envrionment.
Thankfully Github has made it straightforward to personalize your
codespace and upload your [dotfiles](https://docs.github.com/en/codespaces/setting-your-user-preferences/personalizing-github-codespaces-for-your-account#dotfiles).
If you set your dotfiles repository in your Github Codespace settings,
Github will automatically copy your dotfiles to Codespaces you create.
Now all you have to do is create a install script within your dotfiles repository,
and Github will run the script after it clones your dotfiles to the Codespace
to setup your environment.

```shell
#!/bin/sh

if [ -z "$USER" ]; then
  USER=$(id -un)
fi

mv /workspaces/.codespaces/.persistedshare/dotfiles $HOME/dotfiles

cd $HOME

# Make passwordless sudo work
export SUDO_ASKPASS=/bin/true

# Change shell to zsh
sudo chsh "$(id -un)" --shell "/usr/bin/zsh"

# Install ag for fast searching
sudo apt-get install -y silversearcher-ag

# Install rcm for Ubuntu > 19
sudo apt-get update
sudo apt-get install -y rcm
yes | rcup -d dotfiles -x README.md -x LICENSE -x Brewfile -x install
```

This install script copies the dotfiles to the home directory, makes it
so you can run sudo commands without a password, changes the default
shell to zsh, installs the packages silversearcher-ag and rcm,
and finally installs the dotfiles using rcm. That's it, now when you ssh
to the Codespace server you will have all your tools just like if you
were working on your local machine.

Your mileage may vary and you will likely need to tweak the script some. For
example the client I'm working with currently includes neovim in their
codespace image, but you could install it via your dotfiles install script if
needed.

```shell
# Install neovim
sudo apt-get install -y libfuse2
# We use the app image to get the latest version, you could install
# through apt like the other packages in the install script, but it's
# likely an old verion.
curl -L -o $HOME/bin/nvim https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod a+x $HOME/bin/nvim
```
