#compdef tgrep autoload -U is-at-least _tgrep() { typeset -A opt_args typeset -a _arguments_options local ret=1 if is-at-least 5.2; then _arguments_options=(-s -S -C) else _arguments_options=(-s -C) fi local context curcontext="$curcontext" state line _arguments "${_arguments_options[@]}" \ '*-e+[specify the regex expression]:: ' \ '*--regexp=[specify the regex expression]:: ' \ '-t+[specify the search target. If none provided, search the current directory.]::_files' \ '--target=[specify the search target. If none provided, search the current directory.]::_files' \ '--max-depth=[the max depth to search]:: ' \ '--threads=[set the appropriate number of threads to use]:: ' \ '--max-length=[set the max length for a matched line]:: ' \ '(-l --tree)-s+[executable to do the searching]::(rg tgrep)' \ '(-l --tree)--searcher=[executable to do the searching]::(rg tgrep)' \ '*--glob=[rules match .gitignore globs, but ! has inverted meaning, overrides other ignore logic]:: ' \ '-c[display number of files matched in directory and number of lines matched in a file if present]' \ '--count[display number of files matched in directory and number of lines matched in a file if present]' \ '-.[search hidden files]' \ '--hidden[search hidden files]' \ '-n[show line number of match if present]' \ '--line-number[show line number of match if present]' \ '-m[open results in a menu to be edited with \$EDITOR navigate through the menu using the following commands\: - move up/down\: k/j, p/n, up arrow/down arrow - move up/down with a bigger jump\: K/J, P/N - move up/down paths\: {/}, \[/\] - move to the start/end\: g/G, , home/end - move up/down a page\: b/f, pageup/pagedown - quit\: q, ctrl + c]' \ '--menu[open results in a menu to be edited with \$EDITOR navigate through the menu using the following commands\: - move up/down\: k/j, p/n, up arrow/down arrow - move up/down with a bigger jump\: K/J, P/N - move up/down paths\: {/}, \[/\] - move to the start/end\: g/G, , home/end - move up/down a page\: b/f, pageup/pagedown - quit\: q, ctrl + c]' \ '-f[show the paths that have matches]' \ '--files[show the paths that have matches]' \ '--links[show linked paths for symbolic links]' \ '--trim[trim whitespace at the beginning of lines]' \ '--pcre2[enable PCRE2 if the searcher supports it]' \ '--no-ignore[don'\''t use ignore files]' \ '--no-color[don'\''t use colors if present]' \ '(-e --regexp)-l[display the files that would be search in tree format]' \ '(-e --regexp)--tree[display the files that would be search in tree format]' \ '-h[Print help]' \ '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ '::positional regexp -- specify the regex expression:' \ '::positional target -- specify the search target. If none provided, search the current directory.:_files' \ && ret=0 } (( $+functions[_tgrep_commands] )) || _tgrep_commands() { local commands; commands=() _describe -t commands 'tgrep commands' commands "$@" } if [ "$funcstack[1]" = "_tgrep" ]; then _tgrep "$@" else compdef _tgrep tgrep fi