2020-09-08 10:34:42 +00:00
|
|
|
#compdef {{PROJECT_EXECUTABLE}}
|
2020-08-29 15:19:42 +00:00
|
|
|
|
|
|
|
local context state state_descr line
|
|
|
|
typeset -A opt_args
|
|
|
|
|
2020-10-17 06:47:09 +00:00
|
|
|
(( $+functions[_{{PROJECT_EXECUTABLE}}_cache_subcommand] )) ||
|
|
|
|
_{{PROJECT_EXECUTABLE}}_cache_subcommand() {
|
2020-08-29 15:19:42 +00:00
|
|
|
local -a args
|
|
|
|
args=(
|
|
|
|
'(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]'
|
|
|
|
'(-b --build -c --clear)'{-c,--clear}'[Remove the cached syntax definitions and themes]'
|
|
|
|
'(--source)'--source='[Use a different directory to load syntaxes and themes from]:directory:_files -/'
|
|
|
|
'(--target)'--target='[Use a different directory to store the cached syntax and theme set]:directory:_files -/'
|
2020-09-04 10:53:26 +00:00
|
|
|
'(--blank)'--blank'[Create completely new syntax and theme sets]'
|
2020-08-29 15:19:42 +00:00
|
|
|
'(: -)'{-h,--help}'[Prints help information]'
|
|
|
|
'*: :'
|
|
|
|
)
|
|
|
|
|
|
|
|
_arguments -S -s $args
|
|
|
|
}
|
|
|
|
|
2020-10-17 06:47:09 +00:00
|
|
|
(( $+functions[_{{PROJECT_EXECUTABLE}}_main] )) ||
|
|
|
|
_{{PROJECT_EXECUTABLE}}_main() {
|
2020-08-29 15:19:42 +00:00
|
|
|
local -a args
|
|
|
|
args=(
|
|
|
|
'(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
|
2020-10-17 06:47:09 +00:00
|
|
|
'*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]'
|
2020-08-29 15:19:42 +00:00
|
|
|
'(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language'
|
|
|
|
'(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...'
|
|
|
|
'(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
|
|
|
|
'(-d --diff)'--diff'[Only show lines that have been added/removed/modified]'
|
|
|
|
'(--diff-context)'--diff-context'[Include N lines of context around added/removed/modified lines when using `--diff`]:<N> (lines):()'
|
|
|
|
'(--tabs)'--tabs'[Set the tab width to T spaces]:<T> (tab width):()'
|
|
|
|
'(--wrap)'--wrap='[Specify the text-wrapping mode]:<when>:(auto never character)'
|
|
|
|
'(--terminal-width)'--terminal-width'[Explicitly set the width of the terminal instead of determining it automatically]:<width>'
|
|
|
|
'(-n --number)'{-n,--number}'[Show line numbers]'
|
|
|
|
'(--color)'--color='[When to use colors]:<when>:(auto never always)'
|
|
|
|
'(--italic-text)'--italic-text='[Use italics in output]:<when>:(always never)'
|
|
|
|
'(--decorations)'--decorations='[When to show the decorations]:<when>:(auto never always)'
|
|
|
|
'(--paging)'--paging='[Specify when to use the pager]:<when>:(auto never always)'
|
|
|
|
'(-m --map-syntax)'{-m+,--map-syntax=}'[Use the specified syntax for files matching the glob pattern]:<glob\:syntax>...'
|
|
|
|
'(--theme)'--theme='[Set the color theme for syntax highlighting]:<theme>:->theme'
|
|
|
|
'(: --list-themes --list-languages -L)'--list-themes'[Display all supported highlighting themes]'
|
|
|
|
'(--style)'--style='[Comma-separated list of style elements to display]:<components>:->style'
|
|
|
|
'(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:<N\:M>...'
|
|
|
|
'(: --list-themes --list-languages -L)'{-L,--list-languages}'[Display all supported languages]'
|
2021-06-23 11:57:42 +00:00
|
|
|
'(: --no-config)'--no-config'[Do not use the configuration file]'
|
2021-07-27 18:11:58 +00:00
|
|
|
'(: --no-custom-assets)'--no-custom-assets'[Do not load custom assets]'
|
2021-06-23 11:57:42 +00:00
|
|
|
'(: --config-dir)'--config-dir'[Show bat'"'"'s configuration directory]'
|
|
|
|
'(: --config-file)'--config-file'[Show path to the configuration file]'
|
|
|
|
'(: --generate-config-file)'--generate-config-file'[Generates a default configuration file]'
|
|
|
|
'(: --cache-dir)'--cache-dir'[Show bat'"'"'s cache directory]'
|
2020-08-29 15:19:42 +00:00
|
|
|
'(: -)'{-h,--help}'[Print this help message]'
|
|
|
|
'(: -)'{-V,--version}'[Show version information]'
|
|
|
|
'*: :_files'
|
|
|
|
)
|
|
|
|
|
|
|
|
_arguments -S -s $args
|
|
|
|
|
2020-10-17 06:47:09 +00:00
|
|
|
case "$state" in
|
2020-08-29 15:19:42 +00:00
|
|
|
language)
|
|
|
|
local IFS=$'\n'
|
|
|
|
local -a languages
|
2020-09-08 10:34:42 +00:00
|
|
|
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
2020-08-29 15:19:42 +00:00
|
|
|
|
2020-10-17 06:47:09 +00:00
|
|
|
_describe 'language' languages
|
2020-08-29 15:19:42 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
theme)
|
|
|
|
local IFS=$'\n'
|
|
|
|
local -a themes
|
2020-09-08 10:34:42 +00:00
|
|
|
themes=( $({{PROJECT_EXECUTABLE}} --list-themes | sort) )
|
2020-08-29 15:19:42 +00:00
|
|
|
|
|
|
|
_values 'theme' $themes
|
|
|
|
;;
|
|
|
|
|
|
|
|
style)
|
2021-10-11 17:13:16 +00:00
|
|
|
_values -s , 'style' auto full plain changes header grid rule numbers snip
|
2020-08-29 15:19:42 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
# first positional argument
|
|
|
|
if (( ${#words} == 2 )); then
|
2020-08-30 08:59:35 +00:00
|
|
|
local -a subcommands
|
|
|
|
subcommands=('cache:Modify the syntax-definition and theme cache')
|
|
|
|
_describe subcommand subcommands
|
2020-10-17 06:47:09 +00:00
|
|
|
_{{PROJECT_EXECUTABLE}}_main
|
2020-08-29 15:19:42 +00:00
|
|
|
else
|
|
|
|
case $words[2] in
|
|
|
|
cache)
|
2020-10-17 06:47:09 +00:00
|
|
|
_{{PROJECT_EXECUTABLE}}_cache_subcommand
|
2020-08-29 15:19:42 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2020-10-17 06:47:09 +00:00
|
|
|
_{{PROJECT_EXECUTABLE}}_main
|
2020-08-29 15:19:42 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|