-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helper function to handle .env files #69
Comments
Yes, files are loaded regardless of how you I suggest having a single You can use something like the following then: local root=${autoenv_env_file:h}
if [[ $autoenv_event == 'enter' ]]; then
autoenv_source_parent
(( $+functions[zsh_setup_pyenv] )) && zsh_setup_pyenv
local envdir=$root/envdir
autostash PATH=$root/bin:$PATH
# Simulate "envdir envdir $SHELL".
# echo "Exporting env from $envdir."
for i in $envdir/*~*.*(.); do
# echo "Exporting $i:t"
# eval "export ${i:t}='$(<$i)'"
eval "autostash ${i:t}='$(<$i)'"
done
autostash alias pi='p --dynamodb-test-url http://localhost:9000/'
fi Using Check out If you feel that the doc can be improved, a PR for this is welcome of course. |
Thanks @blueyed for your reply. Sorry I couldn't understand the code & also can you explain how to use this code. I have gone through Variable stashing & it did work but first for every Thanks once again |
You would put the code from above in an You would have to read that and apply |
Yes, you can check this https://github.com/laravel/laravel/blob/master/.env.example also in other languages like nodejs or go all uses in this format
Yes I can put the code above but my php package that's also reading
sounds good |
I think I have the same question as OP where I would like to convert this if [[ $autoenv_event == 'enter' ]]; then
if [[ -f .env ]]; then
autostash $(sed '/^#/d' .env | xargs)
fi
fi Is there a recipe to getting this behavior for any subdir of |
After seeing the docs I am not fully clear so I am asking this question.
I have a .env or *.env files e.g production.env or local.env in a repository where my different configs & credentials stored. I am looking for whenever I
cd
into that directory I want to load my all*.env
files or at least.env
file & when I move to parent directory it will restore the previous values of env variable that was modified e.gPATH
variable & will remove the other ones that were added.I am using oh-my-zsh I have tried autoenv but that didn't work also I saw a comment from this repos contributor @blueyed hyperupcall/autoenv#30 (comment) where he says this unload feature is available in this project.
Also in oh-my-zsh when we type a directory & press enter & it just
cd
into that directory, no need to typecd
in oh-my-zsh. So is it already implemented to load.env
files without usecd
just typing the directory name & going into the directory.Thanks
The text was updated successfully, but these errors were encountered: