From 2f4863732b1456ea10ad84cff9744f007ab06e8d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 30 Nov 2016 14:18:10 -0500 Subject: [PATCH] Added helper script to search for a tag in the tags file and send it to the picker --- Makefile | 2 ++ xtagpick | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 26b0bf6..6a3ece6 100644 --- 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 diff --git a/xtagpick b/xtagpick index ab222f4..6fb656a 100755 --- a/xtagpick +++ b/xtagpick @@ -1,6 +1,19 @@ #!/bin/sh -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " +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 -- 2.51.0