Close Idle Tmux Panes
I have a two-line prompt, the second line of which is $, so:
for p in $(tmux list-panes -a -F '#{pane_id}'); do
if [[ "$(tmux capture-pane -t $p -p -S $(tmux display-message -t $p -p '#{cursor_y}') -E $(tmux display-message -t $p -p '#{cursor_y}'))" =~ ^\$\ *$ ]]; then
tmux send-keys -t $p "exit" Enter
fi
done