dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

websearch (1332B)


      1 #!/bin/sh
      2 
      3 if [ $# -lt 1 ]; then
      4 	url="$(grep 'href="htt' "$HOME"/doc/bookmark.html | \
      5 		sed 's/<\/.*>//g' | \
      6 		sed 's/.*<a href="//;s/">/ /;s/<\/a>//' ;
      7 		cat ~/doc/bookmark.txt)"
      8 
      9 	choice=$(printf '%s' "$url" | dmenu -i -p "search:") || exit 1
     10 else
     11 	choice="$*"
     12 fi
     13 
     14 # Detect if url
     15 case "$choice" in
     16 	http://*|https://*)
     17 		plumb "$(printf '%s' "$choice" | awk '{print $1}')"
     18 		;;
     19 	*!scholar*)
     20 		plumb "https://scholar.google.com/scholar?q=$(printf '%s' "$choice" | sed 's/!scholar//')"
     21 		;;
     22 	*!map*)
     23 		plumb "https://www.openstreetmap.org/search?query=$(printf '%s' "$choice" | sed 's/!map//')"
     24 		;;
     25 	*!wiki*)
     26 		plumb "https://en.wikipedia.org/wiki/Special:Search?search=$(printf '%s' "$choice" | sed 's/!wiki//')"
     27 		;;
     28 	*!yt*)
     29 		idiotbox="$HOME/code/idiotbox"
     30 		if [ -x "$idiotbox/cgi" ]; then
     31 			tmpfile=/tmp/yt.html
     32 			QUERY_STRING="q=$(printf '%s' "$choice" | sed "s/!yt//" | tr ' ' '+')" \
     33 				"$idiotbox/cgi" > "$tmpfile"
     34 			cp -r "$idiotbox/css" /tmp
     35 			plumb "$tmpfile"
     36 			sleep 5
     37 			rm "$tmpfile"
     38 		else
     39 			plumb "https://codemadness.org/idiotbox/?q=$(printf '%s' "$choice" | sed 's/!yt//')&o=relevance&m=Dark"
     40 		fi
     41 		;;
     42 	*\ *)
     43 		plumb "https://duckduckgo.com/?q=$(printf '%s' "$choice" | sed 's/+/%2b/g')&kae=d&kau=-1&kao=-1&kap=-1&kaq=-1&kax=-1&kak=-1&kv=-1&kk=-1&k1=-1&kc=-1";;
     44 	*)
     45 		plumb "http://${choice}";;
     46 esac