The Meowgorithm Dotfiles, Collectors’ Edition
#!/usr/bin/env bash
set -euo pipefail
# Send commands or keys to a tmux pane.
#
# Usage:
# tmux_send.sh [options] <target> <command>
# tmux_send.sh [options] <target> -- <command...>
#
# Target formats:
# session-name → active pane in that session
# session-name:window → active pane in that window
# session-name:window.pane → specific pane
# :window.pane → current session, specific pane
# .pane → current session+window, specific pane
#
# Options:
# -e, --enter Send Enter key after the command (default: true)
# -n, --no-enter Do not send Enter after the command
# -k, --keys Treat <command> as literal key name(s) (e.g. C-c, Escape, Up)
# -l, --literal Send as literal text (no tmux key interpretation)
# -d, --delay SECONDS Wait SECONDS before sending (useful for slow panes)
# -r, --read-back Capture and print pane output after sending (with 0.3s delay)
# -w, --wait SECONDS Wait SECONDS before read-back (implies --read-back)
# -h, --help Show this help
usage() {
sed -n '4,/^$/p' "$0" | sed 's/^# \?//' >&2
exit 1
}
ENTER=true
KEYS=false
LITERAL=false
DELAY=0
READBACK=false
WAIT=0
while [[ $# -gt 0 ]]; do
case "$1" in