-
Notifications
You must be signed in to change notification settings - Fork 4
/
vd
executable file
·56 lines (51 loc) · 1.32 KB
/
vd
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
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
die() {
echo $@
exit 1
}
find_file() {
DIR=$1
WHAT=$2
FILE=$(find ${DIR} -noleaf -xdev -name '*.java' \
-o -name '*.proto' \
-o -name '*.h' \
-o -name '*.html' \
-o -name '*.xml' \
-o -name '*.c' \
-o -name '*.cc' \
-o -name '*.scala' \
-o -name '*.go' \
-o -name '*.py' \
-o -name '*.gradle' \
-o -name '*.json' \
-o -name '*.sh' \
| grep "${WHAT}" | sort -r | head -n 1)
[[ -e "${FILE}" ]] || die "Nothing found in $VD_LEFT"
}
[[ $# == 1 ]] || die "You must pass exactly one argument: what to search for"
SEARCH_PATTERN="${1}"
#VD_LEFT="${VD_LEFT:-/home/cmccabe/src/kafka2}"
VD_LEFT="${VD_LEFT:-/home/cmccabe/src/ccs-kafka}"
VD_RIGHT="${VD_RIGHT:-/home/cmccabe/src/ce-kafka2}"
find_file "${VD_LEFT}" "${SEARCH_PATTERN}"
LEFT_FILE="${FILE}"
find_file "${VD_RIGHT}" "${SEARCH_PATTERN}"
RIGHT_FILE="${FILE}"
EXTRA_ARGS=""
if [[ "${VD_SPLIT}" == "stacked" ]]; then
EXTRA_ARGS="$EXTRA_ARGS -o"
elif [[ "${VD_SPLIT}" == "side-by-side" ]]; then
: # nothing to do
elif [[ "${VD_SPLIT}" == "" ]]; then
: # nothing to do
else
die "Unknown VD_SPLIT value of ${VD_SPLIT}"
fi
#
# You can use vimstart here to read file names from stdin. Like so:
#
# export VD_BIN=vimstart
# cat <my_file_name> | vd
#
VD_BIN="${VD_BIN:vimdiff}"
exec vimdiff ${EXTRA_ARGS} "${LEFT_FILE}" "${RIGHT_FILE}"