Add autocomplete

This commit is contained in:
Bruno Tavares 2014-02-21 19:43:24 -03:00
parent 460fdd57f8
commit c908d00703
3 changed files with 30 additions and 0 deletions

View File

@ -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)

18
completions/kickstart Normal file
View File

@ -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

4
lib/kickstart-autocomplete Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
root_dir=`kickstart root-dir`
echo "source $root_dir/completions/kickstart"