sefr (Search Engine FRontend)
Terminal program for interactively opening search engines / parametric URLs.
It's kinda like surfraw but with interactive suggestions (via parsing opensearch json).
I use custom url bar search engines a lot, but browser support for them is frustrating.
- Firefox has a really obtuse way of defining them, doesn't let you specify suggestion endpoints, and still doesn't sync them.
- Chrome makes defining them easy, syncs them, but doesn't let you specify suggestion endpoints.
- Vivaldi makes defining them easy, lets you specify suggestion endpoints, but doesn't sync them.
e.g. in stock Firefox, you can't create a search engine that, when you type "r foo" in your url bar, automatically goes to "reddit.com/r/foo". You have to manually write the URL, and you don't even get completions!
This is meant to be a customizable crossplatform solution, and since it uses your default browser (more details), I hope to fit it into my workflow with a global keybinding.
There are two ways to install
- Clone this repository, install the Rust toolchain, and either call
cargo runin the cloned directory to try it out, or
cargo buildto create a binary located at
- Install via cargo by calling
cargo install sefr. This should make it runnable from anywhere.
On its first startup,
sefr will automatically generate a TOML configuration file in the config directory provided by the directories crate. Any subsequent changes should be made inside it.
e.g. For Linux, the config file will be found in
Adding new engines
Warning: The current configuration format might be changed in the future!
New engines can be added for use by
sefr by adding them to the
A basic engine definition looks like this:
[engines.yt] name = "YouTube" search_url = "https://www.youtube.com/results?q=%s" suggestion_url = "http://suggestqueries.google.com/complete/search?client=firefox&ds=yt&q=%s"
[engines.PREFIX]defines what prefix (also known as a keyword or trigger) activates the engine.
nameis the name of the engine, used for the prompt text if not defined in the prompt section (more on that later).
search_urlis opened in your browser with
%sreplaced by the search term when enter is pressed.
suggestion_url(optional) is the endpoint queried for suggestions (with
%sreplaced by the search term) while typing. It must return OpenSearch suggestions schema json.
+by default) is what spaces are replaced with before
search_urlis opened. In the default config:
engines.wkthas it set to
_, because that's how Wiktionary (and Wikis in general) encode spaces in their URLs.
engines.rhas it set to a blank string, because subreddits can't have spaces in their names (note that this value prevents spaces from being entered into the input buffer when the engine is selected so that space can be used to select a suggestion without performing a search).
The engine used when no prefix is entered is defined as
_default in the config, and it is obligatory for the program to start. Example:
[engines._default] name = "Google" search_url = "https://www.google.com/search?q=%s" suggestion_url = "https://www.google.com/complete/search?client=chrome&q=%s"
Along with this, there is also an optional
prompt section which handles the prompt displayed when the engine is called. It will usually look like this:
[engines.yt.prompt] icon = " ▶ " icon_bg = "Red" icon_fg = "White" text = " Youtube " text_bg = "White" text_fg = "Black"
The following fields are supported, and all are optional:
icon: the icon displayed in the prompt
icon_bg: background color of the icon
icon_fg: foreground color of the icon
text: The text displayed after the icon in the prompt
text_bg: background color for the text
text_fg: foreground color for the text
text are padded with whitespace for aesthetics in the example configuration, but this is not required.
The fields are all strings except for colors (
*_fg). They can be strings (corresponding to the color names here), 8-bit numbers (corresponding to Ansi color codes), or 8-bit RGB tuples like
If this section is left out for a particular engine, a basic prompt displaying the engine's name will be used.
For the time being, keybindings are hardcoded and they can be found below:
Tab/Down/Ctrl-N=> Select next suggestion
Shift-Tab/Up/Ctrl-P=> Select previous suggestion
Ctrl-W=> Delete last word
Enter=> Perform selected search in browser
This project is currently in its alpha stage but is relatively stable.
- Suggestions request / json parse
- Definable engines with prefixes, prompts, and endpoints
- Browser launching
- Selection of suggestions w/ prefix edge cases
- TOML file config
- Use real cursor for rendering input buffer, and be able to move it
- Configurable keybindings
- Better feedback for when suggestion endpoints misbehave
- CLI args, e.g. providing the initial input buffer through an argument for aliasing.