Coder Social home page Coder Social logo

ggreer / the_silver_searcher Goto Github PK

View Code? Open in Web Editor NEW
25.7K 428.0 1.4K 2.37 MB

A code-searching tool similar to ack, but faster.

Home Page: http://geoff.greer.fm/ag/

License: Apache License 2.0

Shell 3.31% C 80.96% Perl 9.65% Python 0.21% Makefile 0.33% M4 5.53%
command-line-tool c silver-searcher pcre ag search-in-text

the_silver_searcher's Introduction

The Silver Searcher

A code searching tool similar to ack, with a focus on speed.

Build Status

Floobits Status

#ag on Freenode

Do you know C? Want to improve ag? I invite you to pair with me.

What's so great about Ag?

  • It is an order of magnitude faster than ack.
  • It ignores file patterns from your .gitignore and .hgignore.
  • If there are files in your source repo you don't want to search, just add their patterns to a .ignore file. (*cough* *.min.js *cough*)
  • The command name is 33% shorter than ack, and all keys are on the home row!

Ag is quite stable now. Most changes are new features, minor bug fixes, or performance improvements. It's much faster than Ack in my benchmarks:

ack test_blah ~/code/  104.66s user 4.82s system 99% cpu 1:50.03 total

ag test_blah ~/code/  4.67s user 4.58s system 286% cpu 3.227 total

Ack and Ag found the same results, but Ag was 34x faster (3.2 seconds vs 110 seconds). My ~/code directory is about 8GB. Thanks to git/hg/ignore, Ag only searched 700MB of that.

There are also graphs of performance across releases.

How is it so fast?

  • Ag uses Pthreads to take advantage of multiple CPU cores and search files in parallel.
  • Files are mmap()ed instead of read into a buffer.
  • Literal string searching uses Boyer-Moore strstr.
  • Regex searching uses PCRE's JIT compiler (if Ag is built with PCRE >=8.21).
  • Ag calls pcre_study() before executing the same regex on every file.
  • Instead of calling fnmatch() on every pattern in your ignore files, non-regex patterns are loaded into arrays and binary searched.

I've written several blog posts showing how I've improved performance. These include how I added pthreads, wrote my own scandir(), benchmarked every revision to find performance regressions, and profiled with gprof and Valgrind.

Installing

macOS

brew install the_silver_searcher

or

port install the_silver_searcher

Linux

  • Ubuntu >= 13.10 (Saucy) or Debian >= 8 (Jessie)

      apt-get install silversearcher-ag
    
  • Fedora 21 and lower

      yum install the_silver_searcher
    
  • Fedora 22+

      dnf install the_silver_searcher
    
  • RHEL7+

      yum install epel-release.noarch the_silver_searcher
    
  • Gentoo

      emerge -a sys-apps/the_silver_searcher
    
  • Arch

      pacman -S the_silver_searcher
    
  • Slackware

      sbopkg -i the_silver_searcher
    
  • openSUSE

      zypper install the_silver_searcher
    
  • CentOS

      yum install the_silver_searcher
    
  • NixOS/Nix/Nixpkgs

      nix-env -iA silver-searcher
    
  • SUSE Linux Enterprise: Follow these simple instructions.

BSD

  • FreeBSD

      pkg install the_silver_searcher
    
  • OpenBSD/NetBSD

      pkg_add the_silver_searcher
    

Windows

  • Win32/64

    Unofficial daily builds are available.

  • winget

      winget install "The Silver Searcher"
    

    Notes:

    • This installs a release of ag.exe optimized for Windows.
    • winget is intended to become the default package manager client for Windows.
      As of June 2020, it's still in beta, and can be installed using instructions there.
    • The setup script in the Ag's winget package installs ag.exe in the first directory that matches one of these criteria:
      1. Over a previous instance of ag.exe from the same origin found in the PATH
      2. In the directory defined in environment variable bindir_%PROCESSOR_ARCHITECTURE%
      3. In the directory defined in environment variable bindir
      4. In the directory defined in environment variable windir
  • Chocolatey

      choco install ag
    
  • MSYS2

      pacman -S mingw-w64-{i686,x86_64}-ag
    
  • Cygwin

    Run the relevant setup-*.exe, and select "the_silver_searcher" in the "Utils" category.

