<commit_before>#!/bin/sh

# Usage: Get a list of all currently visible words:
#     sh panewords.sh
#
# Get all visible words beginning with `foo`:
#     sh panewords.sh foo

if [[ -z "$TMUX_PANE" ]]; then
    echo "Not running inside tmux!" 1>&2
    exit 1
fi

panes_current_window() {
    tmux list-panes -F '#{pane_active} #P' |
    while read active pane; do
        [[ "$active" -eq 0 ]] && echo "$pane"
    done
}

panes_current_session() {
    tmux list-panes -s -F '#{window_active} #I.#P' |
    while read active pane; do
        [[ "$active" -eq 0 ]] && echo "$pane"
    done
}

# take all lines
# append copy with replaced non word characters
# split on spaces
# filter by first argument
# sort ard remove duplicates
(
panes_current_window
panes_current_session
) |
xargs -n1 tmux capture-pane -J -p -t |
sed -e 'p;s/[^a-zA-Z0-9_]/ /g' |
tr -s '[:space:]' '\n'|<commit_msg>Add panes from all sessions<commit_after>#!/bin/sh

# Usage: Get a list of all currently visible words:
#     sh panewords.sh
#
# Get all visible words beginning with `foo`:
#     sh panewords.sh foo

if [[ -z "$TMUX_PANE" ]]; then
    echo "Not running inside tmux!" 1>&2
    exit 1
fi

panes_current_window() {
    tmux list-panes -F '#{pane_active} #P' |
    while read active pane; do
        [[ "$active" -eq 0 ]] && echo "$pane"
    done
}

panes_current_session() {
    tmux list-panes -s -F '#{window_active} #I.#P' |
    while read active pane; do
        [[ "$active" -eq 0 ]] && echo "$pane"
    done
}

panes_all_sessions() {
    current=$(tmux display-message -p '#S')
    tmux list-panes -a -F '#S #I.#P' |
    while read session pane; do
        [[ $current != $session ]] && echo "$session:$pane"
    done
}

# take all lines
# append copy with replaced non word characters
# split on spaces
# filter by first argument
# sort ard remove duplicates
(
panes_current_window
panes_current_session
panes_all_sessions
) |
xargs -n1 tmux capture-pane -J -p -t |
sed -e 'p;s/[^a-zA-Z0-9_]/ /g' |
tr -s '[:space:]' '\n'|
{'fraction_non_alphanumeric': 0.147687717553456, 'fraction_numerical': 0.007956240676280457, 'mean_word_length': 2.922027290448343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2433664', 'n_tokens_mistral': 779, 'n_tokens_neox': 745, 'n_words': 241}