Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created January 3, 2024 01:59
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/331f00544f05134e4617603a6a4f4206 to your computer and use it in GitHub Desktop.
Save johnlindquist/331f00544f05134e4617603a6a4f4206 to your computer and use it in GitHub Desktop.
// Name: GitHub Karabiner Examples
import "@johnlindquist/kit"
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,
// value: OPEN_RECENTS,
// },
]
// {
// missingGroupName: "Actions",
// order: ["Recent", "Actions"],
// }
)
choices.unshift({
info: true,
miss: true,
name: "Search for {input} on GitHub",
})
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()
}
query = query.replaceAll(/ /g, "+")
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