<commit_before>_subr() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"

  words=("${COMP_WORDS[@]:1:COMP_CWORD-1}")

  local completions="$(subr completions "${words[@]}")"
  COMPREPLY=( $(compgen -W "$completions" -- "$word") )

}

complete -F _subr subr<commit_msg>add autocompletion for sub commands<commit_after>_subr() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"

  execbasename=`basename ${COMP_WORDS[0]}`
  words=("${COMP_WORDS[@]:1:COMP_CWORD-1}")

  local completions="$($execbasename completions "${words[@]}")"
  COMPREPLY=( $(compgen -W "$completions" -- "$word") )

}

_subr_find_shortcuts() {
  # find any executable files in the same directory as the subr binary
  # that export _SUBR_SUB_COMMAND and add tab completion for them
  local subr_path=$(command -v "subr" || true)
  if [ -e "$subr_path" ]; then
    local subr_dir=$(dirname $subr_path)
    for file in $subr_dir/*; do
      if [ -x $file ]; then
        local is_sub=$(grep "export _SUBR_SUB_COMMAND" $file)
        if [ -n "$is_sub" ]; then
          local basenamef=`basename $file`
          complete -F _subr $basenamef
        fi
      fi
    done
  fi
}

complete -F _subr subr
_subr_find_shortcuts
{'fraction_non_alphanumeric': 0.15684647302904564, 'fraction_numerical': 0.004149377593360996, 'mean_word_length': 3.8433734939759034, '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': '3059900', 'n_tokens_mistral': 448, 'n_tokens_neox': 443, 'n_words': 105}