function _isabelle { local CURRENT="${COMP_WORDS[${COMP_CWORD}]}" if (( ${COMP_CWORD} == 1 )) then local CURRENT="${COMP_WORDS[${COMP_CWORD}]}" local ISABELLE_TOOL="${COMP_WORDS[0]}" local ISABELLE_HOME="$("${ISABELLE_TOOL}" getenv -b ISABELLE_HOME)" local ISABELLE_TOOLS="$("${ISABELLE_TOOL}" getenv -b ISABELLE_TOOLS)" { export ISABELLE_TOOLS local ISABELLE_TOOLS_ALL=($(perl -w "${ISABELLE_HOME}/lib/scripts/tools.pl" | perl -pe 's/^\s+(\S+)\s.*$/$1/g')) declare +x ISABELLE_TOOLS } COMPREPLY=($(compgen -W "${ISABELLE_TOOLS_ALL[*]}" "${CURRENT}")) else cur="${CURRENT}" && _filedir fi } complete -o filenames -F _isabelle isabelle