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

Commit

Permalink
Add option --nohl
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed Jul 20, 2019
1 parent 6385bbf commit 7e72557
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ optional arguments:
--colorize=always
-C, --nocolor equivalent to --colorize=never
--colors COLORS set output colors (see man page for details)
--nohl do not highlight keyword matches in abstract
-j, --first, --lucky open the first result in web browser and exit
-t dN, --time dN time limit search [h5 (5 hrs), d5 (5 days), w5 (5
weeks), m5 (5 months), y5 (5 years)]
Expand Down
1 change: 1 addition & 0 deletions auto-completion/bash/googler-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _googler () {
--colorize
-C --nocolor
--colors
--nohl
-j --first --lucky
-t --time
-w --site
Expand Down
1 change: 1 addition & 0 deletions auto-completion/fish/googler.fish
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ complete -c googler -s x -l exact --description 'disable automatic s
complete -c googler -l colorize -r --description 'whether to colorize output (options: auto/always/never)'
complete -c googler -s C -l nocolor --description 'disable color output'
complete -c googler -l colors -r --description 'set output colors'
complete -c googler -l nohl --description 'do not highlight keyword matches'
complete -c googler -s j -l first -l lucky --description 'open the first result in a web browser'
complete -c googler -s t -l time -r --description 'time limit search (h/d/w/m/y + number)'
complete -c googler -s w -l site -r --description 'search a site using Google'
Expand Down
1 change: 1 addition & 0 deletions auto-completion/zsh/_googler
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ args=(
'(--colorize)--colorize[whether to colorize output]:auto/always/never'
'(-C --nocolor)'{-C,--nocolor}'[disable color output]'
'(--colors)--colors[set output colors]:six-letter string'
'(--nohl)--nohl[do not highlight keyword matches]'
'(-j --first --lucky)'{-j,--first,--lucky}'[open the first result in a web browser]'
'(-t --time)'{-t,--time}'[time limit search]:period (h/d/w/m/y + number)'
'(-w --site)'{-w,--site}'[search a site using Google]:domain'
Expand Down
6 changes: 5 additions & 1 deletion googler
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,7 @@ class Result(object):
Class Variables
---------------
colors : str
nohl : bool
Methods
-------
Expand All @@ -2242,6 +2243,7 @@ class Result(object):

# Class variables
colors = None
nohl = False
urlexpand = True

def __init__(self, index, title, url, abstract, metadata=None, sitelinks=None, matches=None):
Expand Down Expand Up @@ -2296,7 +2298,7 @@ class Result(object):
else:
print(' ' * (indent + pre) + metadata)

if colors:
if colors and not self.nohl:
# Start from the last match, as inserting the bold characters changes the offsets.
for match in reversed(matches or []):
abstract = (
Expand Down Expand Up @@ -3189,6 +3191,7 @@ def parse_args(args=None, namespace=None):
addarg('--colors', dest='colorstr', type=argparser.is_colorstr,
default=colorstr_env if colorstr_env else 'GKlgxy', metavar='COLORS',
help='set output colors (see man page for details)')
addarg('--nohl', action='store_true', help='do not highlight keyword matches in abstract')
addarg('-j', '--first', '--lucky', dest='lucky', action='store_true',
help='open the first result in web browser and exit')
addarg('-t', '--time', dest='duration', type=argparser.is_duration,
Expand Down Expand Up @@ -3275,6 +3278,7 @@ def main():
else:
colors = None
Result.colors = colors
Result.nohl = opts.nohl
Result.urlexpand = True if os.getenv('DISABLE_URL_EXPANSION') is None else False
GooglerCmd.colors = colors

Expand Down

0 comments on commit 7e72557

Please sign in to comment.