feat(zsh): add auto complete for cht.sh

This commit is contained in:
Stefan Imhoff
2022-09-24 10:02:03 +02:00
parent 42756dfa22
commit 74742bd5af
3 changed files with 25 additions and 2 deletions

21
zsh/_cht Normal file
View File

@@ -0,0 +1,21 @@
#compdef cht.sh
__CHTSH_LANGS=($(curl -s cheat.sh/:list))
_arguments -C \
'--help[show this help message and exit]: :->noargs' \
'--shell[enter shell repl]: :->noargs' \
'1:Cheat Sheet:->lang' \
'*::: :->noargs' && return 0
if [[ CURRENT -ge 1 ]]; then
case $state in
noargs)
_message "nothing to complete";;
lang)
compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};;
*)
_message "Unknown state, error in autocomplete";;
esac
return
fi