diff options
Diffstat (limited to 'dotfiles/common')
| -rwxr-xr-x | dotfiles/common/.local/bin/tmux-util | 28 |
1 files changed, 27 insertions, 1 deletions
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 @@ -36,6 +36,29 @@ EOF } # ----------------------------------------------------------------------------- +# find +# ----------------------------------------------------------------------------- + +cmd_find() { + local pattern="${1:-}" + if [ -z "$pattern" ]; then + echo "tmux-util find: missing pattern" >&2 + echo "Usage: tmux-util find <pattern>" >&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 ;; |
