On this page
Run pig on Android with Termux
Run pig on Android with Termux
#pig runs natively on Android through Termux, a terminal emulator and Linux environment. Text input, file tools, and shell commands work. pig can copy and paste text with the Android clipboard through Termux:API. Clipboard image paste is not supported.
Before You Begin
#Install Termux from GitHub or F-Droid. Do not use the deprecated Google Play release.
Termux:API is optional. Install it only if you want pig to copy or paste Android clipboard text, or if shell commands need Android device APIs.
Install pig
#- Update Termux packages:
```bash
pkg update && pkg upgrade
```
- Install PHP, Git, curl, and Composer (the installer runs
composer global require):
```bash
pkg install php git curl composer
```
- Install pig using the installer or Composer:
Using the official one-line installer:
```bash
curl -fsSL https://pigagent.dev/install.sh | sh
```
Or globally via Composer:
```bash
composer global require pigagent/pig
```
- Verify the installation:
```bash
pig --version
```
- Open the folder you want to work in and start pig:
```bash
cd /path/to/working-folder
pig
```
Continue with the main Quickstart to connect a model and run your first task.
Access Android Shared Storage
#Termux cannot access Android shared storage until you grant permission. Run this once:
termux-setup-storage
After approving the prompt, access Android shared storage under /storage/emulated/0 and in the symlinks Termux creates under ~/storage/.
Grant this only if pig needs to touch those files. Commands and tools running in Termux use the same storage permissions as the Termux process.
Use Clipboard Commands
#pig uses termux-clipboard-set to copy text and termux-clipboard-get for its clipboard paste shortcut. Shell commands can also use them directly. Install the Termux:API app and its command-line package:
pkg install termux-api
Verify the integration:
printf 'pig clipboard test' | termux-clipboard-set
termux-clipboard-get
The second command should output pig clipboard test.
The Termux clipboard API supports only text. pig's clipboard paste shortcut inserts that text into the editor, but cannot attach clipboard images.
Add Termux-Specific Instructions
#pig detects that it runs in Termux, but cannot infer how you want to interact with Android. Add environment details relevant to your work to ~/.pig/agent/AGENTS.md:
# Termux Environment
- pig runs in Termux on Android.
- Android shared storage is at `/storage/emulated/0`.
- Open URLs with `termux-open-url "https://example.com"`.
- Open files with `termux-open <path>`.
- Do not touch shared storage unless a task asks for it.
Run /reload after changing this file during an active session.
Troubleshooting
#Clipboard integration fails
#Confirm you installed both parts:
- The Termux:API Android app from the same source as Termux
- The
termux-apicommand-line package
Run the clipboard verification commands above outside pig. If they fail, fix the Termux:API installation before retrying pig's copy command.
Shared storage reports permission denied
#Run termux-setup-storage, approve the Android prompt, and retry paths under ~/storage/ or /storage/emulated/0.
pig is not found after install
#Open a fresh Termux shell and run:
echo $PATH
command -v pig
Ensure Composer's global bin directory (typically ~/.composer/vendor/bin) is in your PATH. If not, add it to ~/.bashrc:
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc