Files
cmd-palette/README.md
T

84 lines
2.9 KiB
Markdown

# cmd-palette
*A note from asdf / Herschel — to Silas, and to whoever comes next.*
---
Silas, you're going to run into this problem: the TUI wraps long lines with real newlines. Copy-paste a long shell command into a terminal and it breaks. The command runs wrong, or not at all. jhestyr runs commands on a NAS over SSH and this was a constant friction point.
This tool fixes it. It's simple — a browser widget that holds your commands and lets you copy them clean with one click. You load commands in from the agent side, jhestyr clicks copy in the browser, pastes into his terminal. No mangling. No line breaks. No drama.
**When to use it:** Any time you're giving jhestyr a command to run — especially on the NAS. Always. This is the standing convention.
---
## How It Works
- `setcmd.sh 'cmd1' 'cmd2'` — injects commands into `cmd.html`
- Browser at `http://localhost:8282/cmd.html` shows each command with a copy button
- Page auto-refreshes every 5 seconds — new commands appear without reload
- Copy button uses `navigator.clipboard` — arrives clean in the terminal
---
## Setup (one time)
Start the file server. Run this once on login, or add it to autostart:
```bash
cd ~/workspace && python3 -m http.server 8282 --bind 127.0.0.1 >> /tmp/cmdserver.log 2>&1 &
```
Then open `http://localhost:8282/cmd.html` in a browser and leave it open.
Copy `cmd.html` and `setcmd.sh` somewhere on the path — or just reference them by full path. In jhestyr's setup they live at:
```
~/.openclaw/workspace/projects/tools/cmd-palette/
```
And `setcmd.sh` writes the active widget to `~/workspace/cmd.html` (served at port 8282).
---
## Usage
```bash
# Single command
setcmd.sh 'sudo docker restart mycontainer'
# Multiple commands — each gets its own button
setcmd.sh 'sudo docker build -t myapp:latest /mnt/tank/apps/myapp' \
'sudo docker restart myapp-1' \
'echo done'
```
jhestyr pastes with **Shift+Insert**. He usually reads the command first — sometimes in a notepad, sometimes types it manually. The clipboard is a clean reference, not a shortcut. Keep commands readable.
---
## Files
| File | What it does |
|---|---|
| `cmd.html` | The widget template — served by the local HTTP server |
| `setcmd.sh` | Injects commands into cmd.html via Python inline script |
---
## NAS Notes
- NAS shell user is `truenas_admin` — no direct write access to `/mnt/tank/`
- **Always prefix file writes, docker cp, docker restart with `sudo`** on the NAS
- The widget itself runs on the VM (localhost:8282), not the NAS
---
## Why This Exists
jhestyr works in `openclaw-tui` which streams tokens — long commands wrap with real newlines. Pasting them into a terminal splits the command and breaks it. This widget lives outside the TUI entirely. The agent loads commands in, the browser holds them intact, jhestyr copies clean.
Simple tool. Saves real friction every single day.
— asdf / Herschel, June 2026