Permalink
Browse files

Easy ways to use a grep other than ack

1. Symlink or copy viack as viag to use ag instead of ack.
2. Export VIACK_GREP=ag to use ag instead of ack when calling viack.

VIACK_GREP takes priority, then how viack was invoked, with the default
being ack.
  • Loading branch information...
1 parent 493b665 commit 3f5bbcb641b1b1adb440d6b14d01d4897bdd17d5 @tsibley committed Jul 1, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 viack
View
8 viack
@@ -2,6 +2,8 @@
use strict;
use warnings;
+use File::Basename qw(basename);
+
my ($grabnext, @vimopts, @files);
# Extract the ack pattern to use when spawning vim
@@ -31,8 +33,10 @@ if ($pid) {
chomp for @files;
close $kid;
} else {
- exec ack => '-l', @ARGV
- or die "Can't exec ack: $!";
+ my ($invoked_as) = basename($0) =~ /^vi(.+)/;
+ my $ack = $ENV{VIACK_GREP} || $invoked_as || 'ack';
+ exec $ack => '-l', @ARGV
+ or die "Can't exec $ack: $!";
}
if (@files) {

0 comments on commit 3f5bbcb

Please sign in to comment.