nixos-config/users/home-manager/foo-dogsquared/config/bin/generate-bangs
Gabriel Arazas 3a022a374a Restructure the modules
I think this is better for separating modules explicitly. This is also
considered as there are similar objects between modules (e.g., NixOS
and home-manager modules and users).

Revert users module to old position
2021-12-06 17:03:39 +08:00

24 lines
781 B
Plaintext
Executable File

#!/usr/bin/env nix-shell
#! nix-shell -i oil -p coreutils curl jq
# Generate the config with Duckduckgo bangs.
# Very useful if you really want just to search as you would in Duckduckgo.
const bang_url = "${BANGS_URL:-https://duckduckgo.com/bang.js}"
const config = {}
# We still have to use some external tools like jq since Oil doesn't support nested objects yet.
# For more information, see https://github.com/oilshell/oil/issues/741
curl --silent --location $bang_url | jq 'sort_by(.t) | .[]' --raw-output --compact-output --sort-keys | while read --line {
write -- $_line | json read :bang
var _data = {}
var trigger = bang['t']
setvar _data['name'] = bang['s']
setvar _data['url'] = bang['u']
setvar config[trigger] = _data
}
json write :config