From 94816ff64170092d4a1764c7f67fe926bac09d89 Mon Sep 17 00:00:00 2001 From: Matthew Fennell Date: Thu, 25 Dec 2025 19:06:54 +0000 Subject: Initial commit Create `search` - a command-line tool for printing query strings. Firefox has been my main browser for a long time, but as part of a push to move as much as of my computing as possible to the terminal, I've started experimenting with using terminal browsers first, and Firefox only for javascript-heavy web apps. For now, I have settled on `edbrowse` as the terminal browser. There is one feature I miss from Firefox though: "Search Shortcut"s. This lets you define particular search engines with which you would like to search. As Google have tightened the screws and SearxNG has gradually gotten worse, I've started creating different shortcuts for dedicated tasks) instead of using one search engine for everything. For instance, many wikis have decent enough search engines, allowing me to set up e.g. `@osmwiki opening hours`, `@debianwiki debian on mobile`, `@wikipedia list of have I got news for you episodes`, etc. `edbrowse` doesn't have any builtin search engine support, and by its nature it takes many keypresses to submit forms. So, in the spirit of the UNIX philosophy, this script reimplements that Search Shortcut feature on the command line. To use, you first need a search engine config file at `${XDG_CONFIG_HOME}/search/engines.conf`. You can find an example in its repository. [1] Once the tool has generated the URL for your query, there are three actions it can take with it: browser, copy or stdout. Browser (`-b`) opens `edbrowse` with the URL. Copy (`-c`) copies the URL to the clipboard. This is useful if you are already in an `edbrowse` session - simply run `!search -c [query]` then `b [paste]` and `edbrowse` will open the search results. Finally, stdout (the default if no other flags are passed) will simply print the URL to stdout. There are likely lots of problems with this script. It's my first program with Hare, and was developed in one sitting. There are almost certainly bugs, non-idiomatic flows and memory leaks too! There are also hardcoded defaults, such as references to `marginalia`, `edbrowse`, `wl-copy`, etc. However, it has already made my terminal browsing experience less painful! And I am happy that these browsers are much simpler and allow the easy interjection of such a small tool. [1] https://git.fennell.dev/search-config/ --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..62f421e --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +#!/usr/bin/make -f +# SPDX-FileCopyrightText: 2025 Matthew Fennell +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +/usr/local/bin/search: search.ha + reuse lint + hare test + hare build -o search + sudo mv search /usr/local/bin/ -- cgit v1.2.3