shithub: plan9front

Download patch

ref: 2aba7615afdabfdef8e02d162ffee2ecdf3e39e9
parent: f234b29c7fc119fa148af2108f93e5eaf9ecbfb4
author: Sigrid <ftrvxmtrx@gmail.com>
date: Tue Mar 2 02:21:56 EST 2021

mothra: add "d" command to search for a text on the internet (using duckduckgo)

--- a/sys/man/1/mothra
+++ b/sys/man/1/mothra
@@ -132,6 +132,11 @@
 .B a
 Toggle alt display.
 .TP
+.BI d " text
+Search for the given
+.I text
+on the internet.
+.TP
 .BI g " url
 Go to the page with the given URL.
 .TP
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -675,6 +675,16 @@
 		if(*s=='\0' && selection)
 			hit3(3, 0);
 		break;
+	case 'd':
+		s = arg(s);
+		if(*s){
+			s = smprint("https://duckduckgo.com/html/?q=%U", s);
+			if(s != nil)
+				geturl(s, -1, 0, 0);
+			free(s);
+		}else
+			message("Usage: d text");
+		break;
 	case 'g':
 		s = arg(s);
 		if(*s=='\0'){