-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathack
More file actions
executable file
·44 lines (36 loc) · 944 Bytes
/
ack
File metadata and controls
executable file
·44 lines (36 loc) · 944 Bytes
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
36
37
38
39
40
41
42
43
44
#!/bin/bash
#
# Uses .ack.conf file to store default params for the ack command
# The format is simple, lines starting with # will be ignored the rest
# will be appended as an argument list.
#
if [ ! `which ack` ]; then
echo "ack is not installed."
if [ `which brew` ]; then
echo "Type 'brew install ack' to install."
fi
exit 1
fi
function readConf() {
local file=$1
# search in every dir in $pwd in reverse order starting with the current.
while [[ ! -f $file ]] && [[ $PWD != $HOME ]]; do \cd ..; done
if [ -f "$file" ]; then
doReadConf $ackconf
fi
}
function doReadConf() {
local file=$1
while IFS= read -r line;
do
[[ $line =~ ^[[:space:]]*# ]] && continue # ignore comments
result+=" ${line}"
done < "$file"
}
ackCmd=`which -a ack | sed -n 2p`
result=""
ackconf=".ack.conf"
readConf $ackconf
echo $ackCmd $result ${*}
$ackCmd $result ${*}
exit $?