phiresky / ripgrep-all

rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
Other
6.39k stars 148 forks source link

add bash / zsh / fish shell completion for flags #226

Open j-lakeman opened 1 month ago

j-lakeman commented 1 month ago

Would be cool if flags like --rga-adapters could be autocompleted upon pressing TAB. This would increase the ease of use of this already great application lots IMHO.

Konfekt commented 1 month ago

You could give https://github.com/sigoden/argc-completions/blob/main/completions/rga.sh a whirl

j-lakeman commented 1 month ago

Cheers, that's awesome! However I still believe the application itself should provide that, just like ripgrep does.

Konfekt commented 1 month ago

Rga's additional parameters seem straight-forward, so something like adding the following lines to rg's zsh completion (where the patch uses rg 0.13.0) seems sufficient:

0a1
> 
326c327,344
<   )
---
> 
>     + rga
>     '--rga-accurate[Use more accurate but slower matching by mime type]' \
>     '--rga-no-cache[Disable caching of results]' \
>     '--rga-list-adapters[List all known adapters]' \
>     '--rga-no-prefix-filenames[Do not prefix lines of files within archive with the path inside the archive]' \
>     '--rga-print-config-schema[Print the JSON Schema of the configuration file]' \
>     '--rg-help[Show help for ripgrep itself]' \
>     '--rg-version[Show version of ripgrep itself]' \
>     '-V[Prints version information]' \
>     '--version[Prints version information]' \
>     '--rga-adapters=[Change which adapters to use and in which priority order (descending)]:adapters' \
>     '--rga-cache-compression-level=[ZSTD compression level to apply to adapter outputs before storing in cache db]:compression-level' \
>     '--rga-config-file=[Path to configuration file]:config-file-path' \
>     '--rga-max-archive-recursion=[Maximum nestedness of archives to recurse into]:max-archive-recursion' \
>     '--rga-cache-max-blob-len=[Max compressed size to cache]:max-blob-len' \
>     '--rga-cache-path=[Path to store cache db]:path'
>     )