Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created January 13, 2024 15:00
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/bcea234ae80c1cddde8c44c71c4fcea8 to your computer and use it in GitHub Desktop.
Save johnlindquist/bcea234ae80c1cddde8c44c71c4fcea8 to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
// prefer using the full path
let qalc = `/opt/homebrew/bin/qalc`
let currentValue = ""
await arg(
{
placeholder: "Qalculate",
enter: "Copy Result to Clipboard",
},
async input => {
let { stdout } = await exec(`${qalc} "${input}"`)
// yay for "at" 💪
currentValue = stdout.split("≈")?.at(-1)?.trim() || stdout.split("=")?.at(-1)?.trim() || stdout
// returning a string presents the "panel" (returning an array presents choices)
// using the markdown helper for basic padding
return md(`${stdout}`)
}
)
copy(currentValue)
exit() // Manually teardown in case "qalc" is still running for some reason
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment