cgvg for Mac
Code Grep and Vi Grepped cg, vg - tools for finding and modifying on keywords Joshua Uziel - August 28, 2014 - version 1.6.3
cgvg — overview
Code Grep and Vi Grepped cg, vg - tools for finding and modifying on keywords Joshua Uziel - August 28, 2014 - version 1.6.3
[Note: the below is historical... SCO released cscope under a BSD license several months ago (http://cscope.sourceforge.net/), which I also work on. This doesn't mean cgvg isn't useful anymore... I personally still use it, and I'm happy to have it... maybe you'll find use in it as well.]
All too often I need to dig through source code. Where something is defined, used, what files, etc. There's a great tool for doing this from AT&T called "cscope" and a very alpha free clone of it called "cs" (that doesn't look like it's being actively worked on) that does this. There are some alternatives... like ctags and etags for instance... but these only take you to where something is defined... not wherever it is used, which makes it frustrating when, for example, you're at the definition of a function and instead want to see who and what use that function.
So, as a quick hack, mostly for myself, I started writing up some perl scripts (I consciously chose perl, but considered other languages first). One script, "cg", does the equivalent of a find and grep, storing matches and then displaying it in a human-friendly manner. Run it like so:
[11:14pm] tux:/usr/src/linux/fs> cg ext2_permission 0 ext2/acl.c 22 ext2_permission () 1 ext2/acl.c 26 int ext2_permission (struct inode inode, int mask) 2 ext2/dir.c 74 ext2_permission, / permission / 3 ext2/file.c 102 ext2_permission, / permission /
So, you see in the first column, we have a count, the second column is the filename, the third column is the line number, and after that is what it found on that line. This gets stored in your home directory in a log file, so that if you want to see it again, all you have to do is type "cg" to view it again. Also stored in the first line is the pwd of where your inquiry was run from, so you that won't have to be there to do the second half of this kit.
There are several ways of running "cg". Again, "cg" alone recalls the last search. You can also run it like "cg pattern", and it'll search recursively for all default patterns. To that, you can add arguments like "-i" for case insensitive like "cg -i pattern". If you don't want to use the default searching, you can specify where to search and run like grep(1). For example, running "cg pattern '.c'" will check all .c files recursively. If you want to search all files, you can use "cg pattern ''". Note that the quotes (single or double, it doesn't matter) are recommended because otherwise the shell expands it before it gets to perl, so the search would not be recursive. It of course works like this as well. This script also supports coloring and bolding options which are both hardcoded and customizable per-user with a ~/.cgvgrc file.
Details
命令行源代码浏览工具
How to install cgvg
- Open Terminal (press ⌘ + Space and type “Terminal”).
- If Homebrew is not installed yet, run the command below first.
- Run this command:
Latest 10 releases
Last updated 2014-08-28; current version v1.6.3, with the latest 10 releases listed.
| Version | Released | Type | Size | macOS | Windows | Linux |
|---|---|---|---|---|---|---|
| v1.6.3 | 2014-08-28 | Stable | — | — | — | — |
| v1.6.2 | 2014-03-07 | Stable | — | — | — | — |
| v1.6.1 | 2014-03-07 | Stable | — | — | — | — |
| v1.6.0 | 2014-03-07 | Stable | — | — | — | — |
| v1.5.2 | 2014-03-07 | Stable | — | — | — | — |
| v1.5.1 | 2014-03-07 | Stable | — | — | — | — |
| v1.5 | 2014-03-07 | Stable | — | — | — | — |
| v1.4 | 2014-03-07 | Stable | — | — | — | — |
| v1.3 | 2014-03-07 | Stable | — | — | — | — |
| v1.2 | 2014-03-07 | Stable | — | — | — | — |
Data from GitHub Releases; stable releases first, each group sorted newest first.
Prebuilt bottle platforms
Official Homebrew bottles cover:
- all
⚠️ No prebuilt bottle for Intel Macs; Intel users need brew install --build-from-source to build from source.
Compared with similar apps
Only public metadata is compared, with no subjective recommendation; see the compare pages for field-by-field comparisons.
| App | Version | License | Architecture | 30-day installs |
|---|---|---|---|---|
| cgvg | v1.6.3 | GPL-2.0-or-later | CLI | 9 |
| procps | 4.0.7 | GPL-2.0-or-later | CLI | 15 |
| codequery | 1.1.0 | MPL-2.0 | CLI | 3 |
| cscope | 15.9 | BSD-3-Clause | CLI | 34 |
Similar apps: Command-line Tools
procps
procps is a set of command line and full-screen utilities that provide information out of the…codequery
Code-understanding, code-browsing or code-search toolcscope
cscope is a command-line tool for browsing source code, particularly well suited to reading and…hister
Self-hosted search engine for your browsing historyopenssl@4
Cryptography and SSL/TLS Toolkitxz
General-purpose data compression with high compression ratioCategories: Command-line Tools