commit 91a79a874fba12bd64f5fe22a8850214631323b3
parent c827479dd221aa26f12242fa4ed11c7f3f12d0a5
Author: Jacob R. Edwards <n/a>
Date: Sun, 17 Jul 2022 12:38:14 -0500
Make netquery faster for the most common operation
Use the first shortcut by default. A different one can be used by
giving it as the first argument, prefixed by plus ('+').
Diffstat:
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/local/bin/bin/netquery b/local/bin/bin/netquery
@@ -4,11 +4,17 @@
# Find the url shortcut specified by the first argument and replace
# `$query' with the subsequent arguments concatnated on `+'.
-
BEGIN {
FS = " ";
- for (i in ARGV) {
- argv[i] = ARGV[i];
+
+ i = 1
+ if (ARGV[i] ~ /^\+/) {
+ query = substr(ARGV[i], 2)
+ delete ARGV[i]
+ ++i;
+ }
+ for (; i < ARGC; ++i) {
+ argv[++j] = ARGV[i];
delete ARGV[i];
}
@@ -21,13 +27,14 @@ BEGIN {
/^(#|$)/ { next }
-match($1, "^" argv[1] "$") > 0 {
- query = argv[2];
- for (i = 3; i < length(argv); ++i)
+! query || match($1, "^" query "$") > 0 {
+ query = argv[1];
+ for (i = 2; i <= length(argv); ++i)
query = query "+" argv[i];
if (!sub("\\$query", query, $2)) {
printf "%s: No substitution made.\n", $1 > "/dev/stderr";
exit 1;
}
print $2;
+ exit 0
}
diff --git a/local/netquery/config/netquery b/local/netquery/config/netquery
@@ -1,8 +1,8 @@
+s https://searx.be/?q=$query
aw https://wiki.archlinux.org/index.php?search=$query
ebay https://www.ebay.com/sch/i.html?_nkw=$query&_sop=15&LH_BIN=1
hw https://handwiki.org/wiki/index.php?search=$query
ia https://archive.org/search.php?query=$query
-s https://searx.be/?q=$query
sb https://searx.bar/?q=$query
sl http://searx.lukesmith.xyz/?q=$query
sg https://searx.gnu.style/?q=$query
@@ -15,3 +15,4 @@ wm https://commons.wikimedia.org/w/index.php?search=$query
am https://www.amazon.com/s?k=$query&ref=nb_sb_noss&s=price-asc-rank
mb https://musicbrainz.org/search?query=$query&type=artist&method=indexed
lg https://libgen.fun/search.php?req=$query
+craig https://www.craigslist.org/search/sss?query=$query