Home

Awesome

PowerToys-Run-WebSearchShortcut

Mentioned in Awesome PowerToys Run Plugins

This is a simple PowerToys Run plugin for quickly selecting a specific search engine to perform searches via keyword prefixes.

Preview

Preview of the plugin in action

If you have configured the Keyword field, you can use a short keyword to specify the search engine.

Example of the Keyword field

Requirements

Installation

[!IMPORTANT] Some users are currently experiencing application crashes when using the WebSearchShortcut after disabling the WebSearch (an integrated plugin of PowerToys Run). It is recommended to keep WebSearch enabled until the issue is resolved. #23

Configuration

Open the configuration file with "!config"

Note: The configuration file is located in %LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Community.PowerToys.Run.Plugin.WebSearchShortcut\WebSearchShortcutStorage.json.

Reload the configuration file with "!reload"

Example

{
  "Google": {
    "Url": "https://www.google.com/search?q=%s",
    "SuggestionProvider": "Google"
  },
  "Bing": {
    "Url": "https://www.bing.com/search?q=%s",
    "SuggestionProvider": "Bing"
  },
  "GitHub": {
    "Url": "https://www.github.com/search?q=%s"
  },
  "GitHubStars": {
    "Url": "https://github.com/stars?q=%s",
    "Keyword": "gs"
  },
  "StackOverflow": {
    "Url": "https://stackoverflow.com/search?q=%s",
    "Keyword": "st"
  },
  "npm": {
    "Url": "https://www.npmjs.com/search?q=%s"
  },
  "YouTube": {
    "Url": "https://www.youtube.com/results?search_query=%s",
    "Keyword": "yt"
  },
  "ChatGPT": {
    "Url": "https://chat.openai.com/?q=%s",
    "Keyword": "gpt"
  }
}

Configuration fields

Url

The URL template for performing the search. Use %s as a placeholder for the search query. If the URL does not contain %s, the URL will be opened directly when you press enter.

{
  "Google": {
    "Url": "https://www.google.com/search?q=%s"
  }
}

Note: To use multiple URLs, you can separate them with a space (" "). For example:

{
  "GoogleAndBing": {
    "Url": "https://www.google.com/search?q=%s https://www.bing.com/search?q=%s"
  }
}

Alternatively, you can use an array of URLs with the Urls field.

Urls

Urls is an alias for Url, supporting the setting of multiple URLs in an array format.

{
  "GoogleAndBing": {
    "Urls": ["https://www.google.com/search?q=%s", "https://www.bing.com/search?q=%s"]
  }
}

Keyword

Used to quickly select the target search engine using a short keyword.

{
  "Google": {
    "Url": "https://www.google.com/search?q=%s",
    "Keyword": "g"
  }
}

IconUrl

You can customize the icon by setting this field. Under normal circumstances, you don't need to set this, as the plugin will automatically download the favicon of the website corresponding to the Url field. However, sometimes you might want to customize the icon, and this field comes in handy.

Note: This field can only be set to a network URL and cannot be set to a local file.

IsDefault

If this option is true, the corresponding search engine does not need to input the trigger word.

ReplaceWhitespace

With ReplaceWhitespace, you can specify which character(s) to replace a space with when performing a search. This is useful for some websites, such as Wikipedia, which don't use plus signs ("+") to separate words in the URL.

ValueResult
" " or ""Example+search
"-"Example-search
"_"Example_search
"+"Example%2Bsearch

Note: As the string is converted to a URL, any spaces in the string (or ReplaceWhitespace) will be replaced with plus signs. Any other characters that are not allowed in a URL will be encoded with percent-encoding.

SuggestionProvider

Used to set the search suggestion provider.

The currently supported search suggestion providers are:

PRs welcome!

You can also set a Provider to another search engine. For example:

{
  "StackOverflow": {
    "Url": "https://stackoverflow.com/search?q=%s",
    "SuggestionProvider": "Google"
  }
}

Credits

Thanks

Thank you to @thatgaypigeon for writing the excellent documentation!

License

MIT License © 2023 Riri