Jay Taylor's notes

back to listing index

zquestz/s

[web search]
Original source (github.com)
Tags: golang go github.com
Clipped on: 2016-06-11

Skip to content
Open a web search in your terminal.
Go Shell Makefile

README.md

Image (Asset 3/7) alt= Image (Asset 4/7) alt= Image (Asset 5/7) alt= Image (Asset 6/7) alt= Image (Asset 7/7) alt=

s

Web search from the terminal. Just opens in your browser.

normalUsage:
  s <query> [flags]

Flags:
  -b, --binary string     binary to launch search URI
  -c, --cert string       path to cert.pem for TLS
  -k, --key string        path to key.pem for TLS
  -l, --list-providers    list supported providers
      --list-tags         list available tags
      --port int          server port (default 8080)
  -p, --provider string   search provider (default "google")
  -s, --server            launch web server
  -t, --tag string        search tag
  -v, --verbose           verbose mode
      --version           display version

normal

Install

normalgo get -v github.com/zquestz/s
cd $GOPATH/src/github.com/zquestz/s
make
make install
normal

Alternatively, you can use Homebrew:

normalbrew install s-search
normal

Examples

Search for puppies on google.

normals puppies
normal

Search for a wifi router on amazon

normals -p amazon wifi router
normal

Search for rhinos on wikipedia

normals -p wikipedia rhinos
normal

Search providers tagged "video" for muppets.

normals -t video muppets
normal

Provider/Tag Expansion

We can do partial matching of provider and tag names. This searches Facebook for hamsters.

normals -p fa hamsters
normal

Or toasters on amazon.

normals -p am toasters
normal

This searches "tech-news" tagged providers for ssd info.

normals -t te ssd
normal

Or shopping sites for blankets.

normals -t sh blankets
normal

Provider/Tag Autocompletion

Autocompletion is supported for providers and tags. To set up autocompletion:

  1. Have  s  installed
  2. Add the following lines to  ~/.bash_profile  or  ~/.zshrc 
normalif [ -f $GOPATH/src/github.com/zquestz/s/autocomplete/s-completion.bash ]; then
    . $GOPATH/src/github.com/zquestz/s/autocomplete/s-completion.bash
fi
normal

Now you are good to go.

normals -p ba<TAB><TAB>
baidu     bandcamp
normal

Fish

Alternatively, if you use fish, the following will work:

normalmkdir -p ~/.config/fish/completions
ln -s $GOPATH/src/github.com/zquestz/s/autocomplete/s.fish ~/.config/fish/completions/s.fish
normal

Advanced

Setup an alias in your  .profile  for your favorite providers.

normalalias sa="s -p amazon"
alias sw="s -p wikipedia"
normal

Use w3m to find cats instead of just your default browser.

normals -b w3m cats
normal

Search for conspiracy theories in incognito mode.

normals -b "chromium --incognito" conspiracy theories
s -b "firefox --private-window" conspiracy theories
normal

Search in a specific subreddit.

normals -p reddit /r/cscareerquestions best startups.
normal

Server Mode

A web interface is also provided. Just pass the  -s  flag.

Start a server on port 8080 (default).

normals -s
normal

Start a server with TLS on port 8443.

normals -s -c /path/to/cert.pem -k /path/to/key.pem --port 8443
normal

Feel free to try it out at https://jumps.io/.

Configuration

To setup your own default configuration just create  ~/.s/config . The configuration file is in UCL format. JSON is also fully supported as UCL can parse JSON files.

For more information about UCL visit: https://github.com/vstakhov/libucl

The following keys are supported:

  • blacklist (array of providers to exclude)
  • binary (binary to launch search URI)
  • cert (path to cert.pem for TLS)
  • customProviders (array of custom providers)
  • key (path to key.pem for TLS)
  • port (server port)
  • provider (search provider)
  • tag (search tag)
  • verbose (verbose mode)
  • whitelist (array of providers to include)

Set your default provider to duckduckgo:

normalprovider: duckduckgo
normal

To only search a few providers:

normalwhitelist: [google, amazon, wikipedia]
normal

To exclude providers you don't need:

normalblacklist: [dumpert]
normal

To add a custom provider:

normalcustomProviders [
  {
    name: example
    url: "http://example.com?q=%s"
    tags: [example]
  }
]
normal

Custom providers require a few things:

  • An alphanumeric name.  ^[a-zA-Z0-9_]*$ 
  • A  %s  token for the query string.
  • A valid URL scheme.

Supported Providers

  • 500px
  • 8tracks
  • amazon
  • archpkg
  • archwiki
  • arstechnica
  • arxiv
  • atmospherejs
  • aur
  • baidu
  • bandcamp
  • bgr
  • bing
  • buzzfeed
  • cnn
  • codepen
  • coursera
  • cplusplus
  • crates
  • crunchyroll
  • debianpkg
  • digg
  • diigo
  • dockerhub
  • dribbble
  • duckduckgo
  • dumpert
  • engadget
  • facebook
  • flickr
  • flipkart
  • foursquare
  • gist
  • github
  • gmail
  • go
  • godoc
  • google
  • googledocs
  • googleplus
  • hackernews
  • ietf
  • ifttt
  • imdb
  • imgur
  • inbox
  • instagram
  • kickasstorrents
  • libgen
  • linkedin
  • lmgtfy
  • macports
  • mdn
  • medium
  • metacpan
  • msdn
  • naver
  • netflix
  • nhaccuatui
  • npm
  • npmsearch
  • npr
  • nvd
  • overstock
  • packagist
  • phandroid
  • php
  • pinterest
  • postgresql
  • python
  • quora
  • reddit
  • rottentomatoes
  • rubygems
  • shodan
  • soundcloud
  • spotify
  • stackoverflow
  • steam
  • taobao
  • thepiratebay
  • theregister
  • torrentz
  • twitchtv
  • twitter
  • unity3d
  • upcloud
  • vimeo
  • wikipedia
  • wolframalpha
  • yahoo
  • yandex
  • youtube

Contributors

License

s is released under the MIT license.