Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created January 2, 2024 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlindquist/c6ff34c0af6775d2d77b5f0d784f6556 to your computer and use it in GitHub Desktop.
Save johnlindquist/c6ff34c0af6775d2d77b5f0d784f6556 to your computer and use it in GitHub Desktop.
// 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