ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Bang Search

by bsoun ST3

Plugin to perform websearch from Sublime Text

Labels search

Details

Installs

  • Total 343
  • Win 175
  • OS X 90
  • Linux 78
Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2
Windows 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
OS X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Bang Search

Version : 1.2.0

Change in behaviour for the input search method. If you enter a multiline search, using CTRL + ENTER between lines, a distinct browser's window is opened, one for each of your line in the input box panel.

Version : 1.1.2

Bug Correction

Version : 1.1.1

This plugin for Sublime Text 3 allow to perform a web search from the currently selected text/word or from an input panel from your predifined requests in one or several browser tabs.

Various custom or predefined search engine are declared in the bang-search.sublime-settings. You can add yours quite easily in this file , you can prefix your bang by whatever you want except for duckduckgo, this one must be valid : !…

There are several ways to perform your search : * on a selected text/word : - show a quick panel to select your search request - directly launch a predefined search request
* from an input panel - show a quick panel to select your search request - directly launch a predefined search request

This package adds:

  • A Bang Search command to the context menu for the selected
  • A Bang Input Search command to the context menu for the selected
  • A Bang Search to the command pannel
  • A Bang Input Searchto the context panel

Install

If your using the Sublime Package Manger hold down Ctrl+Shift+P and type Package Control: Install Package. Then search for bang-search and hit return.

If your not using the package manager then go to your Sublime packages directory(Sublime Text/Packages) Then run this command git clone https://github.com/bsoun/bang-search.git.

Or you can download the package as a zip file https://github.com/bsoun/bang-search/archive/master.zip then copy it into your Sublime packages directory.

SETTINGS

The two first parameters control the display options : - Display the bang before the caption of your predefine search engine in the quick panel - The second one :
* If true, display alert message in the bottom status panel * If false, a dialog box show you the warning message - The third parameter contain the list of browser (see below)

[
{
    "display_bang_in_panel": true,
    "silent_error": true,
    "browsers_list": ["default","firefox","google-chrome"],
}
]

The definitions contain your search requests :

[
{
     "!gt": {
        "type": "duckduckgo",
        "caption": "Google Translate"
      },
      "!python27": {
        "type": "duckduckgo",
        "caption": "Python 2.7"
      },
      "&gh": {
        "type": "qwant",
        "caption": "Github"
      },
      "@ipynbViewer": {      
      "type": "custom",
      "caption": "iPyNotebookViewer",
      "url": "https://google.com/#q={{q}} site:nbviewer.ipython.org/github/"
      },   
      "@speakerdeck": {
        "type": "hidden",
        "caption"  : "speakerdeck",
        "url"      : "https://speakerdeck.com/search?utf8=✓&q= {{q}}"
          },      
      "#PY2": {
        "type": "group",
        "caption": "python2 general search",
        "banglist": [
          "!python27",
          "@ipynbViewer"]}
}
]

There are 4 types of request :
* duckduckgo : a bang style duckduckgo search request, you have to give a valid !bang * qwant : a qwick style qwant search request, you have to give a valid &qwick * custom : any kind of site or search engine, google i.e., {{q}} will be replace by your search * hidden : a custom request which doesn't appear in the quick panel (can be use in command arg, or group call) * group : a list of bang [duckduckgo|custom|hidden] defined in your bang-search.sublime-settings

You can edit the settings by going to Preferences -> Package Settings -> Bang Search -> Settings - User

Browser configuration

The lib used to open a new tab is webbrowser.py. Only the first element of browsers_list will be used, the others are here to allow quick change in your configuration file. The “default” value refer to the None settings in webbrowser.py corresponding to the default browser.

THE FOLLOWING CONFIGURATION IS AT YOUR OWN RISK, let “default” if you have any doubt.

Identify already defined browsers by webbrowser.py

Open a console : View > Show console

And enter the following code to identify which browser you can use :

import webbrowser; print(webbrowser._browsers)

Register a browser in webbrowser.py

Open a console : View > Show console

And enter the following code to register a browser. Here is a sample for windows, you have to define an alias and the correct path to the choosed browser.

import webbrowser; webbrowser.register('google-chrome', None, webbrowser.BackgroundBrowser("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"))

Choose the browser for Bang-Search

In the bangsearch.sublime-settings, place your _default browser in first place in the list.

"browsers_list": ["firefox","default","google-chrome"],

Usage

Get the quick panel to choose your search query : - Place the cursor inside a word or select some text and press Alt+Super+B quick_panel

  • Press Ctrl+Super+B to get the input panel input_panel

Use a personal key binding with args search-method:

  • Launch directly the @def query from your selected text.
{
  "keys": ["shift+alt+super+b","shift+alt+super+d"], 
  "command": "bang_search",
  "args": {"search_method": "@def"}
},
  • Launch directly the @def query after opening the input text.
{
  "keys": ["ctrl+shift+super+b", "ctrl+shift+super+d"], 
  "command": "bang_search_input",
  "args": {"search_method": "@def"}
}

input_definition