This came out of playing around with curl and the Lemmy API. I wanted a repeatable way to declare a bunch of shell parameters from a json object, so I wrote a jq module! Take a look at the README for examples, or once you install, run

source <( curl 'https://programming.dev/api/v3/community?id=267' | jq -r 'import "shell" as shell; .community_view | shell::param' )

Currently this project only provides a param function, and only supports Bash and Zsh. If I think of other useful helper functions, I may add them to the project.

This uses _ as a default prefix for each parameter. This is so things like {"PATH": "..."} generate typeset _PATH='...' and don’t mangle your $PATH, for example. The prefix can be customized by passing in a string: param("mypfx").

Before declaring a 1.0, I’m planning on expanding shell support, and have the function determine how to output using the the $SHELL parameter:

# This does not work (yet!)
eval (curl $URL | jq -r '
  import "shell" as shell;
  "fish" as $SHELL |
  .community_view | param
')

Always up for feedback!