Created
January 13, 2024 15:00
-
-
Save johnlindquist/bcea234ae80c1cddde8c44c71c4fcea8 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
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