A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings.
Go
Permalink
Failed to load latest commit information.
Godeps Update dependent packages. Dec 23, 2016
cmd/pt Specify GOMAXPROCS. Dec 5, 2015
files Changed permission to 644. Dec 7, 2015
lib/pt Implemented search function for C. (This is a beta feature yet.) Dec 23, 2016
.gitignore Implemented search function for C. (This is a beta feature yet.) Dec 23, 2016
.travis.yml Supported go 1.7.4 Dec 23, 2016
LICENSE Added a LICENSE. Jan 12, 2014
README.md Update README.md Sep 17, 2016
decoder.go Encode and decode is now closed in grep. Nov 28, 2015
decorator.go Invalid ANSI codes are now removed. Jan 24, 2016
encoder.go Refactor grep implementation. Nov 28, 2015
encoding.go Refactor. Nov 8, 2015
encoding_test.go Added encoding test. Dec 3, 2015
extended_grep.go Simplify further to a single defer statement May 28, 2016
file_handler.go Implemented search from stdin. Dec 19, 2015
file_info.go Detect direcotry collectry when follow option is enable. Nov 29, 2015
find.go Allow '..' as an argument to 'pt' Feb 1, 2016
find_test.go fix tests on windows Oct 17, 2016
fixed_grep.go Simplify further to a single defer statement May 28, 2016
formatter.go Changed no-line-number option name to [no]numbers Aug 27, 2016
formatter_test.go Implemented search from stdin. Dec 19, 2015
grep.go Simplify grepper interface May 4, 2016
grep_test.go Implemented search from stdin. Dec 19, 2015
ignore.go Specify base for avoid unnecessary filepath.Dir in gitignore package. Dec 7, 2015
line_grep.go Fix not display issue of before option Dec 22, 2016
line_grep_test.go Add regression test of #166 Dec 22, 2016
match.go Implemented column option. Nov 29, 2015
match_state.go Implemented after option. Nov 28, 2015
option.go Changed no-line-number option name to [no]numbers Aug 27, 2016
passthrough_grep.go Simplify grepper interface May 4, 2016
pattern.go Implemented ignore case and smart case options. Nov 29, 2015
platinum_searcher.go Bumped version to 2.1.5. Dec 23, 2016
print.go Refactor grep implementation. Nov 28, 2015
search.go Implemented g option. Dec 19, 2015
walk.go Fix --follow option issue Jan 11, 2016
wercker.yml Excluded lib/pt/main when goxc in wercker CI. Dec 23, 2016

README.md

The Platinum Searcher Build Status wercker status

A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings.

Features

  • It searches code about 3–5× faster than ack.
  • It searches code as fast as the_silver_searcher(ag).
  • It ignores file patterns from your .gitignore.
  • It searches UTF-8, EUC-JP and Shift_JIS files.
  • It provides binaries for multi platform (macOS, Windows, Linux).

Benchmarks

cd ~/src/github.com/torvalds/linux
ack EXPORT_SYMBOL_GPL 30.18s user 2.32s system  99% cpu 32.613 total # ack
ag  EXPORT_SYMBOL_GPL  1.57s user 1.76s system 311% cpu  1.069 total # ag: It's faster than ack.
pt  EXPORT_SYMBOL_GPL  2.29s user 1.26s system 358% cpu  0.991 total # pt: It's faster than ag!!

Usage

$ # Recursively searches for PATTERN in current directory.
$ pt PATTERN

$ # You can specify PATH and some OPTIONS.
$ pt OPTIONS PATTERN PATH

Configuration

If you put configuration file on the following directories, pt use option in the file.

  • $XDG_CONFIG_HOME/pt/config.toml
  • $HOME/.ptconfig.toml
  • .ptconfig.toml (current directory)

The file is TOML format like the following.

color = true
context = 3
ignore = ["dir1", "dir2"]
color-path = "1;34"

The options are same as command line options.

Editor Integration

Vim + Unite.vim

You can use pt with Unite.vim.

nnoremap <silent> ,g :<C-u>Unite grep:. -buffer-name=search-buffer<CR>
if executable('pt')
  let g:unite_source_grep_command = 'pt'
  let g:unite_source_grep_default_opts = '--nogroup --nocolor'
  let g:unite_source_grep_recursive_opt = ''
  let g:unite_source_grep_encoding = 'utf-8'
endif

Emacs + pt.el

You can use pt with pt.el, which can be installed from MELPA.

Installation

Developer

$ go get -u github.com/monochromegane/the_platinum_searcher/...

User

Download from the following url.

Or, you can use Homebrew (Only macOS).

$ brew install pt

pt is an alias for the_platinum_searcher in Homebrew.

Contribution

  1. Fork it
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request

License

MIT

Author

monochromegane