Here I demonstrate searching through and reading lists of things from the command line.

I ran into some issues with the googlesearch pip module It seems to have been taken down from pip.

I changed my script to use emacs’ eww browser to scrape the results instead eww is pretty reliable.

Demonstration

Please be patient as I bypass the problem above.

asciinema recording

Some search results from the demonstration above

1
2
3
4
5
6
7
8
http://linear.ups.edu/
http://buzzard.ups.edu/
http://www.cns.gatech.edu/GroupTheory/index.html
http://www.cns.gatech.edu/%7Epredrag/
http://www.cns.gatech.edu/~predrag/
http://www.math.harvard.edu/people/SternbergShlomo.html
http://www.math.harvard.edu/~shlomo/docs/Real_Variables.pdf
http://www.math.harvard.edu/~shlomo/docs/lie_algebras.pdf
1
hn haskell -- monad
quality query
terms_string haskell
title_terms_string monad

The hn script is based on my glt script which allows me to search google for websites containing lexemes in the title or document, in an easy way.

1
SITE=news.ycombinator.com glt "$@"

glt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
export TTY

( hs "$(basename "$0")" "$@" "#" "<==" "$(ps -o comm= $PPID)" 0</dev/null ) &>/dev/null

full_string="$(cmd "$@")"

if test $# -eq 0 || test "$full_string" = "--"; then
    : ${SITE:="google.com"}
    eww "http://$SITE"
    exit $?
fi

# save args
args=("$@")

eval "set -- $(cmd "$@" | sed -e "s/^-- .*//"  -e "s/ -- .*//" -e "s/ --$//")"
terms=("$@")
terms_string="$(cmd "$@")"

# restore args
set -- "${args[@]}"

if cmd "$@" | grep -q -P '(^| )--( |$)'; then
    eval "set -- $(cmd "$@" | sed -e "s/.* -- //" -e "s/ --$//" -e "s/^-- //")"
    title_terms=("$@")
else
    title_terms=()
fi
title_terms_string="$(cmd "$@")"

(
echo "terms_string: $terms_string"
echo "title_terms_string: $title_terms_string"
) 1>&2

if test -n "$SITE"; then
    sitestr="site:$SITE"
fi

if test -n "$terms_string" && test -n "$title_terms_string"; then
    eval "egr $terms_string $sitestr intitle:$(aqf "$title_terms_string")"
else
    if test -n "$terms_string"; then
        eval "egr $terms_string $sitestr"
    elif test -n "$title_terms_string"; then
        eval "egr $sitestr intitle:$(aqf "$title_terms_string")"
    fi
fi