Coder Social home page Coder Social logo

the_platinum_searcher's Introduction

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 ignores directories with names that start with ., eg .config. Use --hidden option, if you want to search.
  • 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

the_platinum_searcher's People

Contributors

aeruder avatar bling avatar colinrymer avatar dchapes avatar dplarson avatar drewwells avatar drmohundro avatar gabrielmiller avatar hnakamur avatar homburg avatar ichizok avatar ikaros avatar kevinji avatar kjk avatar kkolman avatar monochromegane avatar oov avatar pongad avatar shantanugoel avatar shiena avatar stefanschroeder avatar syohex avatar t-suwa avatar thomasf avatar tnmt avatar tw4452852 avatar vbauerster avatar vially avatar yinghau76 avatar yosssi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the_platinum_searcher's Issues

pt crashes on doing simple search

Hi there,

Have started using pt recently. Pt is crashing constantly when trying to search over a directory.

I am getting this error.
runtime/cgo: pthread_create failed: Resource temporarily unavailable
SIGABRT: abort
PC=0xf77afa30 m=2
...

The full log is with me however I am getting "Attaching documents requires write permission to this repository. Choose Files Try again with a PNG, GIF, or JPG." when I try to attach the log with this issue.

Doesn't hit dot files

# Doesn't hit dot files  
  
## same text in file  
htaccess  
.htaccess  
-----  
AuthGroupFile "/dev/null"  
-----  
  
## execute  
pt --nogroup --nocolor --ignore-case --smart-case --depth 99 -e "AuthGroupFile" .  
-----  
htaccess:1:AuthGroupFile "/dev/null"  
-----  
Doesn't hit .htaccess  
I hope .htaccess hit default or option please!  
  
pt --version  
1.7.6  

オプションのパスの末尾に\をつけるとruntime panicでおちる

@d_ymkw says the following on Twitter.

@monochromegane はじめまして。Windows環境(x64)下で、
pt利用させて頂いています。ところで、実用上問題はないのですが、
オプションのパスの末尾に\をつけると、runtime panicで落ちます。
ご確認頂ければと思います。

Do not hang on FIFOs

pt hangs on FIFOs. Steps to reproduce:

$ mkdir pt-hangs
$ cd pt-hangs 
$ mkfifo fifo 
$ echo "test" > test.txt
$ pt test
test.txt:
1:test

Version 1.7.7.

cmd/pt cannot be built with Go 1.5

$ go get -u github.com/monochromegane/the_platinum_searcher/cmd/pt
package github.com/monochromegane/the_platinum_searcher/cmd/pt
    imports github.com/jessevdk/go-flags
    imports github.com/monochromegane/terminal
    imports github.com/monochromegane/the_platinum_searcher
    imports github.com/shiena/ansicolor
    imports golang.org/x/text/encoding
    imports golang.org/x/text/transform
    imports golang.org/x/text/encoding/internal
    imports golang.org/x/text/encoding/internal
    imports golang.org/x/text/encoding/internal: use of internal package not allowed
package github.com/monochromegane/the_platinum_searcher/cmd/pt
    imports github.com/jessevdk/go-flags
    imports github.com/monochromegane/terminal
    imports github.com/monochromegane/the_platinum_searcher
    imports github.com/shiena/ansicolor
    imports golang.org/x/text/encoding
    imports golang.org/x/text/transform
    imports golang.org/x/text/encoding/internal
    imports golang.org/x/text/encoding/internal/identifier
    imports golang.org/x/text/encoding/internal/identifier
    imports golang.org/x/text/encoding/internal/identifier: use of internal package not allowed

`pt -g PATTERN PATH` doesn't work

Pt:

$ pt -g hoge
bar\hoge
foo\hoge
$ pt -g hoge bar
bar\hoge
foo\hoge

Ag:

$ ag -g hoge
bar\hoge
foo\hoge
$ ag -g hoge bar
bar\hoge

Workaround:

$ pt -g hoge "" bar
bar\hoge

Global default gitignores are not respected

Git supports global gitignore files in two default locations: ~/.gitignore and $XDG_CONFIG_HOME/.git/config, and will look there even if core.excludesfile is unset (or even if it is).

Mac OS X(x86 64bit) で fatal error

便利に利用させてもらってます。
久しぶりにバイナリをダウンロードして使ってみたところ fatal error が起きるようになりました。

バイナリは
https://drone.io/github.com/monochromegane/the_platinum_searcher/files/artifacts/bin/darwin_amd64/pt

環境:
OS X 10.9.2

