travis-g / bang

Browser launching inspired by DuckDuckGo's !bangs
MIT License
0 stars 0 forks source link

[Feature Request] Non-URI-encoded Bang #8

Closed smhmd closed 4 years ago

smhmd commented 4 years ago
ghr:
  description: GitHub Repo
  format: https://github.com/{{{r}}} #r for raw
$ bang ghr travis-g/bang # opens https://github.com/travis-g/bang

A suggestion: One thing I do in my dmenu script, is that I subtitute @@ with xclip -o (secondary selection) if it holds something. You could consider that. I can think of a configurable @@ for secondary selection and @! for primary selection. Maybe you can think of some other interface.

travis-g commented 4 years ago

Based on the title, are you looking to have a way to pass through the query exactly, without any escaping? escape_method: 1 for PASS_THROUGH may be what you're looking for. The escape methods are going into the help text/usage info soon.

The default sourcegraph bang uses the pass-through option:

% jq .sourcegraph bangs.json  
{
  "description": "Sourcegraph",
  "escape_method": 1,
  "format": "https://sourcegraph.com/{{{s}}}"
}
% ./bang -url sourcegraph github.com/travis-g/bang
https://sourcegraph.com/github.com/travis-g/bang

To clarify about your xclip suggestion, are you looking for a way to do multi-parameter/multi-query bangs? Or conditional logic?

smhmd commented 4 years ago

are you looking for a way to do multi-parameter/multi-query bangs? Or conditional logic?

I was thinking of opening an issue about multi-parameter.

The idea is to abstract clipboard in scripts/automation in contexts where ctrl+v isn't present like dmenu.

In the picture, I have WebAssembly selected, hit my keybinding for dmenu, and enter search terms @@ additional search terms.

pic This opens https://www.google.com/search?q=WebAssembly+with+rust.

similarly, multi-parameters can be abstracted by some sort of delimiter.

wa:
  description: Send Whatsapp Message
  format: https://api.whatsapp.com/send?phone={{{s1}}}&text={{{s2}}}

pic Opens https://api.whatsapp.com/send?phone=15551234567&text=okay.

travis-g commented 4 years ago

Multi-param may be simpler with templates, but I'd have to think on that. You may be able to use a wrapper script:

wa:
  description: Send Whatsapp Message
  format: https://api.whatsapp.com/send?{{{s}}}
#!/usr/bin/env sh
printf "phone=%s&text=%s" "$1" "$2" | bang wa -