CG(1)

🌸 CG β€” the manual, but make it a group chat 🌸

okay so bestie, this is cg(1) β€” manual section 1, the user commands section, and honestly? she's iconic. no preamble needed, let's get into it. πŸ’–


✨ NAME ✨

cg β€” recursively grep for a pattern and store it. that's it, that's the whole job. search the tree, keep the receipts. 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹


like, it's either `<mint>-l</mint>` on its own OR a pattern (maybe with `<mint>-i</mint>`) and maybe some files. pick a lane, she supports both. πŸ’…

---

# 🌈 DESCRIPTION 🌈

okay so here's the tea. `cg` does a search through text files β€” usually source code, because that's the vibe β€” **recursively**, hunting for a pattern, and it *stores* the matches, then shows you the output in a <cyan>human-readable</cyan> fashion. she's giving you the receipts in a format your eyeballs can actually handle. ✨

the whole point? it's meant to give you *some* of the functionality of AT&T's `cscope(1)` tool, but with the advantages of <green>simplicity</green> and <green>not being language-specific</green>. no cap. she doesn't care what language you write in, she's not gonna gatekeep. and if you've configured her that way, the script will <rainbow>colorize</rainbow> the output. πŸ’–

you'll typically run her with a <purple>Perl regular expression</purple> to search for. want it case insensitive? that's what the `-i` option is for, periodt.

you can also hand her a list of files with an extra argument after the pattern. **important:** put that files pattern in <yellow>quotes</yellow> so it gets matched by <purple>Perl</purple> instead of by the shell. fr fr, the quotes are load-bearing.

run the script with **no arguments at all** and she'll recall the results of your previous search β€” like a little memory keeper. πŸ§ πŸ’–

after the search, the entries you found can be edited using the `vg(1)` script. and the `-l` option? that shows you the last log made. easy.

---

# πŸ’œ SOME EXAMPLES πŸ’œ

let's run through them, bestie, because examples are where it all clicks:

- `cg` β€” just her, alone, no args. this <hotpink>recalls the previous search results</hotpink>. she remembers. πŸ™ˆ
- `cg -i pattern` β€” search the **default list of files** for everything matching the pattern, and do it <cyan>case-insensitively</cyan>. lowercase pattern, uppercase results, no problem.
- `cg pattern '*.c'` β€” search **recursively** for the pattern in all `*.c` files. and here's the cute part: this automatically converts `'*'` to `'.*'` and `'.'` to `'\.'` for you, then does a Perl pattern match on all the files in the tree. she's doing the escaping so you don't have to. πŸ‘‘
- `cg pattern *.c` β€” this one goes through the <yellow>shell-expanded</yellow> list of `*.c` files, so it is **not** done recursively. in other words: only the files your shell passes to the script as arguments. that's it. the shell already did the globbing, so `cg` doesn't get to wander. πŸ¦‹
- `cg -l` β€” show the last log made. boom. done.

---

# πŸ’… COMMAND-LINE OPTIONS πŸ’…

- **`-i`** β€” do a case-insensitive search. case? never heard of her.
- **`-l`** β€” show the last log made. the receipts, please. 🧾
- **`-p`** β€” toggle the default pager option. so here's the deal: `cg` has a built-in pager function, and it can be enabled or disabled by default (in `.cgvgrc`). if the default is <green>enabled</green>, this option <red>disables</red> the pager; if the default is <red>disabled</red>, this option <green>enables</green> it. it's a toggle, bestie, she flips whichever way you're not already pointing. πŸ”„
- **`-P`** β€” force the built-in pager to be **disabled**. no pager, no negotiation. πŸ’€

---

# πŸŽ€ FILES πŸŽ€

- **`${HOME}/.cglast`** β€” log file of the last search. your most recent receipts, right in your home directory. πŸ’–
- **`${HOME}/.cgvgrc`** β€” per-user configuration file, for when the defaults are just not desirable. customize her, she loves that. ✨
- **`${HOME}/.cgvg/*`** β€” log files in `$HOSTNAME.shell_pid` form, with the log of the last search. yes, she names them by hostname and shell pid, she's organized like that. πŸ—‚οΈ

---

# πŸ”₯ SEE ALSO πŸ”₯

`vg(1)`, `perl(1)`, `find(1)`, `grep(1)`, `cscope(1)` β€” the whole friend group, go say hi. πŸ‘‘

---

# 🌟 AUTHOR 🌟

`cg` was written by <hotpink>Joshua Uziel</hotpink> `<uzi@uzix.org>`. give credit where credit is due, always. 🫢

---

and that's the whole page, bestie β€” this version is dated **13 Mar 2002** and belongs to the **`CG(1)`** manual. she's been serving since 2002 and she's still eating. periodt. πŸ’…βœ¨