]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added helper script to search for a tag in the tags file and send it to the picker
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 30 Nov 2016 19:18:10 +0000 (14:18 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 30 Nov 2016 19:18:10 +0000 (14:18 -0500)
Makefile
xtagpick

index 26b0bf62f2962b3accfd69b93b94526c76271810..6a3ece602189b77908f9f47d9120c90ba0027e28 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,11 +28,13 @@ install: all
        cp xedit $(PREFIX)/bin
        cp xpick $(PREFIX)/bin
        cp xfilepick $(PREFIX)/bin
+       cp xtagpick $(PREFIX)/bin
 
 uninstall:
        rm -f $(PREFIX)/bin/xedit
        rm -f $(PREFIX)/bin/xpick
        rm -f $(PREFIX)/bin/xfilepick
+       rm -f $(PREFIX)/bin/xtagpick
 
 test: unittests
        ./unittests
index ab222f4046fac30ec10c2c22e47bf43b9e4f5317..6fb656aa198580db8d7a05c5cf27b0091e6821bb 100755 (executable)
--- a/xtagpick
+++ b/xtagpick
@@ -1,6 +1,19 @@
 #!/bin/sh
-if [ "$#" -ne 1 ]; then
-    echo "Usage: $0 <tagfile>"
+TAGFILE="$1"
+TAG="$2"
+
+if [ "" == "$TAG" ] || [ "" == "$TAGFILE" ]; then
+    echo "Usage: $0 TAGFILE TAG"
     exit 1
 fi
-cut -f1 "$1" | grep -v '^!' | uniq | ./xpick
+
+awk -vTAG="$TAG" '
+BEGIN { FS = "[\t]+" }
+($1 == TAG) {
+    matchstr = $3
+    sub(/^\//, "\"", matchstr)
+    sub(/\/;"$/, "\"", matchstr)
+    gsub(/\*/, "\\*", matchstr)
+    print "grep -Hn", matchstr, $2, "| cut -d: -f1,2"
+}
+' "$TAGFILE" | /bin/sh | xpick