From b8b18406d76cb636c7034d0707107129362ea839 Mon Sep 17 00:00:00 2001 From: Amolith Date: Mon, 23 Mar 2026 09:26:36 -0600 Subject: [PATCH] docs(tmux): add filtering, parallel work Add guidance on extracting command output from remote shells using prompt patterns and random anchors. Include section on parallel work with multiple tmux windows for concurrent tasks. Update summary pattern to reference anchor filtering. --- skills/working-with-tmux/SKILL.md | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/skills/working-with-tmux/SKILL.md b/skills/working-with-tmux/SKILL.md index 9821b98b7bb1ae78ce004b600a9b7c3cf697c196..74edbcd09a65ee28fe7929ae6585e4acd85a1c8b 100644 --- a/skills/working-with-tmux/SKILL.md +++ b/skills/working-with-tmux/SKILL.md @@ -61,6 +61,32 @@ tmux capture-pane -p -S - -t "server-log" Prefer to pipe the full scrollback buffer through grep/sed/tac/etc. to view just the content between your last command and the next prompt (exclusive). +### Filtering between prompts + +When running commands on a remote shell, use `sed` to extract output between the shell prompt boundaries: + +```bash +tmux capture-pane -p -S - -t "ID" | sed -n '/PROMPT_PATTERN/,/PROMPT_PATTERN/{//d;p}' +``` + +When prompts are long or appear in scrollback noise, generate random anchors to delimit output cleanly: + +```bash +A=$(openssl rand -hex 4) +tmux send-keys -t "ID" "echo ${A}-st; YOUR_COMMAND; echo ${A}-end" C-m +# Then extract: +tmux capture-pane -p -S - -t "ID" | sed -n '/^'"$A"'-st$/,/^'"$A"'-end$/{/^'"$A"'/d;p}' +``` + +The `-st`/`-end` suffixes prevent matching the anchor inside the echoed command line. + +When scrollback becomes too noisy, clear it: + +```bash +tmux send-keys -t "ID" 'clear' C-m +tmux clear-history -t "ID" +``` + ## 4. Interact with the Process If you need to stop or restart the process: @@ -87,9 +113,23 @@ Example: Create window and start process in one go: tmux new-window -n "server-log" -d ';' send-keys -t "server-log" "npm start" C-m ``` +## 6. Parallel Work + +Spin up multiple windows for independent tasks (downloads, research queries, builds): + +```bash +for name in task-a task-b task-c; do tmux new-window -n "$name" -d; done +``` + +Send commands to each, then check results as they complete. Clean up finished windows: + +```bash +tmux kill-window -t "task-a" +``` + ## Summary of Pattern 0. `echo $TMUX` 1. `tmux new-window -n "ID" -d` 2. `tmux send-keys -t "ID" "CMD" C-m` -3. `tmux capture-pane -p -t "ID"` +3. `tmux capture-pane -p -t "ID"` (with anchor filtering for remote shells)