<commit_before>#!/bin/bash

set -euo pipefail

# SCRIPT_PATH will be filled by stub script
alias tmc="$SCRIPT_PATH/tmc"

tmcCommands=\$(tmc shell-helper -c)

_tmc_opts()
{
  local cur
  # Pointer to current completion word.
  # By convention, it's named "cur" but this isn't strictly necessary.

  COMPREPLY=()
  cur="\${COMP_WORDS[COMP_CWORD]}"

  case "\$cur" in
    -*)
      COMPREPLY=( \$( compgen -W "-v -h --version --help" -- "\$cur" ) )
      return 0
      ;;
#   xx) May add more cases here.
#   yy)
#   zz)
  esac

  COMPREPLY=( \$( compgen -W "\$tmcCommands" -- "\$cur" ) )
  return 0
}

complete -F _tmc_opts tmc<commit_msg>Autocomplete filenames.<commit_after>#!/bin/bash

# SCRIPT_PATH will be filled by stub script
alias tmc="$SCRIPT_PATH/tmc"

TMC_COMMANDS=( "\$(tmc shell-helper -c)" )

_tmc_opts()
{
	local cur
	local sub_command
	local main_args
	# Pointer to current completion word.
	# By convention, it's named "cur" but this isn't strictly necessary.

	COMPREPLY=()
	cur="\${COMP_WORDS[COMP_CWORD]}"

	main_args=( "\${COMP_WORDS[@]:0:COMP_CWORD}" )
	for word in "\${main_args[@]}"; do
		if [[ "\$TMC_COMMANDS" =~ "\$word" ]]; then
			sub_command="\$word"
		fi
	done

	case "\$cur" in
	    -*)
		COMPREPLY=( \$( compgen -W "-v -h --version --help" -- "\$cur" ) )
		return 0
		;;
	esac

	if [[ ! -z "\$sub_command" ]]; then
		COMPREPLY=( \$(compgen -f -- \${cur}) )
		return 0
	fi

	COMPREPLY=( \$( compgen -W "\${TMC_COMMANDS}" -- "\$cur" ) )
	return 0
}

complete -F _tmc_opts tmc
{'fraction_non_alphanumeric': 0.18205980066445182, 'fraction_numerical': 0.003986710963455149, 'mean_word_length': 3.0267379679144386, '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': '5598205', 'n_tokens_mistral': 635, 'n_tokens_neox': 602, 'n_words': 157}