diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2f8163e --- /dev/null +++ b/Makefile @@ -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; diff --git a/completion.bash b/completion.bash new file mode 100644 index 0000000..10af8d5 --- /dev/null +++ b/completion.bash @@ -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