Skip to content

travis-g/bang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bang

GoDoc

Browser launcher, heavily inspired by DuckDuckGo's !bangs.

Search for cat pictures on Google Images:

bang gi cat pictures
# opens a browser to 'cat pictures' on Google Images

Queries can also be piped through stdin if a hyphen is passed in as the argument, and the -url flag can be used to print the bang's URL to stdout rather than launching a browser.

$ echo "cat pictures" | bang -url gi -
https://www.google.com/search?tbm=isch&q=cat+pictures
$ echo "reddit cat pictures" | bang -url -
https://www.reddit.com/search?q=cat+pictures

The system's URL opener will be used by default, but if set, the BROWSER environment variable will be executed with the chosen bang's URL passed as the final argument.

Installation

To get everything and install the CLI into your GOPATH:

go get -u github.com/travis-g/bang/...

The CLI is available from within cmd/bang.

Config

The CLI looks for a config file named bangs.(json|yml|yaml|toml|hcl) in the following locations, in order:

~/.config/bang/
~/.config/
./ (current directory)

Each key of the config file should be the unique name of a Bang, with the following properties:

  • description (string: <req>) is a friendly description for the Bang.
  • escape_method (int: 0) defines how the query is escaped prior to it being substituted within the Bang's format:
    • 0 - Escapes with url.QueryEscape: cat picturescat+pictures. This is the default method.
    • 1 - Pass-through without escaping: cat picturescat pictures
    • 2 - Escapes with url.PathEscape: cat picturescat%20pictures
  • format (string: <req>) defines the template used to create the Bang's resulting query string. Use {{{s}}} to denote where the query should be substituted.

Example YAML config file entry for GoDoc:

godoc:
  # try it: bang godoc github.com/travis-g/bang
  description: GoDoc
  escape_method: 1
  format: "https://godoc.org/{{{s}}}"

See the bang.proto file for the Bang object format.

About

Browser launching inspired by DuckDuckGo's !bangs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published