<commit_before># -*- mode:sh -*-
#
# zaw-src-tmux
#
# select tmux session and attach it
#

function zaw-src-tmux() {
    local session state

    tmux list-sessions | \
        while read session state; do
            candidates+=("${session}")
            cand_descriptions+=("${(r:30:::::)session} ${state}")
        done
        actions=('zaw-callback-tmux-attach')
        act_descriptions=('attach session')
        actions+=('zaw-callback-tmux-kill')
        act_descriptions+=('kill session')
}

zaw-register-src -n tmux zaw-src-tmux

function zaw-callback-tmux-attach() {
    BUFFER="tmux attach -t ${(q)1}"
    zle accept-line
}

function zaw-callback-tmux-kill() {
    BUFFER="tmux kill-session -t ${(q)1}"
    zle accept-line<commit_msg>add switch-client if already in tmux<commit_after># -*- mode:sh -*-
#
# zaw-src-tmux
#
# select tmux session and attach it
#

function zaw-src-tmux() {
    local session state

    tmux list-sessions | \
        while read session state; do
            candidates+=("${session}")
            cand_descriptions+=("${(r:30:::::)session} ${state}")
        done
        actions=('zaw-callback-tmux-attach')
        act_descriptions=('attach session')
        actions+=('zaw-callback-tmux-kill')
        act_descriptions+=('kill session')
}

zaw-register-src -n tmux zaw-src-tmux

function zaw-callback-tmux-attach() {
    if [ -z $TMUX ]; then
        BUFFER="tmux attach -t ${(q)1}"
    else
        BUFFER="tmux switch-client -t ${(q)1}"
    fi
    zle accept-line
}

function zaw-callback-tmux-kill() {
    BUFFER="tmux kill-session -t ${(q)1}"
    zle accept-line
{'fraction_non_alphanumeric': 0.16377171215880892, 'fraction_numerical': 0.005583126550868486, 'mean_word_length': 2.665909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1951376', 'n_tokens_mistral': 552, 'n_tokens_neox': 556, 'n_words': 116}