Update hl and _hl_complete to work with current ‘highlight’ versions
[grml-etc-core.git] / usr_share_grml / zsh / completion / unix / _hl_complete
1 #compdef hl
2
3 # Taken from:
4 # https://dev.0x50.de/projects/ftzsh/repository/revisions/master/entry/functions/_hl_complete
5
6 function _hl_themes() {
7     local expl
8     local -a themes
9     themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*})
10     _wanted -C list themes expl theme compadd ${themes}
11 }
12
13 function _hl_languages() {
14     local dir expl curcontext="$curcontext"
15     local -a langs
16     zstyle -s ":completion:${curcontext}:" theme-directory dir \
17         || dir='/usr/share/highlight/langDefs/'
18     langs=( $dir/*(.:t:r) )
19     _wanted -C list languages expl languages compadd ${langs}
20 }
21
22 function _hl_complete () {
23     local -a args
24     args=(
25         '(--help -h)'{--help,-h}'[display help text]'
26         '(-c --cat --no-pager)'{--no-pager,--cat,-c}'[do not use a pager]'
27         '(--format -F)'{--format,-F}'[specify output format]'
28         '(--list -l)'{--list,-l}'[list available languages]'
29         '(--pager -P)'{--pager,-P}'[specify which pager to use]'
30         '(--syntax -s)'{--syntax,-s}'[specify which syntax to assume]:languages:_hl_languages'
31         '(--themes -t)'{--themes,-t}'[list available themes]'
32         '(--theme -T)'{--theme,-T}'[specify which theme to use]:themes:_hl_themes'
33         '*:files:_path_files'
34     )
35     _arguments -s $args
36 }
37
38 _hl_complete "$@"