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.

D1588981e0248aaa0174906c99df180e?s=128

Andy Lester

June 14, 2012
Tweet

Transcript

  1. ack to the future Andy Lester & Rob Hoelz YAPC::NA

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

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

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

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

  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
  7. Ignores junk • .git, .svn, .hg, etc • coredumps •

    binary files • blib, _build, nytprof • *~ backups Thursday, June 14, 12
  8. Perl regexes • True Perl regexes, not PCRE. • Use

    $1, $&, etc ‣ ack '#include\s*"(.+)"' --output='$1' Thursday, June 14, 12
  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
  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
  11. Pretty output Thursday, June 14, 12

  12. --passthru Thursday, June 14, 12

  13. Optimized for laziness • Typing grep switches is slow •

    DIY aliases + shell configs are not portable Thursday, June 14, 12
  14. "It turns out that Defaults Matter. Who knew?" http://news.ycombinator.com/item?id=830731 Thursday,

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

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

  17. Thursday, June 14, 12

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

  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
  20. Per-project ackrc Thursday, June 14, 12

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

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

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

  24. Plugins! Thursday, June 14, 12

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

    12
  26. Searching in tarballs Thursday, June 14, 12

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

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

  29. Search for text in a PDF, or Word doc, or...

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

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

  32. Join us for the future! • http://betterthangrep.com/ • ack-users on

    Google Groups Thursday, June 14, 12