Created
January 3, 2024 01:59
-
-
Save johnlindquist/331f00544f05134e4617603a6a4f4206 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" | |
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