Make Gitpod Open Sites in the Browser

Gitpod configuration for opening links in the browser instead of in the terminal.

Jonathan Merlevede
datamindedbe
2 min readDec 16, 2022

--

The Lynx browser

At Data Minded, we ❤️ Gitpod for allowing us to easily configure reproducible and sharable development environments. However, we all have our pet peeves — and one small thing I do not like about Gitpod’s default configuration is that opening a URL from a terminal application fires up LYNX… and this despite Gitpod running in a perfectly usable browser 🌎! Luckily, we can change this default and configure Gitpod to open links in a browser window by using a startup script.

Gitpod helper

Gitpod’s helper application gp can open browser windows. As an example, the following command will open Data Minded’s website in a browser window:

gp preview --external https://www.dataminded.com/

Updating alternatives

We can configure the above command as the default way to open links. The idea is to create a small script /usr/local/bin/open.sh with the following contents:

#!/bin/sh
exec gp preview --external "$@"

Then, make it the default way to open links by running:

sudo chmod +x /usr/local/bin/open.sh
sudo update-alternatives --install /usr/bin/www-browser www-browser /usr/local/bin/open.sh 100

The reason for creating the script is that update-alternatives requires you to point to a single executable.

Startup configuration

You can make Gitpod perform the steps above when starting your workspace starts by adding the following start task to your gitpod.yml file:

tasks:
command: |
cat <<'EOF' | sudo install /dev/stdin /usr/local/bin/open.sh
#!/bin/sh
exec gp preview --external "$@"
EOF
sudo update-alternatives --install /usr/bin/www-browser www-browser /usr/local/bin/open.sh 100

--

--