shlax/completion.bash
2020-02-19 00:28:43 +01:00

15 lines
390 B
Bash

#!/usr/bin/bash
_action(){
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ "$COMP_CWORD" -eq 1 ]] ; then
COMPREPLY=($(compgen -W "$(ls shlax/repo/*.py | sed s/^.*\\/\// | cut -d "." -f 1)" "${cur}"))
else
action=$(grep "^[^ #)]\w* =" shlax/repo/${COMP_WORDS[1]}.py | cut -d " " -f 1)
COMPREPLY=($(compgen -W "$action" "${cur}"))
fi
}
complete -F _action shlax