New Project: bm (WIP)
As described in the blog
entries about browser-base, I ended up working on some
browser-related projects this month due to usability issues after a
Firefox upgrade. I decided to go ahead and implement a new version of a
browser home page that I used to use many years ago,
browser-base
. The page displays whenever you open a new
tab, and you can use the keyboard to quickly open links or perform
searches. Unfortunately, Firefox no longer supports custom “new tab
pages” and extensions that provide the necessary functionality have many
usability issues due to limitations imposed by Firefox for security
purposes, so I aborted the project.
Since Firefox can no longer do what I want, I decided to write a
program that works outside of the browser. bm is a program
that can open bookmarks and search queries from the command line. I can
use it in my terminal, from within Vim (:!bm ...
), as well as
with dmenu.
Bookmarks and search queries are configured in a YAML configuration file. Here is an excerpt from my configuration file:
---
command: firefox
args:
- keyword: ddg
url: https://duckduckgo.com
query:
action: https://duckduckgo.com/
- keyword: nix
url: https://nixos.org/
args:
- keyword: manual
url: https://nixos.org/manual/nix/stable
- keyword: os
url: https://nixos.org/manual/nixos/stable
- keyword: pkgs
url: https://github.com/NixOS/nixpkgs
args:
- keyword: manual
url: https://nixos.org/manual/nixpkgs/stable
The command used to open links defaults to general commands according
to the operating system (Linux, Windows, macOS). It can optionally be
set in the configuration file. As shown above, I set my configuration to
use firefox
directly (instead of xdg-open
)
because it is faster.
The program usage is (currently) as follows:
Usage: bm [-c|--config CONFIG] [-t|--trace] ARG [ARG ...]
open bookmarks and search queries from the command line
Available options:
-h,--help show this help text
--version show version and exit
-c,--config CONFIG config file (default: $XDG_CONFIG_HOME/bm.yaml)
-t,--trace show trace output for debugging
ARG [ARG ...] arguments
With this configuration, running bm ddg
opens DuckDuckGo in a new tab. Prefixes are
supported, and the first matching prefix is used, so bm d
does the same thing. The Nix section demonstrates how bookmarks can be
organized into hierarchies. Running bm nix pkgs
opens the
nixpkgs repository in a
new tab, while running bm n p m
opens the nixpkgs Manual in a
new tab.
Notice that a query is also defined. Running
bm ddg haskell LambdaCase
opens a new tab with a search for
“haskell
LambdaCase”. The parameter name as well as additional parameters can
be specified when required. I configure a keyword named /
in my configuration with my default search engine so that I can search
by running bm / haskell LambdaCase
. The keyword is one
character, and I will not have to change habits if I change my preferred
search engine.
The --trace
option is just used for debugging. Here is
an example:
$ bm -t n p m
[firefox]
<nix>
<pkgs>
<manual>
firefox https://nixos.org/manual/nixpkgs/stable
This project is a work in progress. (You can see my TODO
list in the develop
branch.) I hope to make a first release
next week.