Install Termux

Set up a fresh Termux installation from scratch. Run this skill on a new device after installing Termux and pi.

Prerequisites

  • Termux installed from F-Droid or Google Play
  • pi installed (npm install -g @earendil-works/pi-coding-agent)
  • Internet connection
  • Before wiping old device: run backup-termux.sh to save SSH keys, pi config, tokens to Syncthing

Steps

1. Update packages

pkg update -y && pkg upgrade -y

2. Install essential packages

pkg install -y \
  git \
  stow \
  zsh \
  tmux \
  neovim \
  nodejs \
  ripgrep \
  fd \
  fzf \
  lazygit \
  gh \
  make \
  openssh \
  curl \
  jq \
  python \
  python-pip \
  termux-api \
  unzip \
  gnupg \
  mosh \
  rust \
  golang \
  pandoc \
  poppler \
  ffmpeg \
  cmake \
  zsh-completions \
  bun

(bun runs context-mode’s MCP server: see restore-session. Termux ships no su and no ufw, in any of its repos.)

3. Set up storage access

termux-setup-storage

Creates ~/storage/ symlinks (shared, downloads, dcim, …), the route from Termux into shared storage, where the handset’s own files and backups live.

4. Restore from backup (if you ran backup-termux.sh on the old device)

The zip is named termux-backup-<ts>.zip and lands in the script’s backup dir: $BACKUP_DIR defaults to $SYNC_DIR/termux-backup, SYNC_DIR defaults to ~/syncthing, and the script falls back to ~/sync/Files/devices/phone/termux-backup when that dir exists. Do this BEFORE stowing dot-files so .env-private, .pi and .ssh are in place. The restore script comes from the public dot-files repo (clone needs SSH keys, so fetch it first):

mkdir -p ~/.local/bin
curl -fsSL https://gitlab.com/FabianUntermoser/dot-files/-/raw/master/stow/scripts/.local/bin/restore-termux.sh -o ~/.local/bin/restore-termux.sh
curl -fsSL https://gitlab.com/FabianUntermoser/dot-files/-/raw/master/stow/scripts/.local/bin/backup-termux.sh -o ~/.local/bin/backup-termux.sh
chmod +x ~/.local/bin/restore-termux.sh ~/.local/bin/backup-termux.sh
 
restore-termux.sh          # restore latest zip
restore-termux.sh <name>   # restore a specific zip by name

Restores SSH keys, pi config, zsh env, termux appearance + pi session logs, chmods id_rsa, reloads termux settings.

5. Set up SSH key

Generate a new SSH key (or restore from backup):

ssh-keygen -t rsa -b 4096 -C "termux-$(hostname)" -f ~/.ssh/id_rsa -N ""

Add the public key to GitLab:

cat ~/.ssh/id_rsa.pub
# Add this to https://gitlab.com/-/user_settings/ssh_keys

6. Clone dot-files repo

mkdir -p ~/repos
git clone git@gitlab.com:FabianUntermoser/dot-files.git ~/repos/dots/public

7. Stow dot-files

cd ~/repos/dots/public && make

On Termux the zsh package’s root .zshenv conflicts with the termux package’s .zshenv (both own ~/.zshenv). Stow zsh separately, ignoring its root .zshenv:

cd ~/repos/dots/public
stow -v --dir=stow -t "$HOME" bash git JetBrains profile ripgrep scripts shell termux workspaces
stow -v --dir=stow -t "$HOME" --ignore='^\.zshenv$' zsh

8. Set zsh as default shell

# Termux uses ~/.termux/shell symlink
ln -sf /data/data/com.termux/files/usr/bin/zsh ~/.termux/shell

9. Set up Termux colors

Create ~/.termux/colors.properties with the light theme:

# Light theme for Termux
background=#F9F9F9
foreground=#3A3A3A
cursor=#3A3A3A

# Black
color0=#3A3A3A
color8=#7A7A7A

# Red
color1=#CC3333
color9=#FF5555

# Green
color2=#2E7D32
color10=#4CAF50

# Yellow
color3=#B8860B
color11=#FFB300

# Blue
color4=#1565C0
color12=#42A5F5

# Magenta
color5=#7B1FA2
color13=#AB47BC

# Cyan
color6=#00838F
color14=#26C6DA

# White
color7=#D5D5D5
color15=#FFFFFF

Reload Termux settings:

termux-reload-settings

10. Create private env file

Create ~/.config/zsh/.env-private with secrets (tokens, API keys):

cat > ~/.config/zsh/.env-private << 'EOF'
# put your secrets here
export SOME_TOKEN="<your-token>"
EOF

11. Clone other repos

# dot-files-private (SSH config, private configs)
git clone ssh://git@10.147.18.69:23907/FabianUntermoser/dot-files-private.git ~/repos/dots/private
 
# skills
git clone ssh://git@10.147.18.69:23907/FabianUntermoser/skills.git ~/repos/dots/skills

Both live on the private GitLab on the NAS at 10.147.18.69:23907. That address is the NAS ZeroTier address, so the clone also works off the home network while ZeroTier is up.

Stow the private configs (git identity, private aliases, scripts, workspaces):

cd ~/repos/dots/private
stow -v --dir=. -t ~ git shell scripts
# workspaces merges with the dot-files package: make the dirs real, then stow both
rm -rf ~/.config/workspaces && mkdir -p ~/.config/workspaces/layouts ~/.config/workspaces/profiles
cd ~/repos/dots/public && stow -v --dir=stow -t ~ workspaces
cd ~/repos/dots/private && stow -v --dir=. -t ~ workspaces

Skill scripts are not a stow package, so link the ones a bind, an alias or another skill calls by bare name:

for f in tmux/scripts/agent-tmux.sh tmux/scripts/agent-tmux-pane.sh tmux/scripts/agent-task.sh tmux/scripts/tmux_session.sh tmux/scripts/tmux-restore.sh calendar/scripts/agent-cal.sh notify/scripts/ntfy.sh sync/scripts/sync-repos.sh; do
  ln -sfn "$HOME/repos/dots/skills/$f" "$HOME/.local/bin/$(basename "$f")"
done

The skills repo links every skill into place itself (~/.agents/skills, ~/.claude/skills, ~/.codex/skills):

cd ~/repos/dots/skills && make install

~/.pi/agent/ stays device-local: auth.json holds no keys (every provider carries its apiKey in models.json), and the rest is sessions, caches and the files the steps below write. Do NOT stow the pi package; keep what the restore left in place.

12. Install pi and global npm packages

npm install -g @earendil-works/pi-coding-agent
npm install -g wrangler@2 --ignore-scripts

wrangler 3+ bundles workerd, which has no Termux build: pin wrangler@2 and skip scripts (deploy works; local dev does not).

13. Install pi extensions

The list is the packages array of ~/repos/dots/private/pi/.pi/agent/settings.json: keep the two in sync.

pi install git:github.com/v2nic/pi-caveman
pi install npm:@juicesharp/rpiv-ask-user-question
pi install npm:@juicesharp/rpiv-todo
pi install npm:@ollama/pi-web-search
pi install npm:latchkey
pi install npm:pi-mcp-adapter
pi install npm:pi-playwright
pi install npm:@tmustier/pi-usage-extension
pi install git:github.com/tmustier/pi-extensions
pi install npm:context-mode
pi install npm:@gotgenes/pi-permission-system
pi install npm:pi-scroll
pi install npm:@upstash/context7-pi
pi install npm:@hypabolic/pi-hypa
pi install npm:@tintinweb/pi-subagents
pi install npm:codebase-lens
pi install npm:pi-context-view
pi install npm:pi-deepseek-peak
pi install npm:@monotykamary/pi-retry

The git:github.com/tmustier/pi-extensions entry loads one extension only, so it belongs in settings as an object rather than a bare source:

python3 -c "import json; p='$HOME/.pi/agent/settings.json'; s=json.load(open(p)); s['packages']=[{'source': x, 'extensions': ['session-recap/index.ts']} if x == 'git:github.com/tmustier/pi-extensions' else x for x in s['packages']]; json.dump(s, open(p, 'w'), indent=2)"

@gotgenes/pi-permission-system reads its rules from ~/.pi/agent/extensions/pi-permission-system/config.json, so copy the shared one:

mkdir -p ~/.pi/agent/extensions/pi-permission-system
cp ~/repos/dots/private/pi/.pi/agent/extensions/pi-permission-system/config.json ~/.pi/agent/extensions/pi-permission-system/config.json

Remote MCP servers

pi mcp add writes ~/.pi/agent/mcp.json. An OAuth server signs in from a pane on the phone, with the callback port pinned so a retry lands on the same listener:

pi mcp add notion --url https://mcp.notion.com/mcp --oauth-callback-port 45871
tmux new-session -d -s login-notion "pi mcp login --timeout 1800 notion"
tmux capture-pane -p -J -t login-notion | tr -d '\n' | grep -o 'https://[^ ]*authorize[^ ]*'

Over ssh nothing catches the browser redirect, so approve at that URL and paste the redirected URL back into the pane:

tmux send-keys -t login-notion -l -- '<http://127.0.0.1:45871/callback?...>'
tmux send-keys -t login-notion Enter
  • The callback waiter gives up long before --timeout, and a stale state= is rejected with its code burnt: paste fast, and on a mismatch start a fresh pi mcp login rather than reusing the URL.
  • pi mcp login needs a TTY, which ssh host sh -s < script does not give it: run it in tmux as above.
  • ss -ltn on Termux lists nothing for a listener that is up: probe curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:<port>/ instead, where 404 means alive.
  • pi mcp list is the receipt: connected, <n> tools.

