<commit_before># add completion for editfile categories
# note that this file must be sourced
#
# <NAME> 2012 @codedstructure

# This doesn't declare global constants as it gets sourced
# and doesn't want to pollute the environment. But it does
# assume ~/Dropbox/editfile/ is the correct EDITFILE_DIR

_list_files()
{
    if ! [[ -d ~/Dropbox/editfile/$1 ]] ; then
        return
    fi
    cd ~/Dropbox/editfile/$1 2> /dev/null || return
    find * -maxdepth 1 -type f | sed 's/\.txt$//g' | sed 's/ /\\ /g'
}

_editfile()
{
    local curw
    COMPREPLY=()
    curw=${COMP_WORDS[COMP_CWORD]}
    # only offer expansions if nothing currently there
    LIMIT=3
    # if the previous word is an option which can take
    # a category argument, then don't stop yet!
    if [[ ${COMP_WORDS[${#COMP_WORDS[@]} - 2]} =~ -[alf] ]] ; then
        LIMIT=4
    fi
    if [[ ${#COMP_WORDS[@]} -lt $LIMIT ]] ; then
        saveIFS=$IFS
        IFS=$'\n'
        COMPREPLY=($(compgen -W '$(_list_files $1)' -- $curw))
        IFS=$saveIFS
    fi
    return 0
}

for p in $(echo $PATH | tr : \\n | sort | uniq); do
    for ff in $(find -L $p -maxdepth 1 -perm -100 -samefile $(which editfile) 2> /dev/null); do
        complete -o nospace -F _editfile $(basename $ff)<commit_msg>no error on find with no target in completer<commit_after># add completion for editfile categories
# note that this file must be sourced
#
# <NAME> 2012 @codedstructure

# This doesn't declare global constants as it gets sourced
# and doesn't want to pollute the environment. But it does
# assume ~/Dropbox/editfile/ is the correct EDITFILE_DIR

_list_files()
{
    if ! [[ -d ~/Dropbox/editfile/$1 ]] ; then
        return
    fi
    cd ~/Dropbox/editfile/$1 2> /dev/null || return
    find * -maxdepth 1 -type f 2> /dev/null | sed 's/\.txt$//g' | sed 's/ /\\ /g'
}

_editfile()
{
    local curw
    COMPREPLY=()
    curw=${COMP_WORDS[COMP_CWORD]}
    # only offer expansions if nothing currently there
    LIMIT=3
    # if the previous word is an option which can take
    # a category argument, then don't stop yet!
    if [[ ${COMP_WORDS[${#COMP_WORDS[@]} - 2]} =~ -[alf] ]] ; then
        LIMIT=4
    fi
    if [[ ${#COMP_WORDS[@]} -lt $LIMIT ]] ; then
        saveIFS=$IFS
        IFS=$'\n'
        COMPREPLY=($(compgen -W '$(_list_files $1)' -- $curw))
        IFS=$saveIFS
    fi
    return 0
}

for p in $(echo $PATH | tr : \\n | sort | uniq); do
    for ff in $(find -L $p -maxdepth 1 -perm -100 -samefile $(which editfile) 2> /dev/null); do
        complete -o nospace -F _editfile $(basename $ff)
{'fraction_non_alphanumeric': 0.1426905132192846, 'fraction_numerical': 0.014385692068429238, 'mean_word_length': 2.5686546463245494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '7108800', 'n_tokens_mistral': 932, 'n_tokens_neox': 901, 'n_words': 307}