Skip to main content

Web-based terminal accessible from phone via Cloudflare Tunnel

Project description

Porterminal - Vibe Code From Anywhere

PyPI Python Downloads License CI

1. uvx ptn
2. Scan the QR
3. Access your terminal from your phone

Porterminal demo

Why

I wanted to vibe code from bed.

ngrok requires registration and the free tier sucks. Cloudflare Quick Tunnel works great but is hard to use directly on the phone. Termius requires complicated setup: port forwarding, firewall rules, key management... Tried Claude Code web, but it can't access my local hardware and environment. Also tried Happy, but it's too bulky and updates lag behind.

So I built something simpler: run a command, scan a QR, start typing.

Features

  • One command, instant access - No SSH, no port forwarding, no config files. Cloudflare tunnel + QR code.
  • Actually usable on mobile - Touch-optimized with momentum scrolling, pinch-to-zoom, swipe gestures, and modifier keys (Ctrl, Alt).
  • Full terminal apps - vim, htop, less, tmux all work correctly with proper alt-screen buffer handling.
  • Persistent multi-tab sessions - Sessions survive disconnects. Close the browser, switch networks, reconnect from another device—your shell and running processes are still there. Multiple devices can view the same session simultaneously.
  • Cross-platform - Windows (PowerShell, CMD, WSL), Linux/macOS (Bash, Zsh, Fish, Nushell, and any shell via $SHELL). Auto-detects your shells.

Install

Method Install Update
uvx (no install) uvx ptn uvx --refresh ptn
uv tool uv tool install ptn uv tool upgrade ptn
pipx pipx install ptn pipx upgrade ptn
pip pip install ptn pip install -U ptn

One-line install (uv + ptn):

OS Command
Windows powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/lyehe/porterminal/master/install.ps1 | iex"
macOS/Linux curl -LsSf https://raw.githubusercontent.com/lyehe/porterminal/master/install.sh | sh

Requires Python 3.12+ and cloudflared (auto-installed if missing).

Usage

ptn                    # Start in current directory
ptn ~/projects/myapp   # Start in specific folder
Flag Description
-n, --no-tunnel Local network only (no Cloudflare tunnel)
-b, --background Run in background and return immediately
-p, --password Prompt for password to protect this session
-sp, --save-password Save or clear password in config
-tp, --toggle-password Set password requirement (on/off/true/false) or toggle
-v, --verbose Show detailed startup logs
-i, --init Create .ptn/ptn.yaml config with auto-discovered project scripts
-u, --update Update to the latest version
-c, --check-update Check if a newer version is available
-V, --version Show version

Mobile Gestures

Gesture Action
Tap Focus terminal, clear selection
Long-press Start text selection
Double-tap Select word
Swipe left/right Arrow keys (← →)
Scroll Momentum scrolling with physics
Pinch Zoom text (10-24px)

Modifier keys (Ctrl, Alt, Shift): Tap once for sticky (one keystroke), double-tap for lock.

Compose mode (▤ button): Toggle a text input field where you can type or dictate, edit your text with full mobile editing features (autocorrect, suggestions, cursor positioning), then send to terminal. Useful for longer commands or voice input.

Configuration

Run ptn --init to create a starter config. It auto-discovers project scripts from package.json, pyproject.toml, or Makefile and adds them as buttons:

ptn -i
# Created: .ptn/ptn.yaml
# Discovered 3 project script(s): build, dev, test

Or create ptn.yaml manually:

# Terminal settings
terminal:
  default_shell: nu              # Default shell ID
  shells:                        # Custom shell definitions
    - id: nu
      name: Nushell
      command: nu
      args: []

# Custom buttons (appear in toolbar)
# row: 1 = default row, 2+ = additional rows
buttons:
  - label: "claude"
    send:
      - "claude"
      - 100        # delay in ms
      - "\r"
  - label: "build"
    send: "npm run build\r"
    row: 2         # second button row

# Update checker settings
update:
  notify_on_startup: true   # Show update notification
  check_interval: 86400     # Seconds between checks (default: 24h)

# Security settings
security:
  require_password: true    # Always require password at startup
  password_hash: ""         # Saved password hash (use ptn -sp to set)
  max_auth_attempts: 5      # Max failed attempts before disconnect

Config is searched in order: $PORTERMINAL_CONFIG_PATH, ./ptn.yaml, ./.ptn/ptn.yaml, ~/.ptn/ptn.yaml.

Security

Protect your terminal with a password:

# One-time password (prompt each session)
ptn -p

# Save password to config (no prompt needed)
ptn -sp
# Password: ****
# Confirm password: ****

# Clear saved password (enter empty password)
ptn -sp
# Password: [press Enter]

# Set or toggle password requirement
ptn -tp on       # Enable
ptn -tp off      # Disable
ptn -tp          # Toggle

See docs/security.md for details.

Troubleshooting

Connection fails? Cloudflare tunnel sometimes blocks connections. Restart the server (Ctrl+C, then ptn) to get a fresh tunnel URL.

Shell not detected? Set your $SHELL environment variable or configure shells in ptn.yaml.

Contributing

Issues and PRs welcome.

git clone https://github.com/lyehe/porterminal
cd porterminal
uv sync
uv run ptn

License

AGPL-3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ptn-0.5.6.tar.gz (209.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ptn-0.5.6-py3-none-any.whl (237.1 kB view details)

Uploaded Python 3

File details

Details for the file ptn-0.5.6.tar.gz.

File metadata

  • Download URL: ptn-0.5.6.tar.gz
  • Upload date:
  • Size: 209.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ptn-0.5.6.tar.gz
Algorithm Hash digest
SHA256 bd5312ee8762965f6935a19d40f5860d87193d72cb0a4096d55b5e209c1c806d
MD5 40ad4dc2a6fbfae791f5aa29cd0efa69
BLAKE2b-256 88bcfdcede776c8521223583d33b080ebb7817d726ab37a00d190a271e018789

See more details on using hashes here.

Provenance

The following attestation bundles were made for ptn-0.5.6.tar.gz:

Publisher: publish.yml on lyehe/porterminal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ptn-0.5.6-py3-none-any.whl.

File metadata

  • Download URL: ptn-0.5.6-py3-none-any.whl
  • Upload date:
  • Size: 237.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ptn-0.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2e0ac7050ffdf8fd9b3e6ab2b3b6a4345e413581640b4f8a8ec10728df9c434f
MD5 e2d0fbaea752e2a1cb4e4ecda5696c6f
BLAKE2b-256 64f2e74c8b907bc0ee569b347e90de110d3d205b0c04eb5bdba8b35720c8d905

See more details on using hashes here.

Provenance

The following attestation bundles were made for ptn-0.5.6-py3-none-any.whl:

Publisher: publish.yml on lyehe/porterminal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page