Three shapes a phone carried over from pi 0.87 fail on 1.x:

  • auth: "bearer" with bearerToken answers config error ... auth.provider must be a provider name: use "headers": {"Authorization": "Bearer …"}.
  • playwright with --executable-path /usr/bin/brave never starts (Unsupported platform: android): mark it "enabled": false.
  • A stale skill copy under ~/.pi/agent/skills shadows the ~/.agents/skills view and pi reports the second path as (skipped): shared storage takes no symlinks, so delete the stale copy instead of linking it.
  • pi install npm:<pkg> also upgrades an installed extension: @juicesharp/rpiv-ask-user-question 2.11.0 lists typebox under dependencies and the loader rejects it, 2.15.0 declares it in peerDependencies with "*".

14. Set pi theme

pi config is a TUI, not a setter. The shared config ships theme: "wal", and wal is not builtin: theme.sh (public scripts package) generates ~/.pi/agent/themes/wal.json from pywal’s ~/.cache/wal/colors.sh, no repo ships that file, and pywal is not a Termux package. pi fails with Theme not found: wal when the file is absent, so a fresh phone takes the builtin light, and switches to wal once a copied wal.json is in place. Edit ~/.pi/agent/settings.json:

python3 -c "import json; s=json.load(open('$HOME/.pi/agent/settings.json')); s['theme']='light'; json.dump(s,open('$HOME/.pi/agent/settings.json','w'),indent=2)"

15. Set up pi providers (API keys)

Create ~/.pi/agent/models.json with the provider blocks, taking the apiKey values from ~/repos/dots/private/pi/.pi/agent/models.json:

{
  "providers": {
    "google-ai-studio": {
      "api": "google-generative-ai",
      "baseUrl": "https://generativelanguage.googleapis.com/v1beta",
      "apiKey": "<your-google-ai-studio-key>",
      "models": []
    },
    "ollama": {
      "api": "openai-completions",
      "baseUrl": "http://127.0.0.1:11434/v1",
      "apiKey": "ollama",
      "models": []
    },
    "openrouter-models": {
      "api": "openai-completions",
      "baseUrl": "https://openrouter.ai/api/v1",
      "apiKey": "<your-openrouter-key>",
      "models": []
    }
  }
}

The providers in use are google-ai-studio, ollama and openrouter-models; ~/.pi/agent/auth.json stays empty, because each provider carries its apiKey inline. The model IDs come from ~/repos/dots/private/pi/.pi/agent/models.json (cloned in step 11) and from ~/.pi/agent/AGENTS.md: this skill does not pick a model, copy the models arrays from there.

16. Verify setup

Open a new tmux session and check:

tmux new-session -d -s verify 'zsh -i -c "type tmuxify >/dev/null && type pi >/dev/null && echo OK"'
tmux capture-pane -t verify -p -S -5
tmux kill-session -t verify

Expected output:

OK

(pi is a shell function, not an alias, so check with type pi.)

17. Install whisper.cpp (local transcription)

Lets clip transcribe IG reels and media files on the phone without the laptop (whisper-ctranslate2 has no Termux wheel and builds from source for ages; whisper.cpp compiles in minutes). transcribe-video.sh falls back to whisper-cli when whisper-ctranslate2 is missing. WHISPER_BUILD_CLI is not an option upstream; the examples build by default and ship whisper-cli.

# cmake already installed in step 2
cd ~
git clone --depth 1 https://github.com/ggerganov/whisper.cpp
cd whisper.cpp
cmake -B build -DGGML_NATIVE=OFF
cmake --build build --config Release -j2
bash models/download-ggml-model.sh small
ln -sf ~/whisper.cpp/build/bin/whisper-cli ~/.local/bin/whisper-cli

Model lands in ~/whisper.cpp/models/ggml-small.bin (~490MB); the symlink puts whisper-cli on PATH so transcribe-video.sh finds it.

18. Set up calendar sync (vdirsyncer)

PRIVATE: infra details (server, user, calendar list): stripped from the public copy on the website. Edit carefully.

19. Back up before wiping the device

A device swap or a reinstall starts here. backup-termux.sh (public scripts package, on PATH) zips the config this skill sets up: SSH keys, .pi/agent/auth.json, models.json, MEMORY.md, AGENTS.md, settings.json, .pi/settings.json, .config/zsh/.env-private, the vdirsyncer and khal config with ~/.calendars, and the termux appearance files.

backup-termux.sh

backup-termux.sh --restore [ZIP] extracts it back, which restore-termux.sh wraps; the zip lands in the backup dir from step 4. ITEMS in the script is the whole list of what travels: check it when a file you rely on is missing after a restore.

Notes

  • SSH keys must be added to GitLab before cloning repos
  • .env-private tokens must be provided manually (not in repo)
  • dot-files-private + skills require access to the private GitLab server at 10.147.18.69, the NAS ZeroTier address
  • After setup, restart Termux or run exec zsh to switch to zsh
  • Remote access is Termux sshd on 8022 over the tailnet or ZeroTier: Android has no ufw and Termux packages none, so there is no firewall step
  • Calendar sync: vdirsyncer config in .config/vdirsyncer/, calendars in ~/.calendars/: both included in backup-termux.sh

eee08105