Giter VIP home page Giter VIP logo

search's Introduction

Search

This program is a simplified, easier-to-use implementation of the idea of find ... -print0 | xargs -0 grep .... I write that kind of command line so often, and find and xargs are so awkward, and shell glob syntax is so annoyingly different from regular expressions, that it was easier to write and use this.

This Go implementation replaces an older C++ implementation I used to have up on GitHub. Go is obviously easier and more fun to extend than C++, has modern regular expressions, and other such niceness.

You might also enjoy other fine command-line search programs, such as ripgrep, git grep ..., and other such delights. My search is nowhere near as fancy, fast, or feature-riffic as most of those. But it does exactly what I wanted, and is small and simple. So, you know.

Usage

Just run search -h to get the latest command-line help. Here is an example of how I frequently use search:

cd ~/src/some-project
search -n '\.(cc|h)$' -c FrobulateGrommets

This prints all uses of the word FrobulateGrommets in code files in my C++ project. (It’s important to know precisely how and where the grommets are being frobulated.)

search -n '!out/' -n '\.(cc|h)$' -c FrobulateGrommets

This is just like the above, except it excludes files with names that match my project’s output directory, out/. The output directory typically contains binaries and generated code, so search results would often just be extra noise. You can also use the leading ! with the -c option.

Building And Installing

You’ll need to install the Go programming language. If your computer has make, you can just run make to build:

git clone https://github.com/noncombatant/search.git
cd search
make

If not, you can run the steps in the Makefile manually:

git clone https://github.com/noncombatant/search.git
cd search
go build
go vet
go test

To install, just copy the search binary to somewhere in your $PATH. I like to use $HOME/bin for these toys. I always have $HOME/bin in my $PATH, so this works for me:

mkdir -p ~/bin
cp search ~/bin

I have only tried this program on Ubuntu and macOS. In theory it should work on Windows, too. Let me know what happens if you try! I’d take any PRs you’ve got to ensure it works on Windows. (And any other feature requests?)

search's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.