Apps / Development / :8080

VS Code in the browser

code-server: VS Code on the machine, in any browser.

No MiniControl yet? Download MiniControl, then install VS Code in the browser from its catalog.

code-server runs Visual Studio Code on the machine and serves it as a web page. Open it from an iPad, a Chromebook or any borrowed computer and you get the full editor, terminal and extensions, working on the machine's files.

Why on a Mac: The terminal is the Mac's, so Xcode's tools, Swift and Homebrew are right there.

The code editor tile (Remote - SSH) needs no install; this is for browsers and iPads.

After the install: It asks for a password: it's in ~/.config/code-server/config.yaml on the machine.

Free, like the whole catalog.

What MiniControl installs

Packages
brew install code-server
Web page
Port 8080
Keeps running
As LaunchAgent app.minicontrol.code-server, also after a restart
Its data
~/.config/code-server~/.local/share/code-server
Memory
200–500 MB, plus the extensions you use
Licence
MIT
The install script

What MiniControl runs on your server, word for word. The app shows the same script before it installs.

#!/bin/bash
# Generated by MiniControl for VS Code in the browser. Runs on the machine.
set -euo pipefail
export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_ENV_HINTS=1 NONINTERACTIVE=1
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:$PATH"
step() { echo "STEP|$1|$2"; }
fail() { echo "ERR|$1"; exit 1; }
U=$(id -u)
BREW=$(command -v brew || true)
[ -n "$BREW" ] || fail "Homebrew isn't installed. Server Setup → Homebrew installs it."
BP=$("$BREW" --prefix)
step 1 "Checking the machine"
for f in "$HOME"/Library/LaunchAgents/*.plist; do
  if grep -qsF -- 'bin/code-server' "$f"; then fail "VS Code in the browser is already set up here, as $(basename "$f" .plist)."; fi
done
if lsof -nP -iTCP:8080 -sTCP:LISTEN >/dev/null 2>&1; then
  fail "Something else already uses port 8080: $(lsof -nP -iTCP:8080 -sTCP:LISTEN | awk 'NR == 2 {print $1}')."
fi
step 2 "Installing with Homebrew"
"$BREW" list --formula code-server >/dev/null 2>&1 || "$BREW" install code-server
step 3 "Setting it up"
mkdir -p "$HOME/services/code-server/log" "$HOME/Library/LaunchAgents"
PL="$HOME/Library/LaunchAgents/app.minicontrol.code-server.plist"
cat > "$PL" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key><string>app.minicontrol.code-server</string>
  <key>ProgramArguments</key>
  <array>
    <string>$BP/opt/code-server/bin/code-server</string>
    <string>--bind-addr</string>
    <string>0.0.0.0:8080</string>
  </array>
  <key>RunAtLoad</key><true/>
  <key>KeepAlive</key><true/>
  <key>ThrottleInterval</key><integer>10</integer>
  <key>ProcessType</key><string>Background</string>
  <key>StandardOutPath</key><string>$HOME/services/code-server/log/launchd.out.log</string>
  <key>StandardErrorPath</key><string>$HOME/services/code-server/log/launchd.err.log</string>
</dict>
</plist>
EOF
plutil -lint "$PL" >/dev/null
[ -x "$BP/opt/code-server/bin/code-server" ] || fail "$BP/opt/code-server/bin/code-server isn't there after the install."
step 4 "Starting VS Code in the browser"
# Services run in the logged-in user's session (gui/<uid>), like every service in the panel.
launchctl bootstrap "gui/$U" "$PL" || fail "launchd didn't start it. Services run while you're logged in on the machine; Server Setup's \"Log in automatically after a restart\" fixes that."
if /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate 2>/dev/null | grep -q enabled; then echo "FW|$BP/opt/code-server/bin/code-server"; fi
step 5 "Waiting for it to answer"
# Localhost, and the Tailscale IP for apps that bind only to it.
# `|| true`: with set -e, a failed substitution in an assignment would end the script.
HOSTS="127.0.0.1 $(for t in "$BP/bin/tailscale" /usr/local/bin/tailscale; do [ -x "$t" ] && "$t" ip -4 2>/dev/null && break; done | head -1 || true)"
ok=0
for i in $(seq 1 45); do
  for h in $HOSTS; do
    if curl -fsS -m 3 -o /dev/null "http://$h:8080/healthz" 2>/dev/null; then ok=1; break 2; fi
  done
  sleep 2
done
[ "$ok" = 1 ] || echo "WARN|It started, but isn't answering on port 8080 yet. Big apps can take a minute on first start."
echo "DONE"

MiniControl isn’t affiliated with VS Code in the browser. Questions about VS Code in the browser itself go to its makers; about installing it, to hello@minicontrol.app.