Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ack to the future!

Ack to the future!

Why you should use ack, and what's coming in ack 2.0 and beyond.

Andy Lester

June 14, 2012
Tweet

More Decks by Andy Lester

Other Decks in Programming

Transcript

  1. ack to the future
    Andy Lester & Rob Hoelz
    YAPC::NA 2012, June 14, Madison, WI
    Thursday, June 14, 12

    View full-size slide

  2. Searching large trees of
    source code
    Thursday, June 14, 12

    View full-size slide

  3. In the beginning...
    there was find+grep
    Thursday, June 14, 12

    View full-size slide

  4. Search only Perl files
    Thursday, June 14, 12

    View full-size slide

  5. So I created ack
    Thursday, June 14, 12

    View full-size slide

  6. Recognizes filetypes
    • --perl matches *.pm, *.pl, *.t
    • and scripts without extensions that begin
    with a #!...perl shebang line
    • Same with Python, PHP, Ruby, etc
    Thursday, June 14, 12

    View full-size slide

  7. Ignores junk
    • .git, .svn, .hg, etc
    • coredumps
    • binary files
    • blib, _build, nytprof
    • *~ backups
    Thursday, June 14, 12

    View full-size slide

  8. Perl regexes
    • True Perl regexes, not PCRE.
    • Use $1, $&, etc
    ‣ ack '#include\s*"(.+)"' --output='$1'
    Thursday, June 14, 12

    View full-size slide

  9. Portable, Windows
    • Works back to Perl 5.8.8
    • Only one dependency, File::Next
    • Works on Windows when you have no
    other Unixy tools
    Thursday, June 14, 12

    View full-size slide

  10. Easy install
    • Install as App::Ack from CPAN
    • -or-
    • Install a package (might be "ack-grep" for
    your distro)
    • -or-
    • DL single file from betterthangrep.com
    Thursday, June 14, 12

    View full-size slide

  11. Pretty output
    Thursday, June 14, 12

    View full-size slide

  12. --passthru
    Thursday, June 14, 12

    View full-size slide

  13. Optimized for laziness
    • Typing grep switches is slow
    • DIY aliases + shell configs are not portable
    Thursday, June 14, 12

    View full-size slide

  14. "It turns out that Defaults Matter.
    Who knew?"
    http://news.ycombinator.com/item?id=830731
    Thursday, June 14, 12

    View full-size slide

  15. Popular!
    Useful!
    Many contributors!
    Thursday, June 14, 12

    View full-size slide

  16. And now....
    Thursday, June 14, 12

    View full-size slide

  17. Thursday, June 14, 12

    View full-size slide

  18. Less-surprising
    re: non-code searching
    Thursday, June 14, 12

    View full-size slide

  19. Flexible file/dir
    selectors
    • Making types is easier!
    • --type-add=make:match:/^[mr]akefile/i
    • --type-add=perl:firstlinematch:/perl/
    • Making exclusions is easier!
    • --ignore-file=Makefile.PL
    • --ignore-dir=cache/
    Thursday, June 14, 12

    View full-size slide

  20. Per-project ackrc
    Thursday, June 14, 12

    View full-size slide

  21. Going to alpha
    tonight!
    Thursday, June 14, 12

    View full-size slide

  22. Paving the way for 2.x
    Thursday, June 14, 12

    View full-size slide

  23. Ack becomes a
    search framework
    Thursday, June 14, 12

    View full-size slide

  24. Plugins!
    Thursday, June 14, 12

    View full-size slide

  25. What could we do
    with ack plugins?
    Thursday, June 14, 12

    View full-size slide

  26. Searching in tarballs
    Thursday, June 14, 12

    View full-size slide

  27. Search a git repo as of a
    given commit
    Thursday, June 14, 12

    View full-size slide

  28. Select only unstaged
    files to search
    Thursday, June 14, 12

    View full-size slide

  29. Search for text in a
    PDF, or Word doc, or...
    Thursday, June 14, 12

    View full-size slide

  30. Only select files newer
    than 10 days ago.
    Thursday, June 14, 12

    View full-size slide

  31. (Snazzy plugins
    not included!)
    Thursday, June 14, 12

    View full-size slide

  32. Join us for the future!
    • http://betterthangrep.com/
    • ack-users on Google Groups
    Thursday, June 14, 12

    View full-size slide