termux-setup
Sets up and troubleshoots Termux on Android for development. Use whenever the user works in Termux, mentions pkg, termux-setup-storage, ~/storage, git on a phone, "dubious ownership", GitHub push from a phone, SSH keys or tokens on Android, or wants scripts that run in Termux, ev
Install
npx skills add https://github.com/MehranQadirian/skills/tree/main/termux/termux-setup
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install mehranqadirian-skills@llmmart
git clone https://github.com/MehranQadirian/skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole mehranqadirian/skills collection as a plugin from our marketplace. Git is the plain clone.
README
termux-setup
A Claude skill for developing in Termux on Android: setup, shared storage pitfalls, git authentication and automation.
What it does
- Bootstraps Termux with the packages a developer needs
- Explains why repos must live in
$HOME, not~/storage - Fixes
dubious ownership, token login, SSH keys and rejected pushes - Diagnoses a repo with
git_doctor.sh - Shows how to keep jobs alive with wake locks and cron
Try it
Set up Termux for git development and show me what each step does.
git pushasks for a password on my phone. Fix it.
Diagnose my repo at ~/skills.
Install
Claude.ai: zip this folder, then go to Settings > Capabilities > Skills > Upload.
Claude Code:
cp -r termux/termux-setup ~/.claude/skills/
Structure
termux-setup/
├── SKILL.md skill instructions for Claude
├── scripts/
│ ├── termux_bootstrap.sh package, storage and git identity setup (--dry-run)
│ └── git_doctor.sh repo diagnosis
└── references/troubleshooting.md error messages and fixes
Skill manifest
termux-setup
Practical setup and fixes for developing in Termux. Most problems come from three things: missing packages, shared storage behaving unlike a normal Linux disk, and git authentication.
termux-setup/
├── SKILL.md
├── scripts/
│ ├── termux_bootstrap.sh install packages, storage access, git identity (supports --dry-run)
│ └── git_doctor.sh diagnose a repo: ownership, location, remote, credentials
└── references/
└── troubleshooting.md error messages and exact fixes
When to use
- First time setup of Termux for coding
- A git command fails in a repo under
~/storage - Push to GitHub fails or asks for a password
- A script written for Linux must run on the phone
- A task must keep running with the screen off
Golden rules
- Work inside
$HOME(/data/data/com.termux/files/home), not inside~/storage/.... Shared storage has different ownership and no real permission bits, so git and chmod misbehave there. - Use
~/storage/downloadsonly to exchange files with other apps (copy in, copy out). - Use
https://clone URLs with a Personal Access Token, or an SSH key. A GitHub account password does not work. - Write scripts with the shebang
#!/data/data/com.termux/files/usr/bin/bashor#!/usr/bin/env bash. Never hardcode/bin/bashor/usr/bin. - Use
pkg, notapt, and neversudo(there is no root).
Quick start
bash scripts/termux_bootstrap.sh # installs git, openssh, python, zip, unzip, curl
bash scripts/termux_bootstrap.sh --dry-run # only print what would happen
bash scripts/git_doctor.sh ~/skills # diagnose a repo
Git fixes
"detected dubious ownership"
The repo is on shared storage or was extracted by another user. Best fix: move it into $HOME.
cp -r ~/storage/documents/Codes/myrepo ~/myrepo
cd ~/myrepo
git config --global --add safe.directory "$PWD"
Quick fix (trusts every directory, use only on a personal phone):
git config --global --add safe.directory '*'
Push asks for a password
GitHub removed password login for git. Create a token (GitHub: Settings, Developer settings, Personal access tokens) with repo scope, then:
git config --global credential.helper store
git push origin HEAD # username = GitHub user, password = the token
The token is saved in plain text in ~/.git-credentials. Protect the phone with a lock screen.
SSH instead of tokens
ssh-keygen -t ed25519 -C "phone"
cat ~/.ssh/id_ed25519.pub # add this to GitHub: Settings, SSH keys
git remote set-url origin git@github.com:USER/REPO.git
ssh -T git@github.com
Storage
termux-setup-storage # once, then tap Allow
ls ~/storage # downloads, documents, shared, dcim ...
cp file.zip ~/storage/downloads/
If ~/storage is missing after allowing, run termux-setup-storage again and restart Termux.
Long running work
termux-wake-lock # keep CPU awake; run termux-wake-unlock when done
pkg install termux-services # service manager (sv-enable, sv up)
pkg install cronie # crond for scheduled tasks, then: crontab -e
Also disable battery optimization for Termux in Android settings or the OS will kill background jobs.
Writing portable scripts
- Check the environment:
[ -n "${PREFIX:-}" ] && [[ "$PREFIX" == *com.termux* ]] - Prefer
set -euo pipefailand quote every variable - Offer
--dry-runfor anything that deletes or pushes - Avoid
systemd,apt,sudo,/tmpassumptions (use$TMPDIR)
More error messages and fixes: references/troubleshooting.md.
What to report back
State the exact commands run, where the repo lives (must be under $HOME), whether auth is token or SSH, and what to do if the step fails.
Related skills
systematic-debugging: diagnose failures with evidencesecrets-hygiene: keep tokens out of repos and shell historycommitsmith: commit messages for changes made on the phone
Files (skills)
-
references
-
troubleshooting.md 2.1 KB
Loading…
-
-
scripts
-
git_doctor.sh 3 KB
Loading… -
termux_bootstrap.sh 2.3 KB
Loading…
-
-
README.md 1.1 KB
# termux-setup A [Claude skill](../../README.md) for developing in Termux on Android: setup, shared storage pitfalls, git authentication and automation. ## What it does - Bootstraps Termux with the packages a developer needs - Explains why repos must live in `$HOME`, not `~/storage` - Fixes `dubious ownership`, token login, SSH keys and rejected pushes - Diagnoses a repo with `git_doctor.sh` - Shows how to keep jobs alive with wake locks and cron ## Try it > Set up Termux for git development and show me what each step does. > `git push` asks for a password on my phone. Fix it. > Diagnose my repo at ~/skills. ## Install **Claude.ai:** zip this folder, then go to Settings > Capabilities > Skills > Upload. **Claude Code:** ```bash cp -r termux/termux-setup ~/.claude/skills/ ``` ## Structure ``` termux-setup/ ├── SKILL.md skill instructions for Claude ├── scripts/ │ ├── termux_bootstrap.sh package, storage and git identity setup (--dry-run) │ └── git_doctor.sh repo diagnosis └── references/troubleshooting.md error messages and fixes ``` -
SKILL.md 4.4 KB
--- name: termux-setup description: Sets up and troubleshoots Termux on Android for development. Use whenever the user works in Termux, mentions pkg, termux-setup-storage, ~/storage, git on a phone, "dubious ownership", GitHub push from a phone, SSH keys or tokens on Android, or wants scripts that run in Termux, even if they only say "run this on my phone". Covers package setup, shared storage pitfalls, git authentication, wake locks and scheduled jobs. --- # termux-setup Practical setup and fixes for developing in Termux. Most problems come from three things: missing packages, shared storage behaving unlike a normal Linux disk, and git authentication. ``` termux-setup/ ├── SKILL.md ├── scripts/ │ ├── termux_bootstrap.sh install packages, storage access, git identity (supports --dry-run) │ └── git_doctor.sh diagnose a repo: ownership, location, remote, credentials └── references/ └── troubleshooting.md error messages and exact fixes ``` ## When to use - First time setup of Termux for coding - A git command fails in a repo under `~/storage` - Push to GitHub fails or asks for a password - A script written for Linux must run on the phone - A task must keep running with the screen off ## Golden rules 1. Work inside `$HOME` (`/data/data/com.termux/files/home`), not inside `~/storage/...`. Shared storage has different ownership and no real permission bits, so git and chmod misbehave there. 2. Use `~/storage/downloads` only to exchange files with other apps (copy in, copy out). 3. Use `https://` clone URLs with a Personal Access Token, or an SSH key. A GitHub account password does not work. 4. Write scripts with the shebang `#!/data/data/com.termux/files/usr/bin/bash` or `#!/usr/bin/env bash`. Never hardcode `/bin/bash` or `/usr/bin`. 5. Use `pkg`, not `apt`, and never `sudo` (there is no root). ## Quick start ```bash bash scripts/termux_bootstrap.sh # installs git, openssh, python, zip, unzip, curl bash scripts/termux_bootstrap.sh --dry-run # only print what would happen bash scripts/git_doctor.sh ~/skills # diagnose a repo ``` ## Git fixes ### "detected dubious ownership" The repo is on shared storage or was extracted by another user. Best fix: move it into `$HOME`. ```bash cp -r ~/storage/documents/Codes/myrepo ~/myrepo cd ~/myrepo git config --global --add safe.directory "$PWD" ``` Quick fix (trusts every directory, use only on a personal phone): ```bash git config --global --add safe.directory '*' ``` ### Push asks for a password GitHub removed password login for git. Create a token (GitHub: Settings, Developer settings, Personal access tokens) with `repo` scope, then: ```bash git config --global credential.helper store git push origin HEAD # username = GitHub user, password = the token ``` The token is saved in plain text in `~/.git-credentials`. Protect the phone with a lock screen. ### SSH instead of tokens ```bash ssh-keygen -t ed25519 -C "phone" cat ~/.ssh/id_ed25519.pub # add this to GitHub: Settings, SSH keys git remote set-url origin git@github.com:USER/REPO.git ssh -T git@github.com ``` ## Storage ```bash termux-setup-storage # once, then tap Allow ls ~/storage # downloads, documents, shared, dcim ... cp file.zip ~/storage/downloads/ ``` If `~/storage` is missing after allowing, run `termux-setup-storage` again and restart Termux. ## Long running work ```bash termux-wake-lock # keep CPU awake; run termux-wake-unlock when done pkg install termux-services # service manager (sv-enable, sv up) pkg install cronie # crond for scheduled tasks, then: crontab -e ``` Also disable battery optimization for Termux in Android settings or the OS will kill background jobs. ## Writing portable scripts - Check the environment: `[ -n "${PREFIX:-}" ] && [[ "$PREFIX" == *com.termux* ]]` - Prefer `set -euo pipefail` and quote every variable - Offer `--dry-run` for anything that deletes or pushes - Avoid `systemd`, `apt`, `sudo`, `/tmp` assumptions (use `$TMPDIR`) More error messages and fixes: `references/troubleshooting.md`. ## What to report back State the exact commands run, where the repo lives (must be under `$HOME`), whether auth is token or SSH, and what to do if the step fails. ## Related skills - `systematic-debugging`: diagnose failures with evidence - `secrets-hygiene`: keep tokens out of repos and shell history - `commitsmith`: commit messages for changes made on the phone
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.