From 331d9421f1ca56afdaf0d238082f83d82103a795 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 19 May 2026 13:09:23 -0500 Subject: feat(tmux-util): add find subcommand tmux-util find walks every pane across every session, queries each pane's foreground command (`#{pane_current_command}`), and prints the location of any pane whose command matches the pattern. Output format: `:. `, one per line. Pattern is a basic ERE (passed through `grep -E`), so anchors and alternation work. Substring matching is the common case. Exit code: - 0 with output: matches found - 1 with no output: no matches (lets you script around it) - 2 with usage on stderr: missing or empty pattern 7 new tests cover Normal cases (single match, multi-match across sessions, format verification) and Boundary cases (no matches, no sessions, missing pattern, empty pattern). fake-tmux now parses pid:cmd entries in the state file so panes can carry a synthetic command name. Total suite: 39 tests, all green. --- dotfiles/common/.local/bin/tmux-util | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'dotfiles/common') diff --git a/dotfiles/common/.local/bin/tmux-util b/dotfiles/common/.local/bin/tmux-util index 4a7b596..5e0ce85 100755 --- a/dotfiles/common/.local/bin/tmux-util +++ b/dotfiles/common/.local/bin/tmux-util @@ -35,6 +35,29 @@ Run with no arguments to print this help. EOF } +# ----------------------------------------------------------------------------- +# find +# ----------------------------------------------------------------------------- + +cmd_find() { + local pattern="${1:-}" + if [ -z "$pattern" ]; then + echo "tmux-util find: missing pattern" >&2 + echo "Usage: tmux-util find " >&2 + return 2 + fi + + local matches + matches=$(tmux list-panes -a \ + -F '#{session_name}:#{window_index}.#{pane_index} #{pane_current_command}' \ + 2>/dev/null | grep -E "$pattern" || true) + + if [ -z "$matches" ]; then + return 1 + fi + echo "$matches" +} + # ----------------------------------------------------------------------------- # go # ----------------------------------------------------------------------------- @@ -178,7 +201,10 @@ main() { go) cmd_go "$@" ;; - pick|find|rename) + find) + cmd_find "$@" + ;; + pick|rename) echo "tmux-util: subcommand '$sub' is not implemented yet" >&2 return 2 ;; -- cgit v1.2.3