public
Description: TextMate command to search the current project using ack
Homepage:
Clone URL: git://github.com/melo/search-in-project-with-ack-tmcommand.git
100755 35 lines (25 sloc) 0.56 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env perl
 
use strict;
use warnings;
 
my $base = 'SearchInProjectWithAck.tmCommand';
my $tmpl = slurp("$base.tmpl");
my $script = slurp('search_with_ack.rb');
 
# very basic XML Encode
$script =~ s/&/&/go;
$script =~ s/</&lt;/go;
$script =~ s/>/&gt;/go;
$script =~ s/'/&apos;/go;
$script =~ s/"/&quot;/go;
 
$tmpl =~ s/##CONTENT##/$script/;
 
print $tmpl;
 
### Slurp a file
sub slurp {
  my $filename = shift;
  
  if (open(my $fh, '<', $filename)) {
    local $/;
    my $content = <$fh>;
    close($fh);
    
    return $content;
  }
  die $!;
}