Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
Former Member
3 years agoPopulate environment variable for active shell session
I am trying to use op to set environment variable for my active shell session. Instead of hardcoding something like export MYSECRET=sosecret , I would rather populate the environment variable thro...
Former Member
3 years agoHey @dnsstaiger, thank you for reaching out to us!
We are currently working on some native way to achieve this with the CLI, so stay tuned for the next releases!
In the meantime, there is a workaround for this: you can move your direnv
environment variables to a .env
file, replace their values with secret references, and start a privileged session, with access to these secrets, using op run --env-file .env -- $SHELL
. Please do mind that you'll need to explicitly terminate this session (exit
) at the end of it, in order to de-populate the environment.
Another possibility is using direnv in conjunction with op run
: adding envvars with secret references in your .envrc
, and starting a privileged session from within the directory. In this case there would be no need for a .env
file, since the envvars in question are in your session environment: op run -- $SHELL
. Once again, please do proceed with caution and exit the privileged shell once access to the secrets is no longer needed.
Please let us know if this helps. This process is a bit cumbersome at the moment, so we hope you'll try the native CLI approach, once it comes out.
We're looking forward to hearing from you!
Best,
Horia