Last active
February 8, 2023 20:24
-
-
Save bdowling/c42cb00397eff0d8f8ed625146ead676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script helps you find something if you have tons of open panes... | |
# | |
# | |
# $0 '[a]bcdef' | |
notthispane=$TMUX_PANE | |
if [ "$1" = "-a" ]; then | |
notthispane='' | |
shift | |
fi | |
if [ -z "$*" ]; then | |
cat <<EOT | |
Usage: | |
$0 <options> [arguments to grep to find something in any open tmux pane]" | |
Options: | |
-a include the current pane (not included by default because you could just search backwards...) | |
e.g. | |
$0 -Pi '[f]oo.*bar\d+' | |
Tip: The use of brackets around a single char avoids finding your own attempt at finding something, | |
at until you start showing the found history in this pane. | |
EOT | |
exit 1 | |
fi | |
for pane in $( tmux list-panes -a|grep -Po '%\d+' ); do | |
if [ -n "$notthispane" -a "$notthispane" = "$pane" ]; then | |
continue | |
fi | |
if tmux capture-pane -S - -p -t $pane |grep "$@"; then | |
echo "" | |
echo "------ Pane: $(tmux list-panes -a |grep -w $pane) ------" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you find yourself with a lot of tmux window panes open, and you can't remember where you ran a particular command or had some output you needed to capture, you can use this to find it. Hope you find it useful.