DEV Community

Cover image for [Chad Tip] Find a string fast in your project (with grep/ no IDE)
Areskul
Areskul

Posted on • Edited on

[Chad Tip] Find a string fast in your project (with grep/ no IDE)

Most extreme scenario

Doomer(Sitting at his desk):

I know I've already wrote a function like this. But can't remember in which file!!

I will have to open each potential file and seek for the line.
If this becomes recurrent, at this rate, I will hit the deadline soon.
I am an incompetent.
I bet my girlfriend is cheating on me.
This distro sucks.
I need to smoke a cigarette.

Chad(Coming from the sky):

I was just like you before! Let me help you!

Usage

ou <insert your text>
Enter fullscreen mode Exit fullscreen mode

Example

You need to find where you used a function but your IDE stinks.

Type this in your terminal.

ou aggregate
Enter fullscreen mode Exit fullscreen mode

It will find all occurrence of "aggregate"

Image description

"ou" means where in french but can be whatever alias you want

Reasons

A fuzzy finder is the search bar that browse through file name or file content when usually pressing (Ctrl-P, Ctrl-F...) in your IDE.

Why not using vscode finder?
I only have a AMD4700 CPU with 12 threads so it won't retrieve the code until the next day!

Why not using VIM finder?
I don't want to supercharge nvim/spacevim finder to browse through text.

Install

Beware !
You can only use it if you master the CLI.
For power users and very advanced linux users only.
I use arch btw.

It's nothing more than a "grep" with multiple arguments.

Just put this in your .bashrc , .zshrc or wherever you may source your aliases.

# .zshrc
alias ou="grep -rn --exclude=\*.{png,jpg,lock,log} --exclude-dir={.git,node_modules,dist,build}"
Enter fullscreen mode Exit fullscreen mode

grep options:
r -> recursive
n -> print line number

If you've been through all these steps you may be kind of a genius yourself.

Congrats.
Never loose hope.
Everyone has a chad in themselves.πŸ™

Top comments (2)

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

I find SublimeText's searching to be blisteringly fast

Collapse
 
areskul profile image
Areskul

I used it a long time ago ! Maybe i should give it a try