Giter Club home page Giter Club logo

quickfind's Introduction

QuickFind

Quickfind (or qf) is a UN*X tool, inspired by TextMate's Command-T plugin, for quickly finding files and directories under your working directory. I primarily use it as a part of a fast approximate cd command and as a powerful and simple alternative for the find . | grep <pattern> idiom.

Using QuickFind

To find something, just type:

$ qf [-dfa] pattern

By default qf ignores all hidden directories/files and only prints out paths of files and directories under current directory. You can make qf show hidden files and directories with the -a option. To show only files use the -f option, and for only directories use the -d option. The default behavior is the same as -df.

qf Uses a very simple pattern matching algorithm to find what you are looking for. You specify a pattern and then qf finds all directories whose pathname includes all the letters (case insensitive) in the pattern, in the given order. The letters need not be consecutive in the path, but more weight is given to paths where the letters of the pattern are next to each other.

For example, if I were to find the location of all ABBA albums in my iTunes library:

iTunes$ qf -d abba
./Music/ABBA
./Music/ABBA/Gold_ Greatest Hits
./Books/Edwin Abbott Abbott
./Music/Black Sabbath
./Music/Black Sabbath/Sabbath Bloody Sabbath
./Music/Nat Newborn/Back To The Moon
./Music/Carbonne - Di Piazza - Manring/Carbonne - Di Piazza - Manring
./Music/Iron Maiden/The Number of the Beast
./Music/Laura Branigan/The Best of Branigan
./Music/Manu Dibango/African Soul - The Very Best of Manu Dibango
./Music/The Cranberries/Everybody Else Is Doing It, So Why Can't We_

As you can see, all the results contain the letters "ABBA" in order, but the paths where the letters are consecutive were given first.

Or, maybe I'd like to see the tracks on the Black Sabbath's 'Sabbath Bloody Sabbath' album:

iTunes$ qf -f sabbblosabb.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/01 Sabbath Bloody Sabbath.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/02 A National Acrobat.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/03 Fluff.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/04 Sabbra Cadabra.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/05 Killing Yourself to Live.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/06 Who Are You_.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/07 Looking for Today.m4a
./Music/Black Sabbath/Sabbath Bloody Sabbath/08 Spiral Architect.m4a

To use qf as a part of an approximate cd command, I have in my .bashrc a simple shell function called acd that allows me to easily jump into any subdirectory just by writing a few path fragments:

acd() {
  if [ x$1 = x ]; then
    echo "Usage: acd <pattern>"
    return 1
  fi
  cd "$(qf -d $1 | sed 1q)"
}

Building and Installing QuickFind

make
make install

By default qf installs into /usr/bin, but you can easily change the location by giving a different prefix during installation:

PREFIX=~/ make install

Similarly, since the qf Makefile only uses implicit rules, you can control the C compiler and the compiler flags with environment variables. Maybe you'd like to compile qf with clang with full optimizations:

CC=clang CFLAGS=-O4 LDFLAGS=-O4 make

You get the idea.

Removing qf is as simple as a make uninstall. Just remember to give the same prefix that you used during installation since the Makefile doesn't remember it.

quickfind's People

Contributors

akojo avatar hsalokor avatar jvirtanen avatar

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.