aboutsummaryrefslogtreecommitdiff
path: root/bat/autocomplete
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /bat/autocomplete
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'bat/autocomplete')
-rw-r--r--bat/autocomplete/_bat.ps192
-rw-r--r--bat/autocomplete/bat.bash101
-rw-r--r--bat/autocomplete/bat.fish219
-rw-r--r--bat/autocomplete/bat.zsh99
4 files changed, 511 insertions, 0 deletions
diff --git a/bat/autocomplete/_bat.ps1 b/bat/autocomplete/_bat.ps1
new file mode 100644
index 0000000..6cac09b
--- /dev/null
+++ b/bat/autocomplete/_bat.ps1
@@ -0,0 +1,92 @@
+
+using namespace System.Management.Automation
+using namespace System.Management.Automation.Language
+
+Register-ArgumentCompleter -Native -CommandName 'bat' -ScriptBlock {
+ param($wordToComplete, $commandAst, $cursorPosition)
+
+ $commandElements = $commandAst.CommandElements
+ $command = @(
+ 'bat'
+ for ($i = 1; $i -lt $commandElements.Count; $i++) {
+ $element = $commandElements[$i]
+ if ($element -isnot [StringConstantExpressionAst] -or
+ $element.StringConstantType -ne [StringConstantType]::BareWord -or
+ $element.Value.StartsWith('-')) {
+ break
+ }
+ $element.Value
+ }) -join ';'
+
+ $completions = @(switch ($command) {
+ 'bat' {
+ [CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.')
+ [CompletionResult]::new('--language', 'language', [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.')
+ [CompletionResult]::new('-H', 'H', [CompletionResultType]::ParameterName, 'Highlight lines N through M.')
+ [CompletionResult]::new('--highlight-line', 'highlight-line', [CompletionResultType]::ParameterName, 'Highlight lines N through M.')
+ [CompletionResult]::new('--file-name', 'file-name', [CompletionResultType]::ParameterName, 'Specify the name to display for a file.')
+ [CompletionResult]::new('--diff-context', 'diff-context', [CompletionResultType]::ParameterName, 'diff-context')
+ [CompletionResult]::new('--tabs', 'tabs', [CompletionResultType]::ParameterName, 'Set the tab width to T spaces.')
+ [CompletionResult]::new('--wrap', 'wrap', [CompletionResultType]::ParameterName, 'Specify the text-wrapping mode (*auto*, never, character).')
+ [CompletionResult]::new('--terminal-width', 'terminal-width', [CompletionResultType]::ParameterName, 'Explicitly set the width of the terminal instead of determining it automatically. If prefixed with ''+'' or ''-'', the value will be treated as an offset to the actual terminal width. See also: ''--wrap''.')
+ [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'When to use colors (*auto*, never, always).')
+ [CompletionResult]::new('--italic-text', 'italic-text', [CompletionResultType]::ParameterName, 'Use italics in output (always, *never*)')
+ [CompletionResult]::new('--decorations', 'decorations', [CompletionResultType]::ParameterName, 'When to show the decorations (*auto*, never, always).')
+ [CompletionResult]::new('--paging', 'paging', [CompletionResultType]::ParameterName, 'Specify when to use the pager, or use `-P` to disable (*auto*, never, always).')
+ [CompletionResult]::new('--pager', 'pager', [CompletionResultType]::ParameterName, 'Determine which pager to use.')
+ [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
+ [CompletionResult]::new('--map-syntax', 'map-syntax', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
+ [CompletionResult]::new('--theme', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting.')
+ [CompletionResult]::new('--style', 'style', [CompletionResultType]::ParameterName, 'Comma-separated list of style elements to display (*default*, auto, full, plain, changes, header, header-filename, header-filesize, grid, rule, numbers, snip).')
+ [CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
+ [CompletionResult]::new('--line-range', 'line-range', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
+ [CompletionResult]::new('-A', 'A', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
+ [CompletionResult]::new('--show-all', 'show-all', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
+ [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').')
+ [CompletionResult]::new('--plain', 'plain', [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').')
+ [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.')
+ [CompletionResult]::new('--diff', 'diff', [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.')
+ [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').')
+ [CompletionResult]::new('--number', 'number', [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').')
+ [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'f')
+ [CompletionResult]::new('--force-colorization', 'force-colorization', [CompletionResultType]::ParameterName, 'force-colorization')
+ [CompletionResult]::new('-P', 'P', [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''')
+ [CompletionResult]::new('--no-paging', 'no-paging', [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''')
+ [CompletionResult]::new('--list-themes', 'list-themes', [CompletionResultType]::ParameterName, 'Display all supported highlighting themes.')
+ [CompletionResult]::new('-L', 'L', [CompletionResultType]::ParameterName, 'Display all supported languages.')
+ [CompletionResult]::new('--list-languages', 'list-languages', [CompletionResultType]::ParameterName, 'Display all supported languages.')
+ [CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'u')
+ [CompletionResult]::new('--unbuffered', 'unbuffered', [CompletionResultType]::ParameterName, 'unbuffered')
+ [CompletionResult]::new('--no-config', 'no-config', [CompletionResultType]::ParameterName, 'Do not use the configuration file')
+ [CompletionResult]::new('--no-custom-assets', 'no-custom-assets', [CompletionResultType]::ParameterName, 'Do not load custom assets')
+ [CompletionResult]::new('--config-file', 'config-file', [CompletionResultType]::ParameterName, 'Show path to the configuration file.')
+ [CompletionResult]::new('--generate-config-file', 'generate-config-file', [CompletionResultType]::ParameterName, 'Generates a default configuration file.')
+ [CompletionResult]::new('--config-dir', 'config-dir', [CompletionResultType]::ParameterName, 'Show bat''s configuration directory.')
+ [CompletionResult]::new('--cache-dir', 'cache-dir', [CompletionResultType]::ParameterName, 'Show bat''s cache directory.')
+ [CompletionResult]::new('--diagnostic', 'diagnostic', [CompletionResultType]::ParameterName, 'Show diagnostic information for bug reports.')
+ [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print this help message.')
+ [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print this help message.')
+ [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Show version information.')
+ [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Show version information.')
+ [CompletionResult]::new('cache', 'cache', [CompletionResultType]::ParameterValue, 'Modify the syntax-definition and theme cache')
+ break
+ }
+ 'bat;cache' {
+ [CompletionResult]::new('--source', 'source', [CompletionResultType]::ParameterName, 'Use a different directory to load syntaxes and themes from.')
+ [CompletionResult]::new('--target', 'target', [CompletionResultType]::ParameterName, 'Use a different directory to store the cached syntax and theme set.')
+ [CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.')
+ [CompletionResult]::new('--build', 'build', [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.')
+ [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.')
+ [CompletionResult]::new('--clear', 'clear', [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.')
+ [CompletionResult]::new('--blank', 'blank', [CompletionResultType]::ParameterName, 'Create completely new syntax and theme sets (instead of appending to the default sets).')
+ [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
+ [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
+ [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
+ [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
+ break
+ }
+ })
+
+ $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
+ Sort-Object -Property ListItemText
+}
diff --git a/bat/autocomplete/bat.bash b/bat/autocomplete/bat.bash
new file mode 100644
index 0000000..77c2aad
--- /dev/null
+++ b/bat/autocomplete/bat.bash
@@ -0,0 +1,101 @@
+# shellcheck disable=SC2207
+
+# Requires https://github.com/scop/bash-completion
+
+# Macs have bash3 for which the bash-completion package doesn't include
+# _init_completion. This is a minimal version of that function.
+__bat_init_completion()
+{
+ COMPREPLY=()
+ _get_comp_words_by_ref "$@" cur prev words cword
+}
+
+_bat() {
+ local cur prev words cword split=false
+ if declare -F _init_completion >/dev/null 2>&1; then
+ _init_completion -s || return 0
+ else
+ __bat_init_completion -n "=" || return 0
+ _split_longopt && split=true
+ fi
+
+ if [[ ${words[1]-} == cache ]]; then
+ case $prev in
+ --source | --target)
+ _filedir -d
+ return 0
+ ;;
+ esac
+ COMPREPLY=($(compgen -W "
+ --build --clear --source --target --blank --help
+ " -- "$cur"))
+ return 0
+ fi
+
+ case $prev in
+ -l | --language)
+ local IFS=$'\n'
+ COMPREPLY=($(compgen -W "$(
+ "$1" --list-languages | while IFS=: read -r lang _; do
+ printf "%s\n" "$lang"
+ done
+ )" -- "$cur"))
+ compopt -o filenames # for escaping
+ return 0
+ ;;
+ -H | --highlight-line | --diff-context | --tabs | --terminal-width | \
+ -m | --map-syntax | --style | --line-range | -h | --help | -V | \
+ --version | --diagnostic | --config-file | --config-dir | \
+ --cache-dir | --generate-config-file)
+ # argument required but no completion available, or option
+ # causes an exit
+ return 0
+ ;;
+ --file-name)
+ _filedir
+ return 0
+ ;;
+ --wrap)
+ COMPREPLY=($(compgen -W "auto never character" -- "$cur"))
+ return 0
+ ;;
+ --color | --decorations | --paging)
+ COMPREPLY=($(compgen -W "auto never always" -- "$cur"))
+ return 0
+ ;;
+ --italic-text)
+ COMPREPLY=($(compgen -W "always never" -- "$cur"))
+ return 0
+ ;;
+ --pager)
+ COMPREPLY=($(compgen -c -- "$cur"))
+ return 0
+ ;;
+ --theme)
+ local IFS=$'\n'
+ COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur"))
+ compopt -o filenames # for escaping
+ return 0
+ ;;
+ esac
+
+ $split && return 0
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "
+ --show-all --plain --language --highlight-line
+ --file-name --diff --diff-context --tabs --wrap
+ --terminal-width --number --color --italic-text
+ --decorations --paging --pager --map-syntax --theme
+ --list-themes --style --line-range --list-languages
+ --help --version --force-colorization --unbuffered
+ --diagnostic --config-file --config-dir --cache-dir
+ --generate-config-file
+ " -- "$cur"))
+ return 0
+ fi
+
+ _filedir
+ ((cword == 1)) && COMPREPLY+=($(compgen -W cache -- "$cur"))
+
+} && complete -F _bat bat
diff --git a/bat/autocomplete/bat.fish b/bat/autocomplete/bat.fish
new file mode 100644
index 0000000..61f6ea7
--- /dev/null
+++ b/bat/autocomplete/bat.fish
@@ -0,0 +1,219 @@
+# Fish Shell Completions
+# Copy or symlink to $XDG_CONFIG_HOME/fish/completions/bat.fish
+# ($XDG_CONFIG_HOME is usually set to ~/.config)
+
+# `bat` is `batcat` on Debian and Ubuntu
+set bat bat
+
+# Helper functions:
+
+function __bat_complete_files -a token
+ # Cheat to complete files by calling `complete -C` on a fake command name,
+ # like `__fish_complete_directories` does.
+ set -l fake_command aaabccccdeeeeefffffffffgghhhhhhiiiii
+ complete -C"$fake_command $token"
+end
+
+function __bat_complete_one_language -a comp
+ command $bat --list-languages | string split -f1 : | string match -e "$comp"
+end
+
+function __bat_complete_list_languages
+ for spec in (command $bat --list-languages)
+ set -l name (string split -f1 : $spec)
+ for ext in (string split -f2 : $spec | string split ,)
+ test -n "$ext"; or continue
+ string match -rq '[/*]' $ext; and continue
+ printf "%s\t%s\n" $ext $name
+ end
+ printf "%s\t\n" $name
+ end
+end
+
+function __bat_complete_map_syntax
+ set -l token (commandline -ct)
+
+ if string match -qr '(?<glob>.+):(?<syntax>.*)' -- $token
+ # If token ends with a colon, complete with the list of language names.
+ set -f comps $glob:(__bat_complete_one_language $syntax)
+ else if string match -qr '\*' -- $token
+ # If token contains a globbing character (`*`), complete only possible
+ # globs in the current directory
+ set -f comps (__bat_complete_files $token | string match -er '[*]'):
+ else
+ # Complete files (and globs).
+ set -f comps (__bat_complete_files $token | string match -erv '/$'):
+ end
+
+ if set -q comps[1]
+ printf "%s\t\n" $comps
+ end
+end
+
+function __bat_cache_subcommand
+ __fish_seen_subcommand_from cache
+end
+
+# Returns true if no exclusive arguments seen.
+function __bat_no_excl_args
+ not __bat_cache_subcommand; and not __fish_seen_argument \
+ -s h -l help \
+ -s V -l version \
+ -l acknowledgements \
+ -l config-dir -l config-file \
+ -l diagnostic \
+ -l list-languages -l list-themes
+end
+
+# Returns true if the 'cache' subcommand is seen without any exclusive arguments.
+function __bat_cache_no_excl
+ __bat_cache_subcommand; and not __fish_seen_argument \
+ -s h -l help \
+ -l acknowledgements -l build -l clear
+end
+
+function __bat_style_opts
+ set -l style_opts \
+ "default,recommended components" \
+ "auto,same as 'default' unless piped" \
+ "full,all components" \
+ "plain,no components" \
+ "changes,Git change markers" \
+ "header,alias for header-filename" \
+ "header-filename,filename above content" \
+ "header-filesize,filesize above content" \
+ "grid,lines b/w sidebar/header/content" \
+ "numbers,line numbers in sidebar" \
+ "rule,separate files" \
+ "snip,separate ranges"
+
+ string replace , \t $style_opts
+end
+
+# Use option argument descriptions to indicate which is the default, saving
+# horizontal space and making sure the option description isn't truncated.
+set -l color_opts '
+ auto\tdefault
+ never\t
+ always\t
+'
+set -l decorations_opts $color_opts
+set -l paging_opts $color_opts
+
+# Include some examples so we can indicate the default.
+set -l pager_opts '
+ less\tdefault
+ less\ -FR\t
+ more\t
+ vimpager\t
+'
+
+set -l italic_text_opts '
+ always\t
+ never\tdefault
+'
+
+set -l wrap_opts '
+ auto\tdefault
+ never\t
+ character\t
+'
+
+# While --tabs theoretically takes any number, most people should be OK with these.
+# Specifying a list lets us explain what 0 does.
+set -l tabs_opts '
+ 0\tpass\ tabs\ through\ directly
+ 1\t
+ 2\t
+ 4\t
+ 8\t
+'
+
+# Completions:
+
+complete -c $bat -l acknowledgements -d "Print acknowledgements" -n __fish_is_first_arg
+
+complete -c $bat -l color -x -a "$color_opts" -d "When to use colored output" -n __bat_no_excl_args
+
+complete -c $bat -l config-dir -f -d "Display location of configuration directory" -n __fish_is_first_arg
+
+complete -c $bat -l config-file -f -d "Display location of configuration file" -n __fish_is_first_arg
+
+complete -c $bat -l decorations -x -a "$decorations_opts" -d "When to use --style decorations" -n __bat_no_excl_args
+
+complete -c $bat -l diagnostic -d "Print diagnostic info for bug reports" -n __fish_is_first_arg
+
+complete -c $bat -s d -l diff -d "Only show lines with Git changes" -n __bat_no_excl_args
+
+complete -c $bat -l diff-context -x -d "Show N context lines around Git changes" -n "__fish_seen_argument -s d -l diff"
+
+complete -c $bat -l file-name -x -d "Specify the display name" -n __bat_no_excl_args
+
+complete -c $bat -s f -l force-colorization -d "Force color and decorations" -n __bat_no_excl_args
+
+complete -c $bat -s h -d "Print a concise overview" -n __fish_is_first_arg
+
+complete -c $bat -l help -f -d "Print all help information" -n __fish_is_first_arg
+
+complete -c $bat -s H -l highlight-line -x -d "Highlight line(s) N[:M]" -n __bat_no_excl_args
+
+complete -c $bat -l ignored-suffix -x -d "Ignore extension" -n __bat_no_excl_args
+
+complete -c $bat -l italic-text -x -a "$italic_text_opts" -d "When to use italic text in the output" -n __bat_no_excl_args
+
+complete -c $bat -s l -l language -x -k -a "(__bat_complete_list_languages)" -d "Set the syntax highlighting language" -n __bat_no_excl_args
+
+complete -c $bat -s r -l line-range -x -d "Only print lines [M]:[N] (either optional)" -n __bat_no_excl_args
+
+complete -c $bat -l list-languages -f -d "List syntax highlighting languages" -n __fish_is_first_arg
+
+complete -c $bat -l list-themes -f -d "List syntax highlighting themes" -n __fish_is_first_arg
+
+complete -c $bat -s m -l map-syntax -x -a "(__bat_complete_map_syntax)" -d "Map <glob pattern>:<language syntax>" -n __bat_no_excl_args
+
+complete -c $bat -s n -l number -d "Only show line numbers, no other decorations" -n __bat_no_excl_args
+
+complete -c $bat -l pager -x -a "$pager_opts" -d "Which pager to use" -n __bat_no_excl_args
+
+complete -c $bat -l paging -x -a "$paging_opts" -d "When to use the pager" -n __bat_no_excl_args
+
+complete -c $bat -s p -l plain -d "Disable decorations" -n __bat_no_excl_args
+
+complete -c $bat -o pp -d "Disable decorations and paging" -n __bat_no_excl_args
+
+complete -c $bat -s P -d "Disable paging" -n __bat_no_excl_args
+
+complete -c $bat -s A -l show-all -d "Show non-printable characters" -n __bat_no_excl_args
+
+complete -c $bat -l style -x -k -a "(__fish_complete_list , __bat_style_opts)" -d "Specify which non-content elements to display" -n __bat_no_excl_args
+
+complete -c $bat -l tabs -x -a "$tabs_opts" -d "Set tab width" -n __bat_no_excl_args
+
+complete -c $bat -l terminal-width -x -d "Set terminal <width>, +<offset>, or -<offset>" -n __bat_no_excl_args
+
+complete -c $bat -l theme -x -a "(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme" -n __bat_no_excl_args
+
+complete -c $bat -s V -l version -f -d "Show version information" -n __fish_is_first_arg
+
+complete -c $bat -l wrap -x -a "$wrap_opts" -d "Text-wrapping mode" -n __bat_no_excl_args
+
+# Sub-command 'cache' completions
+complete -c $bat -a cache -d "Modify the syntax/language definition cache" -n __fish_use_subcommand
+
+complete -c $bat -l build -f -d "Parse new definitions into cache" -n __bat_cache_no_excl
+
+complete -c $bat -l clear -f -d "Reset definitions to defaults" -n __bat_cache_no_excl
+
+complete -c $bat -l blank -f -d "Create new data instead of appending" -n "__bat_cache_subcommand; and not __fish_seen_argument -l clear"
+
+complete -c $bat -l source -x -a "(__fish_complete_directories)" -d "Load syntaxes and themes from DIR" -n "__bat_cache_subcommand; and not __fish_seen_argument -l clear"
+
+complete -c $bat -l target -x -a "(__fish_complete_directories)" -d "Store cache in DIR" -n __bat_cache_subcommand
+
+complete -c $bat -l acknowledgements -d "Build acknowledgements.bin" -n __bat_cache_no_excl
+
+complete -c $bat -s h -d "Print a concise overview of $bat-cache help" -n __bat_cache_no_excl
+
+complete -c $bat -l help -f -d "Print all $bat-cache help" -n __bat_cache_no_excl
+
+# vim:ft=fish
diff --git a/bat/autocomplete/bat.zsh b/bat/autocomplete/bat.zsh
new file mode 100644
index 0000000..b2c93cb
--- /dev/null
+++ b/bat/autocomplete/bat.zsh
@@ -0,0 +1,99 @@
+#compdef bat
+
+local context state state_descr line
+typeset -A opt_args
+
+(( $+functions[_bat_cache_subcommand] )) ||
+_bat_cache_subcommand() {
+ 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 -/'
+ '(--blank)'--blank'[Create completely new syntax and theme sets]'
+ '(: -)'{-h,--help}'[Prints help information]'
+ '*: :'
+ )
+
+ _arguments -S -s $args
+}
+
+(( $+functions[_bat_main] )) ||
+_bat_main() {
+ local -a args
+ args=(
+ '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
+ '*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]'
+ '(-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]'
+ '(: --no-config)'--no-config'[Do not use the configuration file]'
+ '(: --no-custom-assets)'--no-custom-assets'[Do not load custom assets]'
+ '(: --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]'
+ '(: -)'{-h,--help}'[Print this help message]'
+ '(: -)'{-V,--version}'[Show version information]'
+ '*: :_files'
+ )
+
+ _arguments -S -s $args
+
+ case "$state" in
+ language)
+ local IFS=$'\n'
+ local -a languages
+ languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
+
+ _describe 'language' languages
+ ;;
+
+ theme)
+ local IFS=$'\n'
+ local -a themes
+ themes=( $(bat --list-themes | sort) )
+
+ _values 'theme' $themes
+ ;;
+
+ style)
+ _values -s , 'style' default auto full plain changes header header-filename header-filesize grid rule numbers snip
+ ;;
+ esac
+}
+
+# first positional argument
+if (( ${#words} == 2 )); then
+ local -a subcommands
+ subcommands=('cache:Modify the syntax-definition and theme cache')
+ _describe subcommand subcommands
+ _bat_main
+else
+ case $words[2] in
+ cache)
+ _bat_cache_subcommand
+ ;;
+
+ *)
+ _bat_main
+ ;;
+ esac
+fi