再現法:
https://github.com/SonyWWS/ATF
をクローンしたディレクトリで
pt public
を実行

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
github.com/monochromegane/the_platinum_searcher/search.(*Searcher).Search(0x210378c30, 0x210378c30, 0x2aa220)
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/search.go:27 +0x160
main.main()
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/main.go:94 +0x60a

goroutine 4 [chan receive]:
github.com/monochromegane/the_platinum_searcher/search/grep.(*Grepper).ConcurrentGrep(0x210364480)
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/grep/grep.go:33 +0x97
github.com/monochromegane/the_platinum_searcher/search.(*Searcher).grep(0x210378c30, 0x2103a8100, 0x2103a8180)
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/search.go:51 +0x6a
created by github.com/monochromegane/the_platinum_searcher/search.(*Searcher).Search
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/search.go:25 +0x11c

goroutine 5 [chan receive]:
github.com/monochromegane/the_platinum_searcher/search/print.(*Printer).Print(0x210378c90)
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/print/print.go:43 +0x60
github.com/monochromegane/the_platinum_searcher/search.(*Searcher).print(0x210378c30, 0x2103a8180, 0x2103a4060)
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/search.go:56 +0x4d
created by github.com/monochromegane/the_platinum_searcher/search.(*Searcher).Search
    /home/ubuntu/src/github.com/monochromegane/the_platinum_searcher/search/search.go:26 +0x147

Implement a verbose --version with the name of the application

Since pt can shadow the pt command line tool of TCL parser tools we need a way to identify the platinum searcher. The current --version only prints the version without the name of the application and the help screen does not include the name of the application (with homebrew version at least).

I propose to either put the application name in the help or simply put the application name in the --version output.

[Request] Add a way to filter files by its size. ファイルサイズによるフィルタリング機能

はじめまして、便利に利用させていただいています。有末と申します。

個人的な機能要望で恐縮なのですが、ファイルサイズによるフィルタリングに対応していただけると非常に助かります。これというのも仕事の関係上数十GBに至るファイル(バイナリの場合もASCIIの場合もあります)が混在したディレクトリから検索を行うことが多いのですが、そのようなファイルの内容を検索しに行くと非常に時間がかかってしまうためです。
--ignore などのオプションで全てを指定しても構わないのですが、種類が多いため「あるサイズ以上のファイルを検索しない」というオプションの指定が可能だととても便利です。

お時間があるときで構いませんのでご一考いただけたら幸いです。

pt -g filename_pattern PATH doesn't behave the way ag does

As far as I can tell, pt treats -g and -G the same, whereas ag does not. With ag, if you use -g, the following argument is the file pattern, and the second argument is the path to search. There's no need to specify a pattern argument, as if you want to filter by filename and contents, that's what -G is for, as far as I can tell. I use ag -g filename_pattern path all day long as a quick filtered find, for cases where I don't want to filter by file contents, but only want a quick filename-based search that obeys ag/pt's ignores for performance. Yes, I can use ffind for that too, but it's not quite as fast (at least from what little testing I've done so far, which is admittedly not much), and requires that one specify the path to search with its -d argument.

How to do escape in regex PATTERN?

I would like to search for sort function call case insensitively in my code.
This does not work:

$ pt -i sort\(
error parsing regexp: missing closing ): `(?i)(sort()`

