Autocompletion & Makefile

This commit is contained in:
DrClaw 2020-02-18 22:30:45 +01:00
parent 2db971234a
commit 16f1bef125
2 changed files with 24 additions and 0 deletions

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
all:
@echo -e "\n\033[1;36m --> Installing the module ...\033[0m\n"
pip install --user -e .
@echo -ne "\n\033[1;36m"; \
read -p " --> Install autocompletion ?[Y|n] " RESP; \
echo -e "\n\033[0m"; \
case "$$RESP" in \
y*|Y*|"")sudo cp -v completion.bash /usr/share/bash-completion/completions/shlax;; \
*);; \
esac;

14
completion.bash Normal file
View File

@ -0,0 +1,14 @@
#!/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