Re: Keystroke to search via search engine

Thorsten Glaser <[email protected]>
Newsgroups gmane.comp.web.lynx.devel
Message-ID <[email protected]>
Tim Chase dixit:

>I usually do this with an alias or shell function to populate the                                                                                                                                                             
>GET parameters, like                                                                                                                                                                                                          
>
>  $ goog() { lynx [2]https://google.com/search?q="$1" ; }                                                                                                                                                                     

More escaping needed ☺

# GooGle Search
ggs() {
	local _q _IFS

	_IFS=$IFS
	IFS=+
	_q="$*"
	IFS=$_IFS
	${BROWSER:-lynx} "http://www.google.com/search?hl=la&pws=0&num=100&safe=off&q=$_q"
}

# DuckDuckGo search
ddg() {
	local _q _IFS _p=/ _a=

	_IFS=$IFS
	IFS=+    
	_q="$*"  
	IFS=$_IFS
	case /${BROWSER:-lynx} in
	(*/dillo*)
		# make result page and target links work
		_p=/lite/ _a='&kd=-1' ;;
	(*/links*|*/lynx*)
		# avoid automatic redirect
		_p=/lite/ ;;
	esac
	${BROWSER:-lynx} "https://duckduckgo.com$_p?kp=-1&kl=wt-wt&kb=t&kh=1&kj=g2&km=l&ka=monospace&ku=1&ko=s&k1=-1&kv=1&t=debian&q=$_q$_a"
}

Though some want space (+) to be replaced by %20, and # is still a problem.

bye,
//mirabilos
-- 
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
	-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.