Skip to content

Instantly share code, notes, and snippets.

View BeSpunky's full-sized avatar

Shy Agam BeSpunky

View GitHub Profile
// Name: Show Scraped Apartments
import '@johnlindquist/kit';
import { Choice } from '@johnlindquist/kit';
import { z } from 'zod';
const ScrapedItemSchema = z.object({
id: z.string(),
address: z.string(),
neighborhood: z.string().optional(),
@BeSpunky
BeSpunky / kenvs.md
Last active May 10, 2023 22:01
Script Kit Kenvs Guide

Script Kit Kenvs

Concepts And Terminology

A kenv, short for kit environment, in Script Kit is a directory containing a scripts directory, allowing the Script Kit application to identify where to look for scripts. This term comes from the idea of project environments in other languages like Python (pyenv) and Ruby (rbenv).

While a kenv only requires a scripts directory, other directories like lib, db, logs, etc. can be included for organization and utility purposes. These are not mandatory and depend on the user's preferences and needs. However, once Script Kit identifies the scripts in a scripts directory, it can watch, build, and run scripts while generating relevant materials like database files, logs, and so on.

// Name: Screen OCR
// Description: Capture a screenshot and recognize the text using tesseract.js
import '@johnlindquist/kit';
import { captureScreenshotToFile, enumarateDisplays } from '../lib/os';
import { recognizeText } from '../lib/image-processing';
const display = await arg('Select a display:', (await enumarateDisplays()).map(({ id, name }) => ({ name, value: id })));
const tempFile = kenvPath(`/tmp/screenshot-${ Date.now() }.png`);
// Name: Self Care Reminder
// Description: This script will remind you to take a break from the computer every now and then.
// Schedule: 0,30 */2 * * *
import { getRandomItemFromArray } from '../lib/utils';
notify({
title: "🥰 Self Care Reminder",
message: getRandomItemFromArray((await db('well-being')).data.selfCareReminders)
});
@BeSpunky
BeSpunky / _\multi-select-example.ts
Created May 7, 2023 20:13
ScriptKit Script: Selected Scripts
// Name: Multi-Select Example
// Author: Shy Agam
// Twitter: @shyagam
// GitHub: https://github.com/BeSpunky
import "@johnlindquist/kit"
import { multiArg } from '../lib/ui'
import { identity, scriptChoices } from '../lib/utils';
const choices = await scriptChoices({ valueAs: 'command' });
@BeSpunky
BeSpunky / _\watch-scripts.ts
Created May 5, 2023 22:34
ScriptKit Script: Watch scripts and run a partial rebuild of the dependency graph when a script is changed.
// Name: Watch Scripts
// Description: Watch scripts and run a partial rebuild of the dependency graph when a script is changed.
// Watch: ./*.ts
// Author: Shy Agam
// Twitter: @shyagam
import "@johnlindquist/kit"
const triggeringFile = await arg();
@BeSpunky
BeSpunky / _\update-scripts-dependency-graph.ts
Last active May 6, 2023 08:59
ScriptKit Script: Creates a graph of scripts which are dependent on each ts file in the lib folder.
// Name: Update Scripts Dependency Graph
// Description: Creates a graph of scripts which are dependent on each ts file in the lib folder.
import '@johnlindquist/kit';
import { ensureIsTsFilePath } from '../lib/utils';
import { ScriptDependencyGraphManager } from '../lib/dependency-graph';
const triggeringFile = await arg({
strict: false,
placeholder: `Full path to ts file`,
@BeSpunky
BeSpunky / _\watch-libs.ts
Created May 5, 2023 21:25
ScriptKit Script: Watch libs and run a partial rebuild of the dependency graph when a lib file is changed, then trigger update of dependant scripts.
// Name: Watch Libs
// Description: Watch libs and run a partial rebuild of the dependency graph when a lib file is changed, then trigger update of dependant scripts.
// Watch: ../lib/**/*.ts
// Author: Shy Agam
// Twitter: @shyagam
import "@johnlindquist/kit"
import { ensureIsTsFilePath } from '../lib/utils';
import { ensureIsWatchChangeEvent } from '../lib/utils';
import { ScriptDependencyGraphManager } from '../lib/dependency-graph';
@BeSpunky
BeSpunky / _\gist-it.ts
Created May 5, 2023 21:17
ScriptKit Script: Creates a gist of the selected script and its lib dependencies.
// Name: Gist It
// Description: Creates a gist of the selected script and its lib dependencies.
// Author: Shy Agam
// Twitter: @shyagam
// GitHub: https://github.com/BeSpunky
import '@johnlindquist/kit';
import { extractDependenciesRecoursively, toLibFilePath } from '../lib/dependency-graph';
import { scriptChoices } from '../lib/utils';
import { TsFilePath } from '../lib/types/paths.types';