NAME
rg - search the notes, from here downwards
SYNOPSIS
rg [-isSwFlcvqnN] [--hidden] [--no-heading] [-g glob] pattern [path ...]
DESCRIPTION
The same question grep answers, asked the way ripgrep asks it — which is why
hands reach for it. With no path at all it searches everything below where you
are standing, where grep wants -r before it will; it numbers the lines; and
it groups them under the note they came from rather than putting the name in
front of every one.
Every name it prints is a link, as everything in this shell is.
Flags may be written anywhere on the line. rg beta -i is a case-insensitive
search, where grep beta -i is a search for beta in a file called -i —
ripgrep is not getopt, and neither is this.
What it leaves alone
Names beginning with a dot, until --hidden asks for them, and the rule is
about the whole path: a note inside a hidden directory is hidden too. It says
nothing about a hidden file it could not have read, because it never opened
one — which is the difference between rg and rg --hidden in ~, where
.ssh is nobody’s business but the owner’s.
What it cannot read it names, in the words Rust puts on a failed open — which
in ~ takes --hidden, since everything there that a guest may not read
begins with a dot:
$ rg --hidden beans
.zsh_history: Permission denied (os error 13)
.ssh: Permission denied (os error 13)
and it carries on with the rest. There is no .gitignore on this machine, so
hidden is the only thing it skips.
Through a pipe
One line per match with the name in front, because that is what another
program can read: rg -l is | wc -l. ls drops its columns through a pipe
for the same reason, and real rg does exactly this when it is not talking to a
terminal.
What it answers
0 when it found something, 1 when it did not, 2 when it could not look —
grep’s statuses, which is what makes if rg -q vegan; then a question.
Two things to know about the text it searches: a note is the note as the site renders it, so the frontmatter is not in it and a line is a paragraph; and the pattern is a JavaScript regular expression rather than Rust’s. Anything you would type at a prompt behaves the same.
OPTIONS
- -i
- ignore case
- -s
- do not, whatever -i or -S said. This is the default, and it is the flag that overrules them.
- -S
- smart case: a pattern with no capital in it stops caring about case, one with a capital keeps caring
- -w
- whole words only, so vegan does not match vegans
- -F
- the pattern is text rather than a regular expression, dots and stars and all
- -l
- print the notes that matched and not the lines
- -c
- print how many lines matched in each note
- -v
- select the lines that do not match
- -q
- print nothing at all; the answer is the exit status
- -n
- number the lines. They are numbered already; this says so out loud.
- -N
- do not number the lines
- -g glob
- only the paths this matches. Write it more than once, and put a ! in front of one to exclude instead.
- --hidden
- look in the names beginning with a dot as well
- --no-heading
- one line per match with the name in front of it, the way grep prints. A pipe means this anyway.
EXAMPLES
rg vegan
rg -i nixos ~/writing
rg -l flake
rg -g '*.md' -w is