mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 15:12:12 +00:00 
			
		
		
		
	add completion for 'cache' subcommand
This commit is contained in:
		
							
								
								
									
										129
									
								
								assets/completions/bat.zsh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										129
									
								
								assets/completions/bat.zsh
									
									
									
									
										vendored
									
									
								
							| @@ -1,56 +1,91 @@ | |||||||
| #compdef bat | #compdef bat | ||||||
| # FIXME: help me with the subcommand `cache`, zsh completion is hard as hell |  | ||||||
|  |  | ||||||
| local -a args | local context state state_descr line | ||||||
| local state | typeset -A opt_args | ||||||
|  |  | ||||||
| args=( | (( $+functions[_cache_subcommand] )) || | ||||||
|     '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]' | _cache_subcommand() { | ||||||
|     {-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --paging=never`)' |     local -a args | ||||||
|     '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language' |     args=( | ||||||
|     '(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...' |         '(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]' | ||||||
|     '(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files' |         '(-b --build -c --clear)'{-c,--clear}'[Remove the cached syntax definitions and themes]' | ||||||
|     '(-d --diff)'--diff'[Only show lines that have been added/removed/modified]' |         '(--source)'--source='[Use a different directory to load syntaxes and themes from]:directory:_files -/' | ||||||
|     '(--diff-context)'--diff-context'[Include N lines of context around added/removed/modified lines when using `--diff`]:<N> (lines):()' |         '(--target)'--target='[Use a different directory to store the cached syntax and theme set]:directory:_files -/' | ||||||
|     '(--tabs)'--tabs'[Set the tab width to T spaces]:<T> (tab width):()' |         '(--blank)'--blank'[Create completely new syntax and theme sets)]' | ||||||
|     '(--wrap)'--wrap='[Specify the text-wrapping mode]:<when>:(auto never character)' |         '(: -)'{-h,--help}'[Prints help information]' | ||||||
|     '(--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]' |  | ||||||
|     '(: -)'{-h,--help}'[Print this help message]' |  | ||||||
|     '(: -)'{-V,--version}'[Show version information]' |  | ||||||
|     '*: :_files' |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| _arguments -S -s $args |     _arguments -S -s $args | ||||||
|  | } | ||||||
|  |  | ||||||
| case "$state" in  | (( $+functions[_bat_main] )) || | ||||||
|     language) | _bat_main() { | ||||||
|         local IFS=$'\n' |     local -a args | ||||||
|         local -a languages |     args=( | ||||||
|         languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') ) |         '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]' | ||||||
|  |         {-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --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]' | ||||||
|  |         '(: -)'{-h,--help}'[Print this help message]' | ||||||
|  |         '(: -)'{-V,--version}'[Show version information]' | ||||||
|  |         '*: :_files' | ||||||
|  |     ) | ||||||
|  |  | ||||||
|         _describe 'language' languages  |     _arguments -S -s $args | ||||||
|     ;; |  | ||||||
|  |  | ||||||
|     theme) |     case "$state" in  | ||||||
|         local IFS=$'\n' |         language) | ||||||
|         local -a themes |             local IFS=$'\n' | ||||||
|         themes=( $(bat --list-themes | sort) ) |             local -a languages | ||||||
|  |             languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') ) | ||||||
|  |  | ||||||
|         _values 'theme' $themes |             _describe 'language' languages  | ||||||
|     ;; |         ;; | ||||||
|  |  | ||||||
|     style) |         theme) | ||||||
|         _values -s , 'style' auto full plain changes header grid numbers snip |             local IFS=$'\n' | ||||||
|     ;; |             local -a themes | ||||||
| esac |             themes=( $(bat --list-themes | sort) ) | ||||||
|  |  | ||||||
|  |             _values 'theme' $themes | ||||||
|  |         ;; | ||||||
|  |  | ||||||
|  |         style) | ||||||
|  |             _values -s , 'style' auto full plain changes header grid numbers snip | ||||||
|  |         ;; | ||||||
|  |     esac | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # first positional argument | ||||||
|  | if (( ${#words} == 2 )); then | ||||||
|  |     _values subcommand cache | ||||||
|  |     _bat_main | ||||||
|  | else | ||||||
|  |     case $words[2] in | ||||||
|  |         cache) | ||||||
|  |             _cache_subcommand | ||||||
|  |         ;; | ||||||
|  |  | ||||||
|  |         *) | ||||||
|  |             _bat_main | ||||||
|  |         ;; | ||||||
|  |     esac | ||||||
|  | fi | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user