summaryrefslogtreecommitdiff
path: root/search.ha
AgeCommit message (Collapse)Author
2025-12-26Initial commitmainMatthew Fennell
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/