X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=blobdiff_plain;f=usr_share_grml%2Fzsh%2Fcompletion%2Funix%2F_hl_complete;h=fad3ad8c495f62fe3e1a5d5aba14eded994be56c;hp=28363d4761ca1b092817da09a69115ff01a47951;hb=eb08ffe0a3473847d288cfabc3077d5281f06916;hpb=5f9a26a3da1abedae0565001ccfb2551f4c24115 diff --git a/usr_share_grml/zsh/completion/unix/_hl_complete b/usr_share_grml/zsh/completion/unix/_hl_complete index 28363d4..fad3ad8 100644 --- a/usr_share_grml/zsh/completion/unix/_hl_complete +++ b/usr_share_grml/zsh/completion/unix/_hl_complete @@ -1,17 +1,38 @@ #compdef hl -function _hl_genarg() { +# Taken from: +# https://dev.0x50.de/projects/ftzsh/repository/revisions/master/entry/functions/_hl_complete + +function _hl_themes() { local expl - if [[ -prefix 1 *: ]] ; then - local themes - themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*}) - compset -P 1 '*:' - _wanted -C list themes expl theme compadd ${themes} - else - local langs - langs=(${${${(f)"$(LC_ALL=C highlight --list-langs)"}/ #/}:#*(Installed|Use name)*}) - _wanted -C list languages expl languages compadd -S ':' -q ${langs} - fi + local -a themes + themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*}) + _wanted -C list themes expl theme compadd ${themes} +} + +function _hl_languages() { + local dir expl curcontext="$curcontext" + local -a langs + zstyle -s ":completion:${curcontext}:" theme-directory dir \ + || dir='/usr/share/highlight/langDefs/' + langs=( $dir/*(.:t:r) ) + _wanted -C list languages expl languages compadd ${langs} +} + +function _hl_complete () { + local -a args + args=( + '(--help -h)'{--help,-h}'[display help text]' + '(-c --cat --no-pager)'{--no-pager,--cat,-c}'[do not use a pager]' + '(--format -F)'{--format,-F}'[specify output format]' + '(--list -l)'{--list,-l}'[list available languages]' + '(--pager -P)'{--pager,-P}'[specify which pager to use]' + '(--syntax -s)'{--syntax,-s}'[specify which syntax to assume]:languages:_hl_languages' + '(--themes -t)'{--themes,-t}'[list available themes]' + '(--theme -T)'{--theme,-T}'[specify which theme to use]:themes:_hl_themes' + '*:files:_path_files' + ) + _arguments -s $args } -_arguments -s '1: :_hl_genarg' '2:files:_path_files' +_hl_complete "$@"