Created
January 2, 2024 22:09
-
-
Save johnlindquist/c6ff34c0af6775d2d77b5f0d784f6556 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: GitHub Karabiner Examples | |
import "@johnlindquist/kit" | |
import express from "express" | |
let app = express() | |
let recentsPath = kenvPath("recent", "queries.txt") | |
let recentsContent = await ensureReadFile(recentsPath) | |
let recents = recentsContent.split("\n").filter(r => r.length > 0) | |
const OPEN_RECENTS = "Open recents.txt" | |
let choices = groupChoices( | |
[ | |
...recents.map(r => ({ name: r, group: "Recent", value: r })), | |
{ | |
name: OPEN_RECENTS, | |
group: "Actions", | |
value: OPEN_RECENTS, | |
}, | |
], | |
{ | |
order: ["Recent", "Actions"], | |
} | |
) | |
let query = await arg( | |
{ | |
placeholder: "Enter what you want to find in a karabiner.edn file:", | |
strict: false, | |
}, | |
choices | |
) | |
await dev(query) | |
if (query === OPEN_RECENTS) { | |
await edit(recentsPath) | |
exit() | |
} | |
await writeFile(recentsPath, query + "\n" + recentsContent) | |
let url = `https://github.com/search?q=${query}++path%3A**%2Fkarabiner.edn&type=code` | |
open(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment