<commit_before># -----------------------------------------------------------------------------
# ~zozo/.config/bash/completion
# say hello: printf "zozo\x40inescapable\x2eorg"
# -----------------------------------------------------------------------------
# shell options
# -----------------------------------------------------------------------------

# include .dotfiles in filename expansion
shopt -s dotglob

# perform hostname completion on strings containing '@'
shopt -s hostcomplete

# don't search PATH when completion is attempted on an empty line
shopt -s no_empty_cmd_completion

# -----------------------------------------------------------------------------
# bash-completion
# -----------------------------------------------------------------------------

for checkFile in /{{usr,opt}/local/,}etc/bash_completion; do
    _source "$checkFile" && {
        export BASH_COMPLETION_SOURCED="$checkFile"
        break
    }

    unset checkFile
done

# -----------------------------------------------------------------------------
# my custom completions
# -----------------------------------------------------------------------------

# complete actions:
# -a    alias           #       function
# -b    builtin         #       helptopic
# -c    command         #       hostname (from $HOSTFILE)
# -d    directory       # -j    job (name)
# -e    export(ed var)  # -k    keyword
# -f    file (names)    # -v    variable

complete -bck                   command
complete -abcfk -A function -A helptopic \
                                man type what which
complete -A function            fe where
complete -defv -A hostname      scp sftp ssh
complete -abcf -A function      sudo
complete -defv                  trash
complete -aev -A function       unset

# reloading config files
complete -o nospace -W "profile bashrc ${dotfiles[*]}" rl

# kill running processes
_inPath killall && {
    __complete_killall()
    {
        declare processes=($(command ps -cxo command))
        declare cur=${COMP_WORDS[COMP_CWORD]}
        COMPREPLY=( $(compgen -W "${processes[*]}" -- $cur) )
    }

    complete -o default -o nospace \
             -F __complete_killall \
             killall
}

# -----------------------------------------------------------------------------
# misc. custom completions
# -----------------------------------------------------------------------------

# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
# https://github.com/pahen/dotfiles/blob/master/.completions
[[ -f $HOME/.ssh/config ]] && {
    complete -o default -o nospace \
             -W "$(grep "^Host" $HOME/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" \
             scp sftp ssh
}

# Homebrew
[[ -x /usr/local/bin/brew ]] &&
    _source "$(brew --prefix)/Library/Contributions/brew_bash_completion.sh"

# other
_source "$dir_mybin/transmission-remote-cli/transmission-remote-cli-bash-completion.sh"<commit_msg>completion for my edsh() function<commit_after># -----------------------------------------------------------------------------
# ~zozo/.config/bash/completion
# say hello: printf "zozo\x40inescapable\x2eorg"
# -----------------------------------------------------------------------------
# shell options
# -----------------------------------------------------------------------------

# include .dotfiles in filename expansion
shopt -s dotglob

# perform hostname completion on strings containing '@'
shopt -s hostcomplete

# don't search PATH when completion is attempted on an empty line
shopt -s no_empty_cmd_completion

# -----------------------------------------------------------------------------
# bash-completion
# -----------------------------------------------------------------------------

for checkFile in /{{usr,opt}/local/,}etc/bash_completion; do
    _source "$checkFile" && {
        export BASH_COMPLETION_SOURCED="$checkFile"
        break
    }

    unset checkFile
done

# -----------------------------------------------------------------------------
# my custom completions
# -----------------------------------------------------------------------------

# complete actions:
# -a    alias           #       function
# -b    builtin         #       helptopic
# -c    command         #       hostname (from $HOSTFILE)
# -d    directory       # -j    job (name)
# -e    export(ed var)  # -k    keyword
# -f    file (names)    # -v    variable

complete -bck                   command
complete -abcfk -A function -A helptopic \
                                man type what which
complete -A function            fe where
complete -defv -A hostname      scp sftp ssh
complete -abcf -A function      sudo
complete -defv                  trash
complete -aev -A function       unset

# reloading config files with `rl`
complete -o nospace -W "profile bashrc ${dotfiles[*]}" rl

# kill running processes
_inPath killall && {
    __complete_killall()
    {
        declare processes=($(command ps -cxo command))
        declare cur=${COMP_WORDS[COMP_CWORD]}
        COMPREPLY=( $(compgen -W "${processes[*]}" -- $cur) )
    }

    complete -o default -o nospace \
             -F __complete_killall \
             killall
}

# edit scripts
__complete_edsh()
{
    declare cur=${COMP_WORDS[COMP_CWORD]}
    declare scripts=( $(find -H "$dir_scripts" -maxdepth 2 -type f -name '*.sh' | sed -nE 's#^.*/(.*)\.sh$#\1#p') )

    COMPREPLY=( $(compgen -W "${scripts[*]}" -- $cur) )
}

complete -o default -o nospace \
    -F __complete_edsh \
    edsh

# -----------------------------------------------------------------------------
# misc. custom completions
# -----------------------------------------------------------------------------

# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
# https://github.com/pahen/dotfiles/blob/master/.completions
[[ -f $HOME/.ssh/config ]] && {
    complete -o default -o nospace \
             -W "$(sed -nE 's/Host (.*[^?*])$/\1/p' $HOME/.ssh/config)" \
             scp sftp ssh
}

# Homebrew
[[ -x /usr/local/bin/brew ]] &&
    _source "$(brew --prefix)/Library/Contributions/brew_bash_completion.sh"

# Transmission
_source "$dir_mybin/transmission-remote-cli/transmission-remote-cli-bash-completion.sh"

{'fraction_non_alphanumeric': 0.3181307210534768, 'fraction_numerical': 0.0016059097478721696, 'mean_word_length': 1.1829652996845426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5962214', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1561, 'n_words': 438}