DEV Community

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

Posted on โ€ข Edited on

2 1

[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.๐Ÿ™

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

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

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools canโ€™t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay