Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theproductiveprogrammer/QuickGrep
A blazing fast, tiny, customisable grep
https://github.com/theproductiveprogrammer/QuickGrep
Last synced: about 1 month ago
JSON representation
A blazing fast, tiny, customisable grep
- Host: GitHub
- URL: https://github.com/theproductiveprogrammer/QuickGrep
- Owner: theproductiveprogrammer
- Created: 2021-04-16T02:45:10.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-04T01:42:57.000Z (10 months ago)
- Last Synced: 2024-08-02T05:11:38.350Z (4 months ago)
- Language: C
- Size: 136 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-blazingly-fast - QuickGrep - A blazing fast, tiny, customisable grep (C)
README
---
pdf_options:
format: a4
margin: 30mm 20mm
printBackground: true
headerTemplate: |-
.hdr, .ftr {
width: calc(100% - 30mm);
margin: 0 auto;
text-align: right;
font-family: system-ui;
font-size: 8px;
padding: 4px;
}
.hdr {
border-bottom: 1px solid #ededed;
}
.ftr {
border-top: 1px solid #ededed;
}
Quick Grep
[v1.5.0]
footerTemplate: |-
Page
of
---# Quick Grep
**TL;DR** : A tiny (<500 loc) C file that does a fast grep with great defaults for programming.
ππ¨β¨
## Usage
Compile the C file, name the output `gg` (for quick typing) and put it somewhere in your path. It will do a recursive, case insensitive search by default and put in line numbers so the output plays well with many editors like [vim](https://vimhelp.org/quickfix.txt.html).
```sh
$> grep -inR "int i" .
vs
$> gg int i
```## Vim Usage
Add something like this to your `.vimrc`:
```vim
command! -nargs=+ Find cexpr system('gg ' . shellescape(''))
```And you can now use:
```vim
:Find int i
```to quickly find relevant results from your current directory downward.
## Smart Case
`gg` by default will perform a case-insensitive search but if you provide what looks like capital letters then it will perform a case-sensitive search. This is inspired by the `smartcase` option of vim and works really well.
```sh
$> gg test # matches test, TEST, tEsT...
$> gg Test # matches only Test
```## Run Directory
`gg` searches in current directory but you can pass `-c ../some/other/path` to run the search in another directory.
```sh
$> gg test # searches in current directory and sub-directories
$> gg -c ../some/path test # searches in ../some/path and sub-directories
```## Invert Results
It's also useful to search for lines that do *not* match a certain condition.
```sh
$> gg test # matches test, TEST, tEst... etc
$> gg -v test # returns lines that do NOT match test, TEST, tEst... etc
```## Performance
`gg` ignores directories like `.git`, or `node_modules`, or `target`, large files, and binary files, and this gives us quite a boost in many cases:
```sh
$> time grep -inR "int i" . > /dev/null
real 0m32.282s
user 0m15.777s
sys 0m1.600s$> time gg int i > /dev/null
real 0m1.415s
user 0m0.603s
sys 0m0.139s
```Of course these are benchmarks on my machine for my specific use case so take them with a large grain of salt. Still, itβs pretty fast for a tiny C script.
## Customisation
`gg` gives you zero customisation options. However, because itβs a tiny, simple C file, you can probably make it do whatever you like!
---
Enjoy!