Trigger Scripts directly from Raycast #1342
brianjohnpenner
started this conversation in
Share
Replies: 1 comment
-
Here's an updated version that gives a few more options. This lets you choose whether to create for all scripts, for a kenv, or just a specific script. Open generate-raycast-scripts in Script Kit // Name: Generate Raycast Scripts
import "@johnlindquist/kit"
const collect = await npm("collect.js")
// get the directory to store the scripts in. Save in an environment variable
const directory = await env("RAYCAST_SCRIPTS_DIRECTORY", async () => { return await selectFolder("Select a directory to store the scripts in") })
// get all the scripts from Script Kit
let scripts = collect(await getScripts())
// remove preview from scripts
scripts = scripts.map(script => {
delete script.preview
return script
})
const scope = await arg("Select a scope", ['all', 'kenv', 'script'])
switch (scope) {
case 'kenv':
let kenvs = scripts.pluck('kenv').unique()
kenvs = kenvs.map(kenv => {
return {
name: kenv === '' ? 'default' : kenv,
value: kenv
}
})
const selectedKenv = await arg("Select a kenv", kenvs)
scripts = scripts.where('kenv', selectedKenv)
break;
case 'script':
const selectedScript = await arg("Select a script", await scripts.pluck('name').unique().values().all())
scripts = scripts.where('name', selectedScript)
break;
}
// generate a script for each one in the directory
scripts.each(async script => {
const scriptContents = `#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title ${script.name}
# @raycast.mode silent
# @raycast.packageName Script Kit Scripts
# Documentation:
# @raycast.description ${script.description}
~/.kit/kar ${script.filePath}
`
await writeFile(`${directory}/${script.name}.sh`, scriptContents, "utf-8")
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since I use Raycast as my launcher on my computer I wanted a way to trigger Script Kit scripts directly from the Raycast menu without a second step. I made a script to generate Raycast shell scripts that will directly trigger the Script Kit scripts.
Just posting this as inspiration. This script is a little rough around the edges and could use refinement and customization to suit your needs.
Open generate-raycast-scripts in Script Kit
Beta Was this translation helpful? Give feedback.
All reactions