-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTags
executable file
·48 lines (38 loc) · 907 Bytes
/
Tags
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
#!/bin/sh
panic() {
echo no such tag "'$tag'" && exit 1
}
MAXDEPTH=3
d="$PWD"
while [ ! -f tags -a $MAXDEPTH != 0 ]
do
cd ..
MAXDEPTH=$((MAXDEPTH-1))
done
if [ $MAXDEPTH = 0 ]
then
cd "$d"
echo generating tags
ctags -R
fi
if [ "$#" = 0 ]
then
tag="$(9p read acme/$winid/rdsel)"
else
tag="$1"
fi
grep -q "^$tag " ./tags || panic
addr="$(grep ^$tag ./tags | awk -F'\t' '{a=$3; sub(";\"[^\"]*", "", a); gsub("[().*\\[\\]]", "\\\\&", a); print a; exit}')"
file="$(grep ^$tag ./tags | awk -F'\t' '{print $2; exit}')"
file="$(readlink -f $PWD'/'$file)"
if 9p read acme/index|grep -q "$file"
then
wi="$(9p read acme/index|grep $file|awk '{print $1}')"
else
wi="$(9p read acme/new/ctl|awk '{print $1}')"
echo name "$file"|9p write acme/$wi/ctl
echo get | 9p write acme/$wi/ctl
fi
echo -n "$addr" | 9p write acme/$wi/addr
echo dot=addr | 9p write acme/$wi/ctl
echo show | 9p write acme/$wi/ctl