Skip to content

Commit

Permalink
cli: add -. as short option for --hidden
Browse files Browse the repository at this point in the history
This is somewhat non-standard, but it seems nice on the surface: short
flag names are in short supply, --hidden is probably somewhat common and
-. has an obvious connection with how hidden files are named on Unix.

Closes #1680
  • Loading branch information
marcospb19 authored and BurntSushi committed May 30, 2021
1 parent d93480e commit 3c19c43
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ TBD
===
Unreleased changes. Release notes have not yet been written.

**BREAKING CHANGES**:

In this release, a small tweak has been made to the output format when a binary
file is detected. Previously, it looked like this:

Expand Down Expand Up @@ -31,6 +33,8 @@ Feature enhancements:
minified files, Mint, pofiles (from GNU gettext) Racket, VCL, Yang
* [FEATURE #1404](https://github.com/BurntSushi/ripgrep/pull/1404):
ripgrep now prints a warning if nothing is searched.
* [FEATURE #1680](https://github.com/BurntSushi/ripgrep/pull/1680):
Add `-.` as a short flag alias for `--hidden`.
* [FEATURE #1856](https://github.com/BurntSushi/ripgrep/pull/1856):
The README now links to a
[Spanish translation](https://github.com/UltiRequiem/traducciones/tree/master/ripgrep).
Expand Down
4 changes: 2 additions & 2 deletions ci/test-complete
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ main() {
# Occasionally we may have to handle some manually, however
help_args=( ${(f)"$(
$rg --help |
$rg -i -- '^\s+--?[a-z0-9]|--[a-z]' |
$rg -ior '$1' -- $'[\t /\"\'`.,](-[a-z0-9]|--[a-z0-9-]+)\\b' |
$rg -i -- '^\s+--?[a-z0-9.]|--[a-z]' |
$rg -ior '$1' -- $'[\t /\"\'`.,](-[a-z0-9.]|--[a-z0-9-]+)(,|\\b)' |
$rg -v -- --print0 | # False positives
sort -u
)"} )
Expand Down
2 changes: 1 addition & 1 deletion complete/_rg
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ _rg() {
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"

+ '(hidden)' # Hidden-file options
'--hidden[search hidden files and directories]'
{-.,--hidden}'[search hidden files and directories]'
$no"--no-hidden[don't search hidden files and directories]"

+ '(hybrid)' # hybrid regex options
Expand Down
9 changes: 5 additions & 4 deletions crates/core/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@ This flag can be disabled with --no-hidden.
"
);
let arg = RGArg::switch("hidden")
.short(".")
.help(SHORT)
.long_help(LONG)
.overrides("no-hidden");
Expand Down Expand Up @@ -1987,7 +1988,7 @@ fn flag_no_ignore_dot(args: &mut Vec<RGArg>) {
Don't respect .ignore files.
This does *not* affect whether ripgrep will ignore files and directories
whose names begin with a dot. For that, see --hidden.
whose names begin with a dot. For that, see the -./--hidden flag.
This flag can be disabled with the --ignore-dot flag.
"
Expand Down Expand Up @@ -2360,7 +2361,7 @@ the empty string. For example, if you are searching using 'rg foo' then using
occurrences of 'foo' will be highlighted. This flag enables the same behavior
without needing to modify the pattern.
This overrides the --context, --after-context and --before context flags.
This overrides the --context, --after-context and --before-context flags.
"
);
let arg = RGArg::switch("passthru")
Expand Down Expand Up @@ -2990,8 +2991,8 @@ fn flag_unrestricted(args: &mut Vec<RGArg>) {
"\
Reduce the level of \"smart\" searching. A single -u won't respect .gitignore
(etc.) files (--no-ignore). Two -u flags will additionally search hidden files
and directories (--hidden). Three -u flags will additionally search binary files
(--binary).
and directories (-./--hidden). Three -u flags will additionally search binary
files (--binary).
'rg -uuu' is roughly equivalent to 'grep -r'.
"
Expand Down
2 changes: 1 addition & 1 deletion doc/rg.1.txt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Each of the types of filtering can be configured via command line flags:
* There are several flags starting with '--no-ignore' that toggle which,
if any, ignore rules are respected. '--no-ignore' by itself will disable
all of them.
* '--hidden' will force ripgrep to search hidden files and directories.
* '-./--hidden' will force ripgrep to search hidden files and directories.
* '--binary' will force ripgrep to search binary files.
* '-L/--follow' will force ripgrep to follow symlinks.

Expand Down

0 comments on commit 3c19c43

Please sign in to comment.