Building from source

Building master

  1. Install dependencies (Automake, pkg-config, PCRE, LZMA):

    • macOS:

        brew install automake pkg-config pcre xz
      

      or

        port install automake pkgconfig pcre xz
      
    • Ubuntu/Debian:

        apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
      
    • Fedora:

        yum -y install pkgconfig automake gcc zlib-devel pcre-devel xz-devel
      
    • CentOS:

        yum -y groupinstall "Development Tools"
        yum -y install pcre-devel xz-devel zlib-devel
      
    • openSUSE:

        zypper source-install --build-deps-only the_silver_searcher
      
    • Windows: It's complicated. See this wiki page.

  2. Run the build script (which just runs aclocal, automake, etc):

     ./build.sh
    

    On Windows (inside an msys/MinGW shell):

     make -f Makefile.w32
    
  3. Make install:

     sudo make install
    

Building a release tarball

GPG-signed releases are available here.

Building release tarballs requires the same dependencies, except for automake and pkg-config. Once you've installed the dependencies, just run:

./configure
make
make install

You may need to use sudo or run as root for the make install.

Editor Integration

Vim

You can use Ag with ack.vim by adding the following line to your .vimrc:

let g:ackprg = 'ag --nogroup --nocolor --column'

or:

let g:ackprg = 'ag --vimgrep'

Which has the same effect but will report every match on the line.

Emacs

You can use ag.el as an Emacs front-end to Ag. See also: helm-ag.

TextMate

TextMate users can use Ag with my fork of the popular AckMate plugin, which lets you use both Ack and Ag for searching. If you already have AckMate you just want to replace Ack with Ag, move or delete "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack" and run ln -s /usr/local/bin/ag "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack"

Other stuff you might like

  • Ack - Better than grep. Without Ack, Ag would not exist.
  • ack.vim
  • Exuberant Ctags - Faster than Ag, but it builds an index beforehand. Good for really big codebases.
  • Git-grep - As fast as Ag but only works on git repos.
  • fzf - A command-line fuzzy finder
  • ripgrep
  • Sack - A utility that wraps Ack and Ag. It removes a lot of repetition from searching and opening matching files.

the_silver_searcher's People

Contributors

aswild avatar avih avatar ban-dana avatar blueyed avatar c4rlo avatar cemeyer avatar dnelson avatar elliot-forty-two avatar gentoo90 avatar ggreer avatar greg0ire avatar gurgeous avatar jdhore avatar jschpp avatar k-takata avatar luksen avatar mattn avatar mattscamp avatar me-and avatar n0la avatar nall avatar ojn avatar okdana avatar pquerna avatar rioderelfte avatar rrebello avatar sebgod avatar sjl avatar tonyo avatar umanwizard 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  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_silver_searcher's Issues

Something like ack's --sort-files.

It's nice to have output that's grouped by files, also sorted by the path to that file. Having just searched in a big project, all the results for stuff in app/ was grouped and all results for db/, config/ and spec/ were grouped, but the ordering of groups was: spec/, config/, app/, and db/. Seems weird.

Line number is not printed in plugin 'Search in project' for Sublime Text 2

Not sure what happens here, but the line number is not part of the output from ag when Sublime Text 2's plugin 'Search in project' is running it.

The same happens when running it "manually" through Sublime Text's console, that is, by using Python's subprocess.Popen(...) in the console. The output from this is:

<filename>:<line>

If I try to include the --column option, this is the output:

<filename>:<column>:<line>

Ag stops searching after 25 matches.

So, I discovered this searching logs over the weekend, and looked into it a tiny bit more this morning. Ag stops looking for matches in any given file after the 25th match. It then moves onto the next file in the list or dir tree, or whatever. I'll likely dig into the code tonight to see if I can figure out wtf is going on, assuming someone doesn't beat me to it.

Environment variable for default parameters

I could create an alias, which is what I'll do for now, but it would be pretty awesome if you could pass parameters to ag via an environment variable. sort of like less's LESS or ack's ACK_OPTIONS. I would guess including them in the beginning of the string before passing argv to parse_options would make the most sense.

