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:
		
							
								
								
									
										39
									
								
								assets/completions/bat.zsh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								assets/completions/bat.zsh
									
									
									
									
										vendored
									
									
								
							| @@ -1,9 +1,27 @@ | |||||||
| #compdef bat | #compdef bat | ||||||
| # FIXME: help me with the subcommand `cache`, zsh completion is hard as hell |  | ||||||
|  |  | ||||||
|  | local context state state_descr line | ||||||
|  | typeset -A opt_args | ||||||
|  |  | ||||||
|  | (( $+functions[_cache_subcommand] )) || | ||||||
|  | _cache_subcommand() { | ||||||
|     local -a args |     local -a args | ||||||
| local state |     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=( |     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`)' | ||||||
| @@ -54,3 +72,20 @@ case "$state" in | |||||||
|             _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