mirror of
https://github.com/cheat/cheat.git
synced 2024-11-25 07:21:36 +01:00
Improve zsh completion
This commit is contained in:
parent
c4dd3b52fd
commit
477650ee44
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
local cheats taglist pathlist
|
local cheats taglist pathlist
|
||||||
|
|
||||||
_cheat_complete_cheatsheets()
|
_cheat_complete_personal_cheatsheets()
|
||||||
{
|
{
|
||||||
cheats=("${(f)$(cheat -l -t personal | tail -n +2 | cut -d' ' -f1)}")
|
cheats=("${(f)$(cheat -l -t personal | tail -n +2 | cut -d' ' -f1)}")
|
||||||
_describe -t cheats 'cheats' cheats
|
_describe -t cheats 'cheats' cheats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cheat_complete_full_cheatsheets()
|
||||||
|
{
|
||||||
|
cheats=("${(f)$(cheat -l | tail -n +2 | cut -d' ' -f1)}")
|
||||||
|
_describe -t cheats 'cheats' cheats
|
||||||
|
}
|
||||||
|
|
||||||
_cheat_complete_tags()
|
_cheat_complete_tags()
|
||||||
{
|
{
|
||||||
taglist=("${(f)$(cheat -T)}")
|
taglist=("${(f)$(cheat -T)}")
|
||||||
@ -26,7 +32,7 @@ _cheat() {
|
|||||||
'(--init)--init[Write a default config file to stdout]: :->none' \
|
'(--init)--init[Write a default config file to stdout]: :->none' \
|
||||||
'(-c --colorize)'{-c,--colorize}'[Colorize output]: :->none' \
|
'(-c --colorize)'{-c,--colorize}'[Colorize output]: :->none' \
|
||||||
'(-d --directories)'{-d,--directories}'[List cheatsheet directories]: :->none' \
|
'(-d --directories)'{-d,--directories}'[List cheatsheet directories]: :->none' \
|
||||||
'(-e --edit)'{-e,--edit}'[Edit <sheet>]: :->full' \
|
'(-e --edit)'{-e,--edit}'[Edit <sheet>]: :->personal' \
|
||||||
'(-l --list)'{-l,--list}'[List cheatsheets]: :->full' \
|
'(-l --list)'{-l,--list}'[List cheatsheets]: :->full' \
|
||||||
'(-p --path)'{-p,--path}'[Return only sheets found on path <name>]: :->pathlist' \
|
'(-p --path)'{-p,--path}'[Return only sheets found on path <name>]: :->pathlist' \
|
||||||
'(-r --regex)'{-r,--regex}'[Treat search <phrase> as a regex]: :->none' \
|
'(-r --regex)'{-r,--regex}'[Treat search <phrase> as a regex]: :->none' \
|
||||||
@ -34,13 +40,17 @@ _cheat() {
|
|||||||
'(-t --tag)'{-t,--tag}'[Return only sheets matching <tag>]: :->taglist' \
|
'(-t --tag)'{-t,--tag}'[Return only sheets matching <tag>]: :->taglist' \
|
||||||
'(-T --tags)'{-T,--tags}'[List all tags in use]: :->none' \
|
'(-T --tags)'{-T,--tags}'[List all tags in use]: :->none' \
|
||||||
'(-v --version)'{-v,--version}'[Print the version number]: :->none' \
|
'(-v --version)'{-v,--version}'[Print the version number]: :->none' \
|
||||||
'(--rm)--rm[Remove (delete) <sheet>]: :->full' \
|
'(--rm)--rm[Remove (delete) <sheet>]: :->personal' \
|
||||||
|
'(-)*: :->full'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
(none)
|
(none)
|
||||||
;;
|
;;
|
||||||
(full)
|
(full)
|
||||||
_cheat_complete_cheatsheets
|
_cheat_complete_full_cheatsheets
|
||||||
|
;;
|
||||||
|
(personal)
|
||||||
|
_cheat_complete_personal_cheatsheets
|
||||||
;;
|
;;
|
||||||
(taglist)
|
(taglist)
|
||||||
_cheat_complete_tags
|
_cheat_complete_tags
|
||||||
@ -49,7 +59,6 @@ _cheat() {
|
|||||||
_cheat_complete_paths
|
_cheat_complete_paths
|
||||||
;;
|
;;
|
||||||
(*)
|
(*)
|
||||||
_cheat_complete_cheatsheets
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user