Feature Request: --smart-case

It'd be nice to have an option like ack's --smart-case which searches case-insensitively if there are no uppercase letters in the search string.

--invert-match / -v is broken

So I'm guessing not many people use ag with inverted matching. Right now:

$ echo foo >> sample
$ echo bar >> sample

$ ag foo sample
1:foo

$ ag -v foo sample
1:foo

$ ag -v bar sample
1:foo

$ ag -v b sample
1:foo
2:bar

$ mkdir test
$ cd test
$ echo foo >> sample

$ ag -v foo
./sample

Problem with scandir on ReiserFS

On ReiserFS d_type is always set to DT_UNKNOWN. You need an additional call to lstat if DT_UNKNOWN is returned to find out whether the inode points to a directory or a link

Binary file matches

Whenever I do something like: npm -g list | ag -ia
I always get something like 'Binary file matches'
Where as npm -g list | grep -ia actually gets me a result. Is this intended behavior?

--context longopt doesn't work

The --context longopt specified in the man page doesn't work. The short -C works fine.

(discovered while writing some tests. yay!)

$ ag --context=0 e
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
$ ag --context=1 e
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
$ ag --context=2 e
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
$ ag --context=3 e
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
$ ag --context=4 e
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
$ ag -C0 e
./foo:5:e
$ ag -C1 e
./foo:4-d
./foo:5:e
./foo:6-f
$ ag -C2 e
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
$ ag -C3 e
./foo:2-b
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
./foo:8-h
$ ag -C4 e
./foo:1-a
./foo:2-b
./foo:3-c
./foo:4-d
./foo:5:e
./foo:6-f
./foo:7-g
./foo:8-h
./foo:9-i

ag not respecting .gitignore or .agignore?

I'm on OSX installed via brew.

With a simple rails project with some gems installed into vendor/bundle

$ cd new_rails_app

$ cat .gitignore
/.bundle
/vendor/bundle/

$ cat .agignore
./vendor/bundle/
(tried as vendor/bundle and vendor/bundle/ as well)

$ ag controller

returns

