diff --git a/README.md b/README.md index a3ff49a..240eb21 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ shell_configuration=$HOME/.bashrc git clone https://github.com/bltavares/kickstart.git $installation_path echo 'export PATH=$PATH:'$installation_path'/bin' >> $shell_configuration +echo 'eval "$(baseline autocomplete)"' >> $shell_configuration ``` The other is to link the `bin/kickstart` into a place that is already on your path @@ -22,6 +23,7 @@ shell_configuration=$HOME/.bashrc git clone https://github.com/bltavares/kickstart.git $installation_path sudo ln -s $installation_path/bin/kickstart /usr/local/bin/kickstart +echo 'eval "$(baseline autocomplete)"' >> $shell_configuration ``` ### Usage @@ -128,6 +130,12 @@ Show documentation for a function kickstart doc kickstart.os ``` +#### autocomplete +Enable autocompletion on your terminal + +```bash +eval "$(kickstart autocomplete)" +``` ### Thanks This project was inspired on [sunzi](https://github.com/kenn/sunzi) diff --git a/completions/kickstart b/completions/kickstart new file mode 100644 index 0000000..066376c --- /dev/null +++ b/completions/kickstart @@ -0,0 +1,18 @@ +#!/bin/bash + +_kickstart_autocomplete() { + + local cur=${COM_WORDS[COM_CWORD]} + + if [ "$COMP_CWORD" -eq 1 ]; then + COMPREPLY=( $(compgen -W "`kickstart commands`" -- "$cur") ) + fi + + if [ "$COMP_CWORD" -eq 2 ] && [[ "${COMP_WORDS[1]}" == "doc" ]]; then + COMPREPLY=( $(compgen -W "`kickstart doc 2> /dev/null`" -- $cur) ) + fi + + return 0; +} + +complete -F _kickstart_autocomplete kickstart diff --git a/lib/kickstart-autocomplete b/lib/kickstart-autocomplete new file mode 100755 index 0000000..e0f0608 --- /dev/null +++ b/lib/kickstart-autocomplete @@ -0,0 +1,4 @@ +#!/bin/bash + +root_dir=`kickstart root-dir` +echo "source $root_dir/completions/kickstart"