Integrated the autocompletion scripts into the project, and rewrote the bash version to take advantage of the new -l option.

This commit is contained in:
Chris Lane
2013-09-14 10:27:53 -04:00
parent b24e2b7fd2
commit 587dbf3c11
3 changed files with 7 additions and 12 deletions

View File

@ -0,0 +1,9 @@
function _cheat_autocomplete {
sheets=$(cheat -l | cut -d' ' -f1)
COMPREPLY=()
if [ $COMP_CWORD = 1 ]; then
COMPREPLY=(`compgen -W "$sheets" -- $2`)
fi
}
complete -F _cheat_autocomplete cheat

12
autocompletion/cheat.zsh Normal file
View File

@ -0,0 +1,12 @@
#compdef cheat
declare -a cheats cheats_in_this_dir
for directory in $(cheat --cheat_directories); do
cheats_in_this_dir=($directory/*(N:r:t))
[[ ${#cheats_in_this_dir} > 0 ]] && cheats+=($cheats_in_this_dir)
done
_arguments "1:cheats:(${cheats})"
return 1