mirror of
https://github.com/cheat/cheat.git
synced 2025-09-04 02:58:29 +02:00
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:
9
autocompletion/cheat.bash
Normal file
9
autocompletion/cheat.bash
Normal 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
12
autocompletion/cheat.zsh
Normal 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
|
Reference in New Issue
Block a user