knqyf263 / pet

Simple command-line snippet manager
MIT License
4.44k stars 223 forks source link

Adding environment variable management functionality #205

Closed RamiAwar closed 1 year ago

RamiAwar commented 2 years ago

This PR adds some environment variable management capabilities to pet. Does this by saving env vars in "snippets" that have a tag of [[env]] (piggybacking on the sync), and activating environments by spawning a new shell with those env vars set up there (activate command).

Not sure if this is a change that is wanted in Pet, but I'll be adding this functionality to my company's pet users since its something we really want.

Still missing some code to productionize this, but this PR is just to see if you're even interested in adding this to pet officially.

I also think this could be done in a more general way. I just coded it in the fastest way possible as I'm not looking to generalize this into anything else right now.

activate command newenv command editenv command listenv command

updated toml config

Usage:

$ pet activate   #  creates subshell with correct environment variables read from env.toml file
$ exit # goes back to parent shell