Environment Variables

Read and Write from ~/.kenv/.env

The env helper will read environment variables from ~/.kenv/.env. If the variable doesn't exist, it will prompt you to create it.

// Name: Env Example
import "@johnlindquist/kit"
let KEY = await env("MY_KEY")
await div(md(`You loaded ${KEY} from ~/.kenv/.env`))

Open env-example in Script Kit

Choose an Environment Variable

If you pass a function as the second argument to env, it will only be called if the variable doesn't exist. This allows you to set Enviroment Variables from a list, an API, or any other data source.

// Name: Choose an Environment Variable
import "@johnlindquist/kit"
let MY_API_USER = await env("MY_API_USER", async () => {
return await arg("Select a user for your API", [
await div(
`You selected ${MY_API_USER}. Running this script again will remember your choice`

Open choose-an-environment-variable in Script Kit

Discuss Post