pt sort\( works correctly for small letter case, but I would like to search case insensitively.
-i causes pt to use regex.

$ pt --version
1.7.4

Related to #62.

.ackrc

Ack uses a file called .ackrc for defining default settings for a project or a user.
It supports (almost) all command line switches.

Did I miss something or is this a feature not implemented in pt yet?

regexp searches not working

If I try git grep 'Seconda*', ack 'Seconda*', or ag 'Seconda*', I get identical results (modulo time). If I try pt 'Seconda*', I get no output. If I remove the * from the pt invocation, then I get reasonable output. Basically, unless the pattern passed to pt is a string literal, I get no output. I tried several patterns listed at https://code.google.com/p/re2/wiki/Syntax

pt 1.7.1 installed by Homebrew.

brew install broken on El Capitan OS X 10.11

I was able to install just fine from source go get -f -u github.com/monochromegane/the_platinum_searcher/..., but the latest brew install is throwing errors.

go build -o /usr/local/Cellar/the_platinum_searcher/1.7.7/bin/pt cmd/pt/main.go
clang: warning: no such sysroot directory: ''
src/github.com/monochromegane/terminal/terminal_darwin_cgo.go:6:10: fatal error: 'unistd.h' file not found
#include <unistd.h>
         ^
1 error generated.
couldn't understand kern.osversion `15.0.0'

Error codes on positive/negative search results

Currently pt returns 0 for both a positive search result (i.e. 1 or more matches were found) and for a negative search result (i.e. no matches were found). grep on the other hand, returns 0 for a positive result and 1 for a negative result, which is more of the standard/expected behavior for UNIX command-line programs.

With that said, I would like to propose that pt switches to returning 0 for a positive search result and 1 for a negative result.

NOTE: the_silver_searcher currently has the same behavior as the_platinum_searcher (i.e. returns 0 for both positive and negative search results). Perhaps there is a reason for this behavior that I'm not aware of…

Sort result

Is there anyway to sort pt's result by the most recent date of the file?

That would be very helpful!

Thanks!

windows環境下で、Pathを指定せずに検索すると、何も 検索されてない

@d_ymkw says the following on Twitter.

@monochromegane こんばんわ。たびたびすみません。
pt、windows環境下で、Pathを指定せずに検索すると、何も
検索されてないように思えるのですがご確認頂けますか?
(デフォルトでは、カレントディレクトリ下のディレクトリをすべ
て見てくれると思ったのですが)

regexp not working on windows

I'm trying to do a regexp search "a|b" (say foo|bar)

This is a simple failed test:

C:\some\dir> pt --version
1.7.7
C:\some\dir> echo a > test
C:\some\dir> echo b >> test
C:\some\dir> echo a^|b >> test
C:\some\dir> echo a\^|b >> test
C:\some\dir> cat test
a
b
a|b
a\|b
C:\some\dir> pt "a|b" test
test:
3:a|b
C:\some\dir> pt a^|b test
test:
3:a|b
C:\some\dir> pt "a\|b" test
test:
4:a\|b
C:\some\dir> pt a\^|b test
test:
4:a\|b

As expected:

C:\some\dir> pt a test
test:
1:a
3:a|b
4:a\|b

works

Speed problems

Hey,
not an issue, was just curious to try out pt and this strikes me as odd, what could the reason be. Both were run repeatedly to avoid caching issues, nothing changed a lot.

pt was built with go get && go (go version go1.1.2 linux/amd64) this morning

$ git clone https://github.com/php/php-src.git
$ time ag -i time_t php-src | wc -l
391
ag -i time_t php-src 0.44s user 0.24s system 155% cpu 0.437 total
wc -l 0.00s user 0.00s system 0% cpu 0.436 total
$ time pt -i time_t php-src | wc -l
391
pt -i time_t php-src 24.84s user 0.28s system 344% cpu 7.284 total
wc -l 0.00s user 0.00s system 0% cpu 7.284 total

$ pt --version
1.5.2
$ ag --version
ag version 0.15pre

color disappears when piping

Searching for word 'title' in my source code.

pt --color title | less
or
pt --color --file-search-regexp='.go$' | less

The color does not appear. Color appears when not piped. It isn't less, it's the pipe. Color is also gone in the case of:
pt --color title | cat

--
Description: Ubuntu 14.04 LTS
Codename: trusty
Linux sda8 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:00:20 UTC 2014 x86_64 GNU/Linux
jessie/sid

$ pt --version
1.6.2

ctrl-c during printout causes panic

I really like this idea (ag/ack in go)! Great job!

Here's a low-priority issue I found: pressing ctrl-c while the results are printing causes a panic. go 1.2, Mac 10.8.

Partial stacktrace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x40 pc=0x40966a4]

goroutine 8 [running]:
runtime.panic(0x40dffc0, 0x423ae59)
    /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/monochromegane/the_platinum_searcher/search/file.IdentifyType(0xc2100ef800, 0x30, 0x0, 0x0)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/file/file.go:28 +0xb4
github.com/monochromegane/the_platinum_searcher/search/find.func·001(0xc2100ef800, 0x30, 0x4411178, 0xc2149be1e0, 0x4, ...)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/find/find.go:51 +0x7f1
github.com/monochromegane/the_platinum_searcher/search/find.walk(0xc2100ef800, 0x30, 0x4411178, 0xc2149be1e0, 0x4, ...)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/find/find.go:78 +0x9c
github.com/monochromegane/the_platinum_searcher/search/find.walk(0xc210066be0, 0x1c, 0x4411178, 0xc2100931e0, 0x4, ...)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/find/find.go:103 +0x66b
github.com/monochromegane/the_platinum_searcher/search/find.walk(0xc210066240, 0x12, 0x4411178, 0xc2100680a0, 0x3, ...)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/find/find.go:103 +0x66b
github.com/monochromegane/the_platinum_searcher/search/find.walkOnGoRoutine(0xc210066240, 0x12, 0x4411178, 0xc2100680a0, 0xc21006f000, ...)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/find/find.go:73 +0x87
created by github.com/monochromegane/the_platinum_searcher/search/find.walk
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/find/find.go:100 +0x489

goroutine 1 [chan receive]:
github.com/monochromegane/the_platinum_searcher/search.(*Searcher).Search(0xc21001e5d0)
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/search/search.go:22 +0x119
main.main()
    /Users/justin/dev/go/src/github.com/monochromegane/the_platinum_searcher/main.go:54 +0x347

goroutine 3 [syscall]:
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1394

--column option

I'd like you to add --column option like that ag has.

$ ag --nogroup --column split
autoload/ag.vim:22:7:  "if split(system("ag --version"), "[ \n\r\...
$ pt --nogroup split
autoload/ag.vim:22:  "if split(system("ag --version"), "[ \n\r\...

Enhancement Request: Support for -A, -B and -C options

Hi, could you please provide the -A, -B and -C options similar to what grep has?

Also, does this follow symlinks by default? Is there a way to make it follow (or not follow) symlinks explicitly?

Thanks for the great tool 👍

Windows 上での PATH 区切り文字の表示

結果出力時に、ファイル名の PATH を Windows のお作法にのっとって \ で表示されていると
辛い場面があるので、/ で置き換えて出力してくれるオプションを追加して頂けないでしょうか。

`--word-regexp` does not work as expected

Given that pt relies on Go's regular expressions for word-ness, --word-regexp cannot work as expected. Maybe it is helpful to add this to the documentation. (Fixing it requires replacing \b.)

According to https://golang.org/pkg/regexp/syntax/ you get matches for

\b             at ASCII word boundary (\w on one side and \W, \A, or \z on the other)

– i.e., it also matches before any in-word non-ASCII character. Try

pt -w über

, and you will get in-word matches such as darüber, but no occurrence of über as a word.

This Stack Overflow question discusses how to circumvent \b in Java and discusses workarounds for \b, some of which should also work in Go.

emacs integration, pt.el

thanks for this awesome app, which makes searching on a windows box way easier/faster than the other alternatives.

i was in the middle of releasing my package to the public and noticed that it wouldn't work with the latest build of pt.

i tracked it down to the commit which broke my plugin.

for whatever reason, if i just type something like pt foo in a shell with emacs, it never finishes. if i provide a directory, like pt foo ., it works, despite that parameter being optional.

the directory can be omitted correctly outside of emacs, and it continues to work in vim/unite.

Regular Expression system is obscure

The regular expression system is obscure to all but Go programmers. Some reference to the RE2 package would certainly help. Even a pointer to the documentation for allowable regular expressions.

Add -g support

ag has an unpopular but important flag -g that allows one to just search filenames, ignoring the file contents entirely.

This is useful for giving massive speed improvements to other tools (like the plugin for vim ctrlp). As well as the nice expected matching behavior you would expect from ag/pt.

let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'

Colour not being shown in Windows command prompt

Instead of seeing colours, I'm seeing the escape sequence ←[1;33m10768←[0m←. I also get the same in another command prompt I use (ConEmu).

If it helps, ack shows colours correctly but ag doesn't!

Multiple cores one one file?

I've just tried pt on a 35GB text file. I'm a bit disappointed that it only uses 1 core even when I set GOMAXPROCS=32.

Any ideas? Is this supposed to be supported?

Flag To Omit All Ignores

Sometimes I do need to search files that are in .gitignore or similar. It looks like one could set --vcs-ignore= (and the relevant global ignores), but for speed and efficacy, it’d be nice to have a single short flag to omit all VCS ignore files, at least—I suppose the global pt ignore could still require its own flag (or why would you have that file?)

Utility panics if searching too many files

This utility panics if searching through too many files.

panic: open foo/bar/file.txt: too many open files

I was running pt "foo" * on a directory containing about 30,890 files (according to find . -type f|wc -l). ack, however, can handle this workload fine.

I'm running OS X 10.10.5 with pt version 1.7.8.

Cannot specify multiple ignores in ptconfig.toml

It looks like it's impossible to specify multiple ignores in the global configuration, ~/.ptconfig.toml

A single value works:

  ignore = "node_modules"

  % pt
  ...
  --ignore=             Ignore files/directories matching pattern (default: [node_modules])

This ignores the ignores completely:

  ignore = "third_party"
  ignore = "node_modules"

  % pt
  ...
  --ignore=             Ignore files/directories matching pattern

And this ignores the ignores completely in a different way, notice the double-list:

  ignore = ["third_party", "node_modules"]

  % pt
  ...
  --ignore=             Ignore files/directories matching pattern (default: [[third-party node_modules]])

(v1.7.9 under archlinux, built from aur)

Add --column argument.

I'm not sure how much hassle it would be to add an --column argument to not only print matching line number but also matching column while not affecting performance too much. Since it would be optional I guess that the eventual negative performance would only apply to when this argument is in use.

I'm writing this because wanting to have pt working well with a emacs package called ag.el.
Wilfred/ag.el#46

Count option?

Hello,

Ack supports a count option very simply:

 % ack -c foo
pt_20150801.csv:6732
foo.csv:6732

Will you consider supporting a count option?

grepの--includeやagの-Gオプション相当のもの

本日から使い始めています。文字コード混在下での作業が多いのですごく便利です。
最高ですね ^^
grepの--includeやagの-Gオプション相当のものが実装されると、更に便利に使えると思います。
拡張子で絞ったりする需要は結構あるかと。
でもパフォーマンスが落ちちゃいますかね…

大文字小文字を無視した検索の対応

Agで言うところの、
--ignore-case (大文字小文字を無視)
--smart-case (大文字の指定があれば、大文字小文字の違いを有効)
の対応を希望します。
よろしくお願いします。

.gitignore Globstar Not Respected

"It ignores file patterns from your .gitignore" feature from the Readme is incomplete.

If I have the files

  • components/something/vendor-a/tags
  • components/vendor-b/tags

and in my .gitignore i have components/**/tag. Those files are not ignored, as expected. Git does ignore them.

I had to replace the globstar option in my .gitignore with components/*/tags and components/*/*/tags which is less ideal.

On Globstar, heres the Gnu manual info with quote:

If set, the pattern '**' used in a filename expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a '/', only directories and subdirectories match.

Search only in files specified in PATH argument

The Platinum Searcher ignores PATH argument if it specifies file names. Specifically, this breaks behavior of Unite grep:$buffers command that is supposed to search only in open vim buffers.

I'm using the latest 1.7.5 version:

$ \pt --version
1.7.5

Let's say we have three files:

$ tail -n +1 *.py
==> first.py <==
orange
apple
mellow

==> second.py <==
banana
apple
pie

==> third.py <==
yes I have apple here

Here is what pt returns when I search like this:

$ \pt 'apple' first.py second.py
first.py:
2:apple

second.py:
2:apple

third.py:
1:yes I have apple here

All other search tools respect arguments and skip third.py:

$ \ag 'apple' first.py second.py
first.py
2:apple

second.py
2:apple

$ \ack-grep 'apple' first.py second.py
first.py
2:apple

second.py
2:apple

$ \grep 'apple' first.py second.py    
first.py:apple
second.py:apple

Download file naming should consistent with architecture name

for some (to me) unknown reason the amd64 version is called linun_amd64 instead of linux_amd64 and the i386 version is named linux_386 instead of linux_i386..

Both of these things prohibits downloading like this:

curl https://drone.io/github.com/monochromegane/the_platinum_searcher/files/artifacts/bin/linux_$(dpkg --print-architecture)/pt -o ~/.bin/pt

Potential to go faster

Currently pt does a readline for every line and then finds the matches. It is impressive how it is able to be close to ag in speed with this but I think there is potential to go much faster by "mmap"ing the file and then doing a Regexp.FindAllStrings or something.
Please check it out.
I'll also try to work on this next.

Ignoring directories does not work

Example with the platinum searcher source code:

~/src/the_platinum_searcher/files/vcs$ cat .gitignore
/ignore
~/src/the_platinum_searcher/files/vcs$ pt go
absolute/ignore.txt:
1:go test

ignore/ignore.txt:
1:go test

match/ignore.txt:
1:go test

match/match.txt:
1:go test

~/src/the_platinum_searcher/files/vcs$ ag go
match/ignore.txt
1:go test

match/match.txt
1:go test

absolute/ignore.txt
1:go test

The file ignore/ignore.txt should be ignored (which ag does properly), but shows up in the search results.

Doesn't work in cygwin

I've tried the latest windows binaries (both x86 and x86-64) and both of them just hang when used in cygwin. On my other computer I had an older version of pt which did work perfectly under cygwin.

Please fix this, as this is the only ack-like program that works under windows without the need of a scripting language. I need it for vim under cygwin.

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.