Skip to content

Instantly share code, notes, and snippets.

@JosXa
Created March 14, 2025 00:34
Show Gist options
  • Save JosXa/b614d14deaef4a087c3188544ea198f8 to your computer and use it in GitHub Desktop.
Save JosXa/b614d14deaef4a087c3188544ea198f8 to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
import type { Choice } from "@johnlindquist/kit"
import gis from "g-i-s"
const query = await arg("Enter image search term")
const images = await new Promise<any[]>((resolve, reject) => {
gis(query, (error, results) => {
if (error) {
reject(error)
} else {
resolve(results)
}
})
})
const choices = images.map((image) => ({
name: image.url,
value: image.url,
preview: `<img class="w-full" src="${image.url}" />`,
onSubmit: async () => {
await copy(image.url);
}
} satisfies Choice))
const imageUrl = await arg("Pick an image", choices)
console.log(`Selected image URL: ${imageUrl}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment