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:
		
							
								
								
									
										51
									
								
								assets/completions/bat.zsh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								assets/completions/bat.zsh
									
									
									
									
										vendored
									
									
								
							| @@ -1,10 +1,28 @@ | |||||||
| #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] )) || | ||||||
|  | _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, ..)]' |         '(-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`)' |         {-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' |         '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language' | ||||||
| @@ -29,11 +47,11 @@ args=( | |||||||
|         '(: -)'{-h,--help}'[Print this help message]' |         '(: -)'{-h,--help}'[Print this help message]' | ||||||
|         '(: -)'{-V,--version}'[Show version information]' |         '(: -)'{-V,--version}'[Show version information]' | ||||||
|         '*: :_files' |         '*: :_files' | ||||||
| ) |     ) | ||||||
|  |  | ||||||
| _arguments -S -s $args |     _arguments -S -s $args | ||||||
|  |  | ||||||
| case "$state" in  |     case "$state" in  | ||||||
|         language) |         language) | ||||||
|             local IFS=$'\n' |             local IFS=$'\n' | ||||||
|             local -a languages |             local -a languages | ||||||
| @@ -53,4 +71,21 @@ case "$state" in | |||||||
|         style) |         style) | ||||||
|             _values -s , 'style' auto full plain changes header grid numbers snip |             _values -s , 'style' auto full plain changes header grid numbers snip | ||||||
|         ;; |         ;; | ||||||
| esac |     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