[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73GD06T10M6TJTSC4HMPRWF":3,"skill-same:01M73GD06T10M6TJTSC4HMPRWF":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":45,"ownerHtmlUrl":46,"ownerBlogUrl":47,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M73GD06T10M6TJTSC4HMPRWF","tmux",null,"Expert tmux session, window, and pane management for terminal multiplexing, persistent remote workflows, and shell scripting automation.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Ftmux\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: tmux\ndescription: \"Expert tmux session, window, and pane management for terminal multiplexing, persistent remote workflows, and shell scripting automation.\"\ncategory: development\nrisk: safe\nsource: community\ndate_added: \"2026-03-28\"\nauthor: kostakost2\ntags: [tmux, terminal, multiplexer, sessions, shell, remote, automation]\ntools: [claude, cursor, gemini]\n---\n\n# tmux — Terminal Multiplexer\n\n## Overview\n\n`tmux` keeps terminal sessions alive across SSH disconnects, splits work across multiple panes, and enables fully scriptable terminal automation. This skill covers session management, window\u002Fpane layout, keybinding patterns, and using `tmux` non-interactively from shell scripts — essential for remote servers, long-running jobs, and automated workflows.\n\n## When to Use This Skill\n\n- Use when setting up or managing persistent terminal sessions on remote servers\n- Use when the user needs to run long-running processes that survive SSH disconnects\n- Use when scripting multi-pane terminal layouts (e.g., logs + shell + editor)\n- Use when automating `tmux` commands from bash scripts without user interaction\n\n## How It Works\n\n`tmux` has three hierarchy levels: **sessions** (top level, survives disconnects), **windows** (tabs within a session), and **panes** (splits within a window). Everything is controllable from outside via `tmux \u003Ccommand>` or from inside via the prefix key (`Ctrl-b` by default).\n\n### Session Management\n\n```bash\n# Create a new named session\ntmux new-session -s work\n\n# Create detached (background) session\ntmux new-session -d -s work\n\n# Create detached session and start a command\ntmux new-session -d -s build -x 220 -y 50 \"make all\"\n\n# Attach to a session\ntmux attach -t work\ntmux attach          # attaches to most recent session\n\n# List all sessions\ntmux list-sessions\ntmux ls\n\n# Detach from inside tmux\n# Prefix + d   (Ctrl-b d)\n\n# Kill a session\ntmux kill-session -t work\n\n# Kill all sessions except the current one\ntmux kill-session -a\n\n# Rename a session from outside\ntmux rename-session -t old-name new-name\n\n# Switch to another session from outside\ntmux switch-client -t other-session\n\n# Check if a session exists (useful in scripts)\ntmux has-session -t work 2>\u002Fdev\u002Fnull && echo \"exists\"\n```\n\n### Window Management\n\n```bash\n# Create a new window in the current session\ntmux new-window -t work -n \"logs\"\n\n# Create a window running a specific command\ntmux new-window -t work:3 -n \"server\" \"python -m http.server 8080\"\n\n# List windows\ntmux list-windows -t work\n\n# Select (switch to) a window\ntmux select-window -t work:logs\ntmux select-window -t work:2       # by index\n\n# Rename a window\ntmux rename-window -t work:2 \"editor\"\n\n# Kill a window\ntmux kill-window -t work:logs\n\n# Move window to a new index\ntmux move-window -s work:3 -t work:1\n\n# From inside tmux:\n# Prefix + c     — new window\n# Prefix + ,     — rename window\n# Prefix + &     — kill window\n# Prefix + n\u002Fp   — next\u002Fprevious window\n# Prefix + 0-9   — switch to window by number\n```\n\n### Pane Management\n\n```bash\n# Split pane vertically (left\u002Fright)\ntmux split-window -h -t work:1\n\n# Split pane horizontally (top\u002Fbottom)\ntmux split-window -v -t work:1\n\n# Split and run a command\ntmux split-window -h -t work:1 \"tail -f \u002Fvar\u002Flog\u002Fsyslog\"\n\n# Select a pane by index\ntmux select-pane -t work:1.0\n\n# Resize panes\ntmux resize-pane -t work:1.0 -R 20   # expand right by 20 cols\ntmux resize-pane -t work:1.0 -D 10   # shrink down by 10 rows\ntmux resize-pane -Z                   # toggle zoom (fullscreen)\n\n# Swap panes\ntmux swap-pane -s work:1.0 -t work:1.1\n\n# Kill a pane\ntmux kill-pane -t work:1.1\n\n# From inside tmux:\n# Prefix + %     — split vertical\n# Prefix + \"     — split horizontal\n# Prefix + arrow — navigate panes\n# Prefix + z     — zoom\u002Funzoom current pane\n# Prefix + x     — kill pane\n# Prefix + {\u002F}   — swap pane with previous\u002Fnext\n```\n\n### Sending Commands to Panes Without Being Attached\n\n```bash\n# Send a command to a specific pane and press Enter\ntmux send-keys -t work:1.0 \"ls -la\" Enter\n\n# Run a command in a background pane without attaching\ntmux send-keys -t work:editor \"vim src\u002Fmain.py\" Enter\n\n# Send Ctrl+C to stop a running process\ntmux send-keys -t work:1.0 C-c\n\n# Send text without pressing Enter (useful for pre-filling prompts)\ntmux send-keys -t work:1.0 \"git commit -m '\"\n\n# Clear a pane\ntmux send-keys -t work:1.0 \"clear\" Enter\n\n# Check what's in a pane (capture its output)\ntmux capture-pane -t work:1.0 -p\ntmux capture-pane -t work:1.0 -p | grep \"ERROR\"\n```\n\n### Scripting a Full Workspace Layout\n\nThis is the most powerful pattern: create a fully configured multi-pane workspace from a single script.\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n\nSESSION=\"dev\"\n\n# Bail if session already exists\ntmux has-session -t \"$SESSION\" 2>\u002Fdev\u002Fnull && {\n  echo \"Session $SESSION already exists. Attaching...\"\n  tmux attach -t \"$SESSION\"\n  exit 0\n}\n\n# Create session with first window\ntmux new-session -d -s \"$SESSION\" -n \"editor\" -x 220 -y 50\n\n# Window 1: editor + test runner side by side\ntmux send-keys -t \"$SESSION:editor\" \"vim .\" Enter\ntmux split-window -h -t \"$SESSION:editor\"\ntmux send-keys -t \"$SESSION:editor.1\" \"npm test -- --watch\" Enter\ntmux select-pane -t \"$SESSION:editor.0\"\n\n# Window 2: server logs\ntmux new-window -t \"$SESSION\" -n \"server\"\ntmux send-keys -t \"$SESSION:server\" \"docker compose up\" Enter\ntmux split-window -v -t \"$SESSION:server\"\ntmux send-keys -t \"$SESSION:server.1\" \"tail -f logs\u002Fapp.log\" Enter\n\n# Window 3: general shell\ntmux new-window -t \"$SESSION\" -n \"shell\"\n\n# Focus first window\ntmux select-window -t \"$SESSION:editor\"\n\n# Attach\ntmux attach -t \"$SESSION\"\n```\n\n### Configuration (`~\u002F.tmux.conf`)\n\n```bash\n# Change prefix to Ctrl-a (screen-style)\nunbind C-b\nset -g prefix C-a\nbind C-a send-prefix\n\n# Enable mouse support\nset -g mouse on\n\n# Start window\u002Fpane numbering at 1\nset -g base-index 1\nsetw -g pane-base-index 1\n\n# Renumber windows when one is closed\nset -g renumber-windows on\n\n# Increase scrollback buffer\nset -g history-limit 50000\n\n# Use vi keys in copy mode\nsetw -g mode-keys vi\n\n# Faster key repetition\nset -s escape-time 0\n\n# Reload config without restarting\nbind r source-file ~\u002F.tmux.conf \\; display \"Config reloaded\"\n\n# Intuitive splits: | and -\nbind | split-window -h -c \"#{pane_current_path}\"\nbind - split-window -v -c \"#{pane_current_path}\"\n\n# New windows open in current directory\nbind c new-window -c \"#{pane_current_path}\"\n\n# Status bar\nset -g status-right \"#{session_name} | %H:%M %d-%b\"\nset -g status-interval 5\n```\n\n### Copy Mode and Scrollback\n\n```bash\n# Enter copy mode (scroll up through output)\n# Prefix + [\n\n# In vi mode:\n# \u002F to search forward, ? to search backward\n# Space to start selection, Enter to copy\n# q to exit copy mode\n\n# Paste the most recent buffer\n# Prefix + ]\n\n# List paste buffers\ntmux list-buffers\n\n# Show the most recent buffer\ntmux show-buffer\n\n# Save buffer to a file\ntmux save-buffer \u002Ftmp\u002Ftmux-output.txt\n\n# Load a file into a buffer\ntmux load-buffer \u002Ftmp\u002Fdata.txt\n\n# Pipe pane output to a command\ntmux pipe-pane -t work:1.0 \"cat >> ~\u002Fsession.log\"\n```\n\n### Practical Automation Patterns\n\n```bash\n# Idempotent session: create or attach\nensure_session() {\n  local name=\"$1\"\n  tmux has-session -t \"$name\" 2>\u002Fdev\u002Fnull \\\n    || tmux new-session -d -s \"$name\"\n  tmux attach -t \"$name\"\n}\n\n# Run a command in a new background window and tail its output\nrun_bg() {\n  local session=\"${1:-main}\" cmd=\"${*:2}\"\n  tmux new-window -t \"$session\" -n \"bg-$$\"\n  tmux send-keys -t \"$session:bg-$$\" \"$cmd\" Enter\n}\n\n# Wait for a pane to produce specific output (polling)\nwait_for_output() {\n  local target=\"$1\" pattern=\"$2\" timeout=\"${3:-30}\"\n  local elapsed=0\n  while (( elapsed \u003C timeout )); do\n    tmux capture-pane -t \"$target\" -p | grep -q \"$pattern\" && return 0\n    sleep 1\n    (( elapsed++ ))\n  done\n  return 1\n}\n\n# Kill all background windows matching a name prefix\nkill_bg_windows() {\n  local session=\"$1\" prefix=\"${2:-bg-}\"\n  tmux list-windows -t \"$session\" -F \"#W\" \\\n    | grep \"^${prefix}\" \\\n    | while read -r win; do\n        tmux kill-window -t \"${session}:${win}\"\n      done\n}\n```\n\n### Remote and SSH Workflows\n\n```bash\n# SSH and immediately attach to an existing session\nssh user@host -t \"tmux attach -t work || tmux new-session -s work\"\n\n# Run a command on remote host inside a tmux session (fire and forget)\nssh user@host \"tmux new-session -d -s deploy 'bash \u002Fopt\u002Fdeploy.sh'\"\n\n# Watch the remote session output from another terminal\nssh user@host -t \"tmux attach -t deploy -r\"  # read-only attach\n\n# Pair programming: share a session (both users attach to the same session)\n# User 1:\ntmux new-session -s shared\n# User 2 (same server):\ntmux attach -t shared\n```\n\n## Best Practices\n\n- Always name sessions (`-s name`) in scripts — unnamed sessions are hard to target reliably\n- Use `tmux has-session -t name 2>\u002Fdev\u002Fnull` before creating to make scripts idempotent\n- Set `-x` and `-y` when creating detached sessions to give panes a proper size for commands that check terminal dimensions\n- Use `send-keys ... Enter` for automation rather than piping stdin — it works even when the target pane is running an interactive program\n- Keep `~\u002F.tmux.conf` in version control for reproducibility across machines\n- Prefer `bind -n` for bindings that don't need the prefix, but only for keys that don't conflict with application shortcuts\n\n## Security & Safety Notes\n\n- `send-keys` executes commands in a pane without confirmation — verify the target (`-t session:window.pane`) before use in scripts to avoid sending keystrokes to the wrong pane\n- Read-only attach (`-r`) is appropriate when sharing sessions with others to prevent accidental input\n- Avoid storing secrets in tmux window\u002Fpane titles or environment variables exported into sessions on shared machines\n\n## Common Pitfalls\n\n- **Problem:** `tmux` commands from a script fail with \"no server running\"\n  **Solution:** Start the server first with `tmux start-server`, or create a detached session before running other commands.\n\n- **Problem:** Pane size is 0x0 when creating a detached session\n  **Solution:** Pass explicit dimensions: `tmux new-session -d -s name -x 200 -y 50`.\n\n- **Problem:** `send-keys` types the text but doesn't run the command\n  **Solution:** Ensure you pass `Enter` (capital E) as a second argument: `tmux send-keys -t target \"cmd\" Enter`.\n\n- **Problem:** Script creates a duplicate session each run\n  **Solution:** Guard with `tmux has-session -t name 2>\u002Fdev\u002Fnull || tmux new-session -d -s name`.\n\n- **Problem:** Copy-mode selection doesn't work as expected\n  **Solution:** Confirm `mode-keys vi` or `mode-keys emacs` is set to match your preference in `~\u002F.tmux.conf`.\n\n## Controlling Interactive TUI Programs\n# Source: obra\u002Fsuperpowers-lab (MIT) — superpowers-lab\u002Fskills\u002Fusing-tmux-for-interactive-commands\n\nDùng tmux để lập trình control các TUI tools (vim, git rebase, Python REPL, psql...)\nmà không thể dùng stdin redirect thông thường.\n\n```bash\n# Pattern chuẩn: create → wait → send-keys → capture → loop → kill\nSESSION=\"interactive-$$\"\n\n# 1. Tạo detached session với TUI tool\ntmux new-session -d -s \"$SESSION\" -x 200 -y 50 \"vim myfile.py\"\nsleep 0.3   # đợi TUI initialize (100-500ms tùy tool)\n\n# 2. Gửi keystrokes (dùng tmux key names, không phải escape sequences)\ntmux send-keys -t \"$SESSION\" \"i\"        # enter insert mode\ntmux send-keys -t \"$SESSION\" \"hello\"    # type text\ntmux send-keys -t \"$SESSION\" \"Escape\"   # exit insert mode — NOT \\x1b\ntmux send-keys -t \"$SESSION\" \":wq\" Enter\n\n# 3. Capture output để kiểm tra\ntmux capture-pane -t \"$SESSION\" -p\n\n# 4. Cleanup\ntmux kill-session -t \"$SESSION\"\n```\n\n**Wait-for-prompt helper** (dùng khi TUI cần load time):\n\n```bash\nwait_for_prompt() {\n  local target=\"$1\" pattern=\"$2\" timeout=\"${3:-10}\"\n  for ((i=0; i\u003Ctimeout*10; i++)); do\n    tmux capture-pane -t \"$target\" -p | grep -q \"$pattern\" && return 0\n    sleep 0.1\n  done\n  return 1   # timeout\n}\n\n# Ví dụ: đợi Python REPL sẵn sàng\ntmux new-session -d -s py -x 200 -y 50 \"python3\"\nwait_for_prompt py \">>>\" 5\ntmux send-keys -t py \"print('hello')\" Enter\nsleep 0.2\ntmux capture-pane -t py -p | grep \"hello\"\ntmux kill-session -t py\n```\n\n**Các TUI tool phổ biến + gotchas:**\n\n```bash\n# git rebase -i\ntmux new-session -d -s rebase -x 200 -y 50 \"git rebase -i HEAD~3\"\nsleep 0.5  # vim cần thêm thời gian\ntmux send-keys -t rebase \":2s\u002Fpick\u002Fsquash\u002F\" Enter  # squash line 2\ntmux send-keys -t rebase \":wq\" Enter\n\n# psql interactive\ntmux new-session -d -s db -x 200 -y 50 \"psql -U postgres mydb\"\nwait_for_prompt db \"=#\" 5\ntmux send-keys -t db \"SELECT COUNT(*) FROM users;\" Enter\nsleep 0.3\ntmux capture-pane -t db -p | grep -A2 \"count\"\ntmux send-keys -t db \"\\\\q\" Enter\ntmux kill-session -t db\n```\n\n**Lỗi thường gặp:**\n- **Premature capture**: luôn sleep sau khi start, trước capture\n- **Missing Enter**: `send-keys \"cmd\" Enter` — Enter là argument riêng\n- **Wrong key names**: dùng `Enter Escape Tab` (Pascal case), không phải `\\n \\x1b \\t`\n- **Orphaned sessions**: luôn `kill-session` sau khi xong\n\n## Related Skills\n\n- `@bash-pro` — Writing the shell scripts that orchestrate tmux sessions\n- `@bash-linux` — General Linux terminal patterns used inside tmux panes\n- `@ssh` — Combining tmux with SSH for persistent remote workflows\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","# tmux — Terminal Multiplexer\n\n## Overview\n\n`tmux` keeps terminal sessions alive across SSH disconnects, splits work across multiple panes, and enables fully scriptable terminal automation. This skill covers session management, window\u002Fpane layout, keybinding patterns, and using `tmux` non-interactively from shell scripts — essential for remote servers, long-running jobs, and automated workflows.\n\n## When to Use This Skill\n\n- Use when setting up or managing persistent terminal sessions on remote servers\n- Use when the user needs to run long-running processes that survive SSH disconnects\n- Use when scripting multi-pane terminal layouts (e.g., logs + shell + editor)\n- Use when automating `tmux` commands from bash scripts without user interaction\n\n## How It Works\n\n`tmux` has three hierarchy levels: **sessions** (top level, survives disconnects), **windows** (tabs within a session), and **panes** (splits within a window). Everything is controllable from outside via `tmux \u003Ccommand>` or from inside via the prefix key (`Ctrl-b` by default).\n\n### Session Management\n\n```bash\n# Create a new named session\ntmux new-session -s work\n\n# Create detached (background) session\ntmux new-session -d -s work\n\n# Create detached session and start a command\ntmux new-session -d -s build -x 220 -y 50 \"make all\"\n\n# Attach to a session\ntmux attach -t work\ntmux attach          # attaches to most recent session\n\n# List all sessions\ntmux list-sessions\ntmux ls\n\n# Detach from inside tmux\n# Prefix + d   (Ctrl-b d)\n\n# Kill a session\ntmux kill-session -t work\n\n# Kill all sessions except the current one\ntmux kill-session -a\n\n# Rename a session from outside\ntmux rename-session -t old-name new-name\n\n# Switch to another session from outside\ntmux switch-client -t other-session\n\n# Check if a session exists (useful in scripts)\ntmux has-session -t work 2>\u002Fdev\u002Fnull && echo \"exists\"\n```\n\n### Window Management\n\n```bash\n# Create a new window in the current session\ntmux new-window -t work -n \"logs\"\n\n# Create a window running a specific command\ntmux new-window -t work:3 -n \"server\" \"python -m http.server 8080\"\n\n# List windows\ntmux list-windows -t work\n\n# Select (switch to) a window\ntmux select-window -t work:logs\ntmux select-window -t work:2       # by index\n\n# Rename a window\ntmux rename-window -t work:2 \"editor\"\n\n# Kill a window\ntmux kill-window -t work:logs\n\n# Move window to a new index\ntmux move-window -s work:3 -t work:1\n\n# From inside tmux:\n# Prefix + c     — new window\n# Prefix + ,     — rename window\n# Prefix + &     — kill window\n# Prefix + n\u002Fp   — next\u002Fprevious window\n# Prefix + 0-9   — switch to window by number\n```\n\n### Pane Management\n\n```bash\n# Split pane vertically (left\u002Fright)\ntmux split-window -h -t work:1\n\n# Split pane horizontally (top\u002Fbottom)\ntmux split-window -v -t work:1\n\n# Split and run a command\ntmux split-window -h -t work:1 \"tail -f \u002Fvar\u002Flog\u002Fsyslog\"\n\n# Select a pane by index\ntmux select-pane -t work:1.0\n\n# Resize panes\ntmux resize-pane -t work:1.0 -R 20   # expand right by 20 cols\ntmux resize-pane -t work:1.0 -D 10   # shrink down by 10 rows\ntmux resize-pane -Z                   # toggle zoom (fullscreen)\n\n# Swap panes\ntmux swap-pane -s work:1.0 -t work:1.1\n\n# Kill a pane\ntmux kill-pane -t work:1.1\n\n# From inside tmux:\n# Prefix + %     — split vertical\n# Prefix + \"     — split horizontal\n# Prefix + arrow — navigate panes\n# Prefix + z     — zoom\u002Funzoom current pane\n# Prefix + x     — kill pane\n# Prefix + {\u002F}   — swap pane with previous\u002Fnext\n```\n\n### Sending Commands to Panes Without Being Attached\n\n```bash\n# Send a command to a specific pane and press Enter\ntmux send-keys -t work:1.0 \"ls -la\" Enter\n\n# Run a command in a background pane without attaching\ntmux send-keys -t work:editor \"vim src\u002Fmain.py\" Enter\n\n# Send Ctrl+C to stop a running process\ntmux send-keys -t work:1.0 C-c\n\n# Send text without pressing Enter (useful for pre-filling prompts)\ntmux send-keys -t work:1.0 \"git commit -m '\"\n\n# Clear a pane\ntmux send-keys -t work:1.0 \"clear\" Enter\n\n# Check what's in a pane (capture its output)\ntmux capture-pane -t work:1.0 -p\ntmux capture-pane -t work:1.0 -p | grep \"ERROR\"\n```\n\n### Scripting a Full Workspace Layout\n\nThis is the most powerful pattern: create a fully configured multi-pane workspace from a single script.\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n\nSESSION=\"dev\"\n\n# Bail if session already exists\ntmux has-session -t \"$SESSION\" 2>\u002Fdev\u002Fnull && {\n  echo \"Session $SESSION already exists. Attaching...\"\n  tmux attach -t \"$SESSION\"\n  exit 0\n}\n\n# Create session with first window\ntmux new-session -d -s \"$SESSION\" -n \"editor\" -x 220 -y 50\n\n# Window 1: editor + test runner side by side\ntmux send-keys -t \"$SESSION:editor\" \"vim .\" Enter\ntmux split-window -h -t \"$SESSION:editor\"\ntmux send-keys -t \"$SESSION:editor.1\" \"npm test -- --watch\" Enter\ntmux select-pane -t \"$SESSION:editor.0\"\n\n# Window 2: server logs\ntmux new-window -t \"$SESSION\" -n \"server\"\ntmux send-keys -t \"$SESSION:server\" \"docker compose up\" Enter\ntmux split-window -v -t \"$SESSION:server\"\ntmux send-keys -t \"$SESSION:server.1\" \"tail -f logs\u002Fapp.log\" Enter\n\n# Window 3: general shell\ntmux new-window -t \"$SESSION\" -n \"shell\"\n\n# Focus first window\ntmux select-window -t \"$SESSION:editor\"\n\n# Attach\ntmux attach -t \"$SESSION\"\n```\n\n### Configuration (`~\u002F.tmux.conf`)\n\n```bash\n# Change prefix to Ctrl-a (screen-style)\nunbind C-b\nset -g prefix C-a\nbind C-a send-prefix\n\n# Enable mouse support\nset -g mouse on\n\n# Start window\u002Fpane numbering at 1\nset -g base-index 1\nsetw -g pane-base-index 1\n\n# Renumber windows when one is closed\nset -g renumber-windows on\n\n# Increase scrollback buffer\nset -g history-limit 50000\n\n# Use vi keys in copy mode\nsetw -g mode-keys vi\n\n# Faster key repetition\nset -s escape-time 0\n\n# Reload config without restarting\nbind r source-file ~\u002F.tmux.conf \\; display \"Config reloaded\"\n\n# Intuitive splits: | and -\nbind | split-window -h -c \"#{pane_current_path}\"\nbind - split-window -v -c \"#{pane_current_path}\"\n\n# New windows open in current directory\nbind c new-window -c \"#{pane_current_path}\"\n\n# Status bar\nset -g status-right \"#{session_name} | %H:%M %d-%b\"\nset -g status-interval 5\n```\n\n### Copy Mode and Scrollback\n\n```bash\n# Enter copy mode (scroll up through output)\n# Prefix + [\n\n# In vi mode:\n# \u002F to search forward, ? to search backward\n# Space to start selection, Enter to copy\n# q to exit copy mode\n\n# Paste the most recent buffer\n# Prefix + ]\n\n# List paste buffers\ntmux list-buffers\n\n# Show the most recent buffer\ntmux show-buffer\n\n# Save buffer to a file\ntmux save-buffer \u002Ftmp\u002Ftmux-output.txt\n\n# Load a file into a buffer\ntmux load-buffer \u002Ftmp\u002Fdata.txt\n\n# Pipe pane output to a command\ntmux pipe-pane -t work:1.0 \"cat >> ~\u002Fsession.log\"\n```\n\n### Practical Automation Patterns\n\n```bash\n# Idempotent session: create or attach\nensure_session() {\n  local name=\"$1\"\n  tmux has-session -t \"$name\" 2>\u002Fdev\u002Fnull \\\n    || tmux new-session -d -s \"$name\"\n  tmux attach -t \"$name\"\n}\n\n# Run a command in a new background window and tail its output\nrun_bg() {\n  local session=\"${1:-main}\" cmd=\"${*:2}\"\n  tmux new-window -t \"$session\" -n \"bg-$$\"\n  tmux send-keys -t \"$session:bg-$$\" \"$cmd\" Enter\n}\n\n# Wait for a pane to produce specific output (polling)\nwait_for_output() {\n  local target=\"$1\" pattern=\"$2\" timeout=\"${3:-30}\"\n  local elapsed=0\n  while (( elapsed \u003C timeout )); do\n    tmux capture-pane -t \"$target\" -p | grep -q \"$pattern\" && return 0\n    sleep 1\n    (( elapsed++ ))\n  done\n  return 1\n}\n\n# Kill all background windows matching a name prefix\nkill_bg_windows() {\n  local session=\"$1\" prefix=\"${2:-bg-}\"\n  tmux list-windows -t \"$session\" -F \"#W\" \\\n    | grep \"^${prefix}\" \\\n    | while read -r win; do\n        tmux kill-window -t \"${session}:${win}\"\n      done\n}\n```\n\n### Remote and SSH Workflows\n\n```bash\n# SSH and immediately attach to an existing session\nssh user@host -t \"tmux attach -t work || tmux new-session -s work\"\n\n# Run a command on remote host inside a tmux session (fire and forget)\nssh user@host \"tmux new-session -d -s deploy 'bash \u002Fopt\u002Fdeploy.sh'\"\n\n# Watch the remote session output from another terminal\nssh user@host -t \"tmux attach -t deploy -r\"  # read-only attach\n\n# Pair programming: share a session (both users attach to the same session)\n# User 1:\ntmux new-session -s shared\n# User 2 (same server):\ntmux attach -t shared\n```\n\n## Best Practices\n\n- Always name sessions (`-s name`) in scripts — unnamed sessions are hard to target reliably\n- Use `tmux has-session -t name 2>\u002Fdev\u002Fnull` before creating to make scripts idempotent\n- Set `-x` and `-y` when creating detached sessions to give panes a proper size for commands that check terminal dimensions\n- Use `send-keys ... Enter` for automation rather than piping stdin — it works even when the target pane is running an interactive program\n- Keep `~\u002F.tmux.conf` in version control for reproducibility across machines\n- Prefer `bind -n` for bindings that don't need the prefix, but only for keys that don't conflict with application shortcuts\n\n## Security & Safety Notes\n\n- `send-keys` executes commands in a pane without confirmation — verify the target (`-t session:window.pane`) before use in scripts to avoid sending keystrokes to the wrong pane\n- Read-only attach (`-r`) is appropriate when sharing sessions with others to prevent accidental input\n- Avoid storing secrets in tmux window\u002Fpane titles or environment variables exported into sessions on shared machines\n\n## Common Pitfalls\n\n- **Problem:** `tmux` commands from a script fail with \"no server running\"\n  **Solution:** Start the server first with `tmux start-server`, or create a detached session before running other commands.\n\n- **Problem:** Pane size is 0x0 when creating a detached session\n  **Solution:** Pass explicit dimensions: `tmux new-session -d -s name -x 200 -y 50`.\n\n- **Problem:** `send-keys` types the text but doesn't run the command\n  **Solution:** Ensure you pass `Enter` (capital E) as a second argument: `tmux send-keys -t target \"cmd\" Enter`.\n\n- **Problem:** Script creates a duplicate session each run\n  **Solution:** Guard with `tmux has-session -t name 2>\u002Fdev\u002Fnull || tmux new-session -d -s name`.\n\n- **Problem:** Copy-mode selection doesn't work as expected\n  **Solution:** Confirm `mode-keys vi` or `mode-keys emacs` is set to match your preference in `~\u002F.tmux.conf`.\n\n## Controlling Interactive TUI Programs\n# Source: obra\u002Fsuperpowers-lab (MIT) — superpowers-lab\u002Fskills\u002Fusing-tmux-for-interactive-commands\n\nDùng tmux để lập trình control các TUI tools (vim, git rebase, Python REPL, psql...)\nmà không thể dùng stdin redirect thông thường.\n\n```bash\n# Pattern chuẩn: create → wait → send-keys → capture → loop → kill\nSESSION=\"interactive-$$\"\n\n# 1. Tạo detached session với TUI tool\ntmux new-session -d -s \"$SESSION\" -x 200 -y 50 \"vim myfile.py\"\nsleep 0.3   # đợi TUI initialize (100-500ms tùy tool)\n\n# 2. Gửi keystrokes (dùng tmux key names, không phải escape sequences)\ntmux send-keys -t \"$SESSION\" \"i\"        # enter insert mode\ntmux send-keys -t \"$SESSION\" \"hello\"    # type text\ntmux send-keys -t \"$SESSION\" \"Escape\"   # exit insert mode — NOT \\x1b\ntmux send-keys -t \"$SESSION\" \":wq\" Enter\n\n# 3. Capture output để kiểm tra\ntmux capture-pane -t \"$SESSION\" -p\n\n# 4. Cleanup\ntmux kill-session -t \"$SESSION\"\n```\n\n**Wait-for-prompt helper** (dùng khi TUI cần load time):\n\n```bash\nwait_for_prompt() {\n  local target=\"$1\" pattern=\"$2\" timeout=\"${3:-10}\"\n  for ((i=0; i\u003Ctimeout*10; i++)); do\n    tmux capture-pane -t \"$target\" -p | grep -q \"$pattern\" && return 0\n    sleep 0.1\n  done\n  return 1   # timeout\n}\n\n# Ví dụ: đợi Python REPL sẵn sàng\ntmux new-session -d -s py -x 200 -y 50 \"python3\"\nwait_for_prompt py \">>>\" 5\ntmux send-keys -t py \"print('hello')\" Enter\nsleep 0.2\ntmux capture-pane -t py -p | grep \"hello\"\ntmux kill-session -t py\n```\n\n**Các TUI tool phổ biến + gotchas:**\n\n```bash\n# git rebase -i\ntmux new-session -d -s rebase -x 200 -y 50 \"git rebase -i HEAD~3\"\nsleep 0.5  # vim cần thêm thời gian\ntmux send-keys -t rebase \":2s\u002Fpick\u002Fsquash\u002F\" Enter  # squash line 2\ntmux send-keys -t rebase \":wq\" Enter\n\n# psql interactive\ntmux new-session -d -s db -x 200 -y 50 \"psql -U postgres mydb\"\nwait_for_prompt db \"=#\" 5\ntmux send-keys -t db \"SELECT COUNT(*) FROM users;\" Enter\nsleep 0.3\ntmux capture-pane -t db -p | grep -A2 \"count\"\ntmux send-keys -t db \"\\\\q\" Enter\ntmux kill-session -t db\n```\n\n**Lỗi thường gặp:**\n- **Premature capture**: luôn sleep sau khi start, trước capture\n- **Missing Enter**: `send-keys \"cmd\" Enter` — Enter là argument riêng\n- **Wrong key names**: dùng `Enter Escape Tab` (Pascal case), không phải `\\n \\x1b \\t`\n- **Orphaned sessions**: luôn `kill-session` sau khi xong\n\n## Related Skills\n\n- `@bash-pro` — Writing the shell scripts that orchestrate tmux sessions\n- `@bash-linux` — General Linux terminal patterns used inside tmux panes\n- `@ssh` — Combining tmux with SSH for persistent remote workflows\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n",{"name":5,"risk":24,"tags":25,"tools":32,"author":36,"source":37,"category":38,"date_added":39,"description":7},"safe",[5,26,27,28,29,30,31],"terminal","multiplexer","sessions","shell","remote","automation",[33,34,35],"claude","cursor","gemini","kostakost2","community","development","2026-03-28","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Ftmux",1,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-11 23:56:26",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill tmux",{"tool":56,"command":57},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill tmux",{"tool":59,"command":60},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill tmux","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Ftmux\u002FSKILL.md",true,[],[65,73,80,88,96,104],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":84,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":100,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]