...snip a bunch...
./vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/test/test_merge_helpers.rb
10: source_fixture('app/controllers/sample_controller.rb')
=> [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
15: source_fixture('app/controllers/sample_controller.rb')
=> [nil, 3, 1, nil, nil, nil, 1, 0, nil, nil],
32: should "have proper results for sample_controller.rb" do
33: assert_equal [nil, 4, 2, 1, nil, nil, 2, 0, nil, nil],
@merged[source_fixture('app/controllers/sample_controller.rb')]
... more snipping...

I'm wondering if I'm missing something really simple but I haven't been able to find anything about how to setup the ignores online.

Not respecting .gitignore?

The readme says "It ignores files matched by patterns in your .gitignore and .hgignore." I can't make this work, however.

I tried running ag hello in a Git repo where /logs/*.log is .gitignored. Doing git grep hello works as expected, but ag hello seems to scan logs/development.log for the word.

make -r a noopt

Hi,
sometimes I run grep -r on a large source tree. Then, it's too long, so I Ctrl-C, and edit command line to run ack or ag.
ack supports -r option, but not ag, so it's not possible to just replace grep with ag.
I can provide patch for that if needed.

Static linking against libpcre?

Hi Geoff,

We're hoping to embed ag into an application (as it's own binary, that we interact with as a child process when needed). We've noticed it depends on the pcre dynamic library being available on the system. Presumably it's possible to statically link against libpcre.a instead? I'm completely unversed in GNU autotools, but I started reading about it last night. If it's a simple change to statically link, maybe you could just tell me what to change? But otherwise I'll keep studying :-). Are there any other obstacles you can think of that would preclude redistributing a binary that runs on modern versions of OS X? Thanks!

Support for Whole Word ?

I got this working in my branch for regular expressions--it's not too bad.

For non-regexps, though, it's somewhat more difficult.

-f seems to have same behavior as -l; also, symlink not working

vaughn /temp/ag $ ls
bar foo
vaughn /temp/ag $ cat foo/one.txt
This is a test.
vaughn /temp/ag $ cat bar/two.txt
This is another test.
vaughn /temp/ag $ ag test
./bar/two.txt
1:This is another test.

./foo/one.txt
1:This is a test.
everything is as expected so far ---

but, this seems to have the behavior expressed by -l
vaughn /temp/ag $ ag -f test
./bar/two.txt
./foo/one.txt
vaughn /temp/ag $

note: --follow correctly tries to follow symlinks (unlike -f), but has an error:
vaughn /temp/ag $ ln -s ../ag_symlink/ symlink

vaughn /temp/ag $ ll
drwxr-xr-x 3 vaughn wheel 102 Apr 17 17:30 foo
drwxr-xr-x 3 vaughn wheel 102 Apr 17 17:30 bar
drwxr-xr-x 61 vaughn wheel 2.1K Apr 17 17:34 ..
lrwxr-xr-x 1 vaughn wheel 14 Apr 17 17:39 symlink -> ../ag_symlink/
drwxr-xr-x 5 vaughn wheel 170 Apr 17 17:39 .

echo 'This a test via symlink.' > symlink/three.txt

./bar/two.txt
1:This is another test.

./foo/one.txt
1:This is a test.
ERR: File ./symlink failed to load: Invalid argument.

I tried relative and absolute symlinks but got the same 'invalid argument' error.

-G option only works in current directory

Even including the --depth option doesn't return results in subdirectories.

Setup
In a new terminal session
mkdir meals
cd meals
echo -e "coffee\neggs" > breakfast.log
echo -e "juice\nsalad" > lunch.log
echo -e "beer\nburger" > supper.log
echo -e "coffee\njuice\nburger">drinks.txt
cd ../

Reproduce
expected behavior
$ag coffee
./meals/breakfast.log
1:coffee

./meals/drinks.txt
1:coffee

unexpected behavior
$ag -G txt coffee - no results

$cd ./meals
$ag -G txt coffee

./drinks.txt
1:coffee

No File Names in output when using globstar

ack console.log **/*.coffee outputs a list of files in the directory that contain console.log like so:

exam_view_controller.coffee
24:      console.log @model.graded
26:        console.log 'graded in prerender'
63:        console.log split
65:          console.log i
160:      console.log 'selecting ' + index

ag console.log **/*.coffee outputs the same files and lines, but it doesn't output the file that the lines occurred in. Ex:

24:      console.log @model.graded
26:        console.log 'graded in prerender'
63:        console.log split
65:          console.log i
160:      console.log 'selecting ' + index

'ChangeLog' text files should not be searched

Issue Details

I did a search in WebkitGtk source, and noticed that search result includes 'ChangeLog' text files, whereas ack-grep did not include 'ChangeLog' text files in the search result.

I feel search results should not show text files such 'ChangeLog'.

Feel free to ask me more details if you need.

Environment Details

System: Ubuntu 12.04
ag version: latest as of today
ack-grep version: 1.92
Source used: webkitgtk-1.10.0

Sample result:

./Source/JavaScriptCore/ChangeLog:5338: memmove() to move the objects.
./Source/JavaScriptCore/ChangeLog:5340: The problem is memmove() is overkill for this object, moving the value can be done with

Segfault

I was messing around with ag and ran into a segfault when I tried to search for "test" in my Documents folder.

It happens with all of the strings that have a match that I have tried so far. Unmatched strings run fine, and the binary seems to run fine anywhere else. Some file is causing this.

Here's my gdb output:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00000001000c7000
print_file_matches (path=0x1001002b0 "./ag.txt", buf=<value temporarily unavailable, due to optimizations>, buf_len=188416, matches=0x7fff5fbebc60, matches_len=168) at src/print.c:104
104         if (buf[i] == '\n' && opts.before > 0) {

Does not obey gitignore

I use ctags for a really large codebase for navigating in vim, and I've got my tags file gitignored. ag keeps searching through it though, which is a bit troublesome when searching for uses of a function.

I can reproduce the problem on a much smaller scale with the following test:

$ mkdir -p ./Test/Sources
$ cd ./Test
$ echo "tags" > .gitignore
$ echo "hello" > ./Sources/tags

# ag does not skip the tags file, despite it being gitignored
$ ag "hello"
./Sources/tags
1:hello

Search hidden files and dirs by default

There are some dot-dirs that I would like to search, but ag doesn't seem to support specifying them - it's all or nothing.
For example, I'd like to always search my .ipython directory.

-u ignores .gitignore and .agignore, which isn't what I want either since it's all or nothing.

What would be really useful is for ag to search all dotfiles and dotdirs by default, except the ones in .gitignore and .agignore.

Thanks, awesome tool so far. Love the speed improvements over ack.
OSX Lion, ag version 0.1.1

Why do you define global variables in header files?

I find that there are several global variables defined in ignore.h (ignores *root_ignores), options.h (cli_options opts), search.h ( work_queue_t *work_queue, ...) and util.h (ag_stats stats).

As far as I know about good C programming practice, it is not a good idea to do that.

Could you tell me the reasons or considerations behind that?

By the way, thank you for this great work! ;-)

Cannot run ag in parallel

I see there is already a note about pthreads as a future feature. Until then I decided to give GNU parallel ( https://savannah.gnu.org/projects/parallel/ ) a try.

This is the command I used: cat spellings.dict | parallel "ag -ai {} *" which does not appear to do anything. I adapted this idea from the grep version I use cat spellings.dict | parallel "grep -ri {} *"

Steps to reproduce this bug:

  1. run cat spellings.dict | parallel "ag -ai {} *"
  2. no output returned and $? = 0
  3. run cat spellings.dict | parallel "grep -ri {} *" see what the output should have been.

No up-to-date builds on PPA

I just met Ag a few days ago and it is awesome.

Problem is, the binaries on https://launchpad.net/~ggreer/+archive/ag is outdated and I really wanna introduce Ag to my collegues and we're adopting Ubuntu 12.04 as dev sandbox.

I guess I could just build .deb myself but it's really nice to have up-do-date official binaries for this popular distro.

Thanks again for the great work.

Ag doesn't seem to properly print to stdout (unless I use --ackmate) when in node script

This one baffled me and a colleague for a good 45 minutes: http://screencast.com/t/DCog6zuFRhO

Basically, I can run ag on the command line. Great! I actually want to run it as part of a node script. I wrapped up the command in a spawn function, and waited to listen for data events on stdout. I also waited for error and exit events.

Except, nothing ever came out.

When I added the --ackmate option to the script, I got my results. I would prefer not to use this option, though, as I don't want it.

Looking at the source, I see everyone doing printf() all the same. I'm not sure what's going on. This is the absolute latest source from the repo.

Edit: I was running Node v0.6.18, and here's a gist of my file.

macports package

I just whipped this up this portfile to build ag in macports. It seems fine, but I thought I'd run it past you to see if there are any config options, variants, &c I should add as well. Also, I want to make sure the short and long descriptions are okay.

# $Id$

PortSystem       1.0
PortGroup        github 1.0

github.setup     ggreer the_silver_searcher 0.7.2
categories       textproc
maintainers      josephholsten openmaintainer
platforms        darwin
license          Apache-2.0
description      A code-searching tool similar to ack, but faster.
long_description \
  An attempt to make something better than ack, which itself is better than grep.

checksums           rmd160  7fc867cd6065b5946eb4dd89d60a734aa0b09396 \
                    sha256  c81d88c111adf4610d340bd0bf2987a5512a8502dc16eb21421d53f014f174fb

use_autoreconf   yes

You should know your project's straightforward build process makes it super easy to package.

.agrc

Does ag use an ack-like rc file? I wasn't sure where to go to ask this question so I just made an issue.

Support for command-line exclude patterns ?

Sometimes, you don't want to exclude based on a .*ignore file. You may just want to exclude certain patterns based on a one-time only search. For example:

ag var --exclude-files={*.js, *.markdown}

would exclude files based on those extensions.

On a directory level:

ag var --exclude-dirs={lib, src}

would not enter directories that match lib or src.

For extra ice cream bonus points, wildcard matching would be awesome: s*rc* excludes src and source.

I know you like image macros:

Cannot build from source with automake 1.9

Hello,
When trying to build from source with automake 1.9 installed, the following error is reported by automake:
Makefile.am: C objects in subdir but AM_PROG_CC_C_O' not inconfigure.ac'

This can be fixed by adding the line:
AM_PROG_CC_C_O

Near the top of configure.ac.

Sorry there is no pull request - I am forbidden from contributing to open source projects and don't want to poison your code.

Many thanks for a nice utility.

^[[K escape code displayed on every line when output piped into most

Using with Terminal.app on OSX 10.8, and when output is piped into most, the escape code ^[[K is displayed at the end of every line. I'm using the --color to force color even though the output is redirected.

Seems to work fine with less, so could be a problem with most? Any ideas?

Detect file output redirection

If I try to run ag something > output.txt, I get the following message.

ERR: Too many matches in ./output.txt. Skipping the rest of this file.

If I look at the contents of output.txt afterwards, it does in fact contain matches from earlier in output.txt itself. I think ag should avoid searching this file.

The best way to do it would be to run fstat on fd 1 (standard output) and run stat on the file you are about to search and check if their inode numbers match.

Feature Request: .agunignore

In one of the projects I work on, we have a main git repo ~/foo and an optional repo that you can clone under that, ~/foo/bar. In the foo repo, bar is in the gitignore so git doesn't freak out and try to manage it. This means that ag ignores it. I want ag to search that dir though, since it's still useful source code.

Basically I need to way to "unignore" something for a specific project.

trailing '/' in .gitignore

From man gitignore:

If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).

ag doesn't seem to handle this well, if I have a foo/ in my .gitignore, it will still search in foo/bar.txt. I believe it's a bug.

Ubuntu 12.04 instructions don't work

Hello,
I've followed the Ubuntu instructions in the README on both Lubuntu and Linux Mint. These distributions are based on Ubuntu 12.04. I get the following error on:

 sudo apt-get update

W: Failed to fetch http://ppa.launchpad.net/ggreer/ag/ubuntu/dists/precise/main/source/Sources  404  Not Found
W: Failed to fetch http://ppa.launchpad.net/ggreer/ag/ubuntu/dists/precise/main/binary-amd64/Packages  404  Not Found
W: Failed to fetch http://ppa.launchpad.net/ggreer/ag/ubuntu/dists/precise/main/binary-i386/Packages  404  Not Found

I don't mind building from source but I thought it best to report it.

Thanks again for ag. I find your avatar really creepy.

Tests?

It would be nice to have a test suite. I've made a few minor changes lately and didn't really know if I'd broken anything unrelated.

ag seems like the perfect fit for cram. Basically you write tests that look like shell session transcripts:

Add a file:

  $ echo Foo >> testfile

Case-sensitive by default for both literals and regexes:

  $ ag foo

  $ ag f[o]o

  $ ag Foo
  ./testfile
  1:Foo

  $ ag F[o]o
  ./testfile
  1:Foo

Case insensitivity can be turned on:

  $ ag -i foo
  ./testfile
  1:Foo

  $ ag -i f[o]o
  ./testfile
  1:Foo

Smart casing:

  $ ag -S foo
  ./testfile
  1:Foo

  $ ag -S foO

I can write some cram tests if you want.

.gitignore patterns beginning with '/' not treated correctly.

For example, in the linux kernel tree's /.gitignore:

/linux

Causes ag to ignore the path /include/linux, which it should not (and recently caused me some pain).

Mercurial allows this via '^' in regexes, git doesn't use regexes. On another note: as .hgignore uses actual regexes instead of glob patterns (which fnmatch handles), so I don't think they'll work at all.

Possible solutions I see from glancing at the code:

  • create a separate listing in struct ignores for these types of "full path relative to ignore dir" matches. Of course, there would need to be duplicate names and regexes.
  • Build knowledge of what the '/' means into the filename matching. Potentially replace it with './' and have the "current directory" = "." be the directory the ignore file was from.
  • Construct, from all patterns (globs, regexes, & static), a FSM for performing the matching. Essentially, unify regexes and names. This could potentially decrease the cost of ignore look ups (or potentially increase it if branch-misses increase). It would also fix the lack of real hgignore support.

Pager Support (for paging through colored results)

One nice feature of 'ack' is that you can set a pager so you can page through the colored result set. It would be cool if there was a simple pager option (defaulting to less -R or -r) to display results via a pager.

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.