Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Incremental search support.
Browse files Browse the repository at this point in the history
Signed-off-by: Arun Prakash Jana <[email protected]>
  • Loading branch information
jarun committed Sep 4, 2015
1 parent 1acf62a commit a870e4f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Copyright (C) 2008 Henri Hakkinen

Modified (2015) by Arun Prakash Jana &lt;[email protected]&gt;

`google-cli` is a command line tool to search Google (Web & News) from the terminal. It shows the title, URL and text context for each result. Results are fetched in pages. Next or previous page navigation is possible using keyboard shortcuts. Results are indexed and a result URL can be opened in a browser using the index number.
`google-cli` is a command line tool to search Google (Web & News) from the terminal. It shows the title, URL and text context for each result. Results are fetched in pages. Next or previous page navigation is possible using keyboard shortcuts. Results are indexed and a result URL can be opened in a browser using the index number. Supports sequential searches in a single instance.

`google-cli` is GPLv3 licensed. It doesn't have any affiliation to Google in any way.

Expand All @@ -16,6 +16,7 @@ Modified (2015) by Arun Prakash Jana &lt;[email protected]&gt;
> - Fetch n results in a go
> - Start at n<sup>th</sup> result
> - Fetch and navigate next or previous set of results
> - Initiate a new search with original options (in a single instance)
> - Easily open result URLs in browser from cmdline using index number
> - Show full contextual text snippet in search results
> - Specify search duration (in hours / days / weeks / months / years)
Expand Down Expand Up @@ -53,8 +54,10 @@ Options
-d enable debugging

Keys
n, p press 'n' or 'p' and Enter to navigate forward and backward
1-N press a number and Enter to open that result in browser</pre>
n, p enter 'n' or 'p' to navigate forward or backward
s terms enter 's' followed by keywords to initiate a new search (with original options)
1-N enter a number to open that result in browser
any other input exits googler</pre>

<b>Configuration file</b>

Expand Down Expand Up @@ -110,6 +113,9 @@ To remove, run:

# News

>**04 Sep, 2015**
> - Add incremental search
>**03 Sep, 2015**
> - Removed file type specific search as it can be done easily with `filetype:mime` option
> - The utilily name is changed to googler (from google) to avoid any copyright infringements
Expand Down
32 changes: 26 additions & 6 deletions googler
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ def usage():
print(" -t dN time limit search [h5 (5 hrs), d5 (5 days), w5 (5 weeks), m5 (5 months), y5 (5 years)]")
print(" -d enable debugging\n")
print("Keys")
print(" n, p press 'n' or 'p' and Enter to navigate forward and backward")
print(" 1-N press a number and Enter to open that result in browser\n")
print("Version 1.2")
print(" n, p enter 'n' or 'p' to navigate forward or backward")
print(" s terms enter 's' followed by keywords to initiate a new search (with original options)")
print(" 1-N enter a number to open that result in browser")
print(" any other input exits googler\n")
print("Version 1.5")
print("Copyright (C) 2008 Henri Hakkinen.")
print("Modified (2015) by Arun Prakash Jana <[email protected]>")
print("Webpage: https://github.com/jarun/google-cli")
Expand Down Expand Up @@ -290,6 +292,12 @@ if lang is not None:
if duration is not None:
url += "tbs=qdr:" + duration + "&"

baseurl = url
basestart = start

if debug:
print("[DEBUG] Base URL [%s]" % url)

url += "q=" + quote_plus(keywords[0])
for kw in keywords[1:]:
url += "+" + quote_plus(kw)
Expand Down Expand Up @@ -354,14 +362,14 @@ def fetch_results():

results = []
while True:
if nav == "n" or nav == "p":
if nav == "n" or nav == "p" or nav =="s":
results = fetch_results()

oldstart = start
if sys.version_info > (3,):
nav = input("Press 'n', 'p', or number and Enter to continue... ")
nav = input("Enter 'n', 'p', 's keywords', or number to continue... ")
else:
nav = raw_input("Press 'n', 'p', or number and Enter to continue... ")
nav = raw_input("Enter 'n', 'p', 's keywords' or number to continue... ")

if nav == "n":
if num is not None:
Expand All @@ -375,6 +383,18 @@ while True:
else:
start = str(int(start) - 10)
print("\n\x1B[91m\x1B[1m ***** ***** ***** ***** \x1B[0m\n")
elif len(nav) > 2 and nav[0] == "s" and nav[1] == " ":
trimsearch = nav[2:].strip().replace(" ", "+")
if trimsearch == "":
print("Empty string. Exiting...")
break
url = baseurl + "q=" + trimsearch
if debug:
print("New search URL [%s]" % url)
nav = "s"
start = basestart
print("\n\x1B[91m\x1B[1m ***** ***** ***** ***** \x1B[0m\n")
continue
elif is_int(nav):
index = int(nav) - 1
try:
Expand Down
14 changes: 10 additions & 4 deletions googler.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "GOOGLER" "1" "August 2015" "Version 1.2" "User Commands"
.TH "GOOGLER" "1" "September 2015" "Version 1.5" "User Commands"
.SH NAME
googler \- Google from command line
.SH SYNOPSIS
Expand All @@ -7,7 +7,7 @@ googler \- Google from command line
.I KEYWORDS...
.SH DESCRIPTION
.B googler
is a command line tool to search Google (Web & News) from the terminal. It shows the title, URL and text context for each result. Results are fetched in pages. Next or previous page navigation is possible using keyboard shortcuts. Results are indexed and a result URL can be opened in a browser using the index number. There is no configuration file as aliases serve the same purpose for this utility.
is a command line tool to search Google (Web & News) from the terminal. It shows the title, URL and text context for each result. Results are fetched in pages. Next or previous page navigation is possible using keyboard shortcuts. Results are indexed and a result URL can be opened in a browser using the index number. There is no configuration file as aliases serve the same purpose for this utility. Supports sequential searches in a single instance.
.SH OPTIONS
.TP
.BI \-s " N"
Expand Down Expand Up @@ -45,10 +45,16 @@ Enable debugging.
.SH KEYS
.TP
.BI "n, p"
Press 'n' or 'p' and Enter to navigate forward and backward
Enter 'n' or 'p' to navigate forward or backward.
.TP
.BI s " terms"
Enter 's' followed by keywords to initiate a new search (with original options).
.TP
.BI "1-N"
Press a number and Enter to open that result in browser
Enter a number to open that result in browser.
.TP
.BI ""
Any other input exits googler.
.SH ENVIRONMENT
.TP
.BI BROWSER
Expand Down

0 comments on commit a870e4f

Please sign in to comment.