Created
October 12, 2022 08:00
-
-
Save ammarnajjar/5b060c939760ede703f485c2aaee9c4d to your computer and use it in GitHub Desktop.
parse yml to envs and source it in the running shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires python3 | |
# replace <path> | |
source <(python <<EOF | |
with open('<path>', 'r') as fi: | |
content = fi.readlines() | |
trans = [line.strip().replace(': ', '=').replace('\'', '"') for line in content if line.strip() and line.strip()[0] != '#'] | |
envs = '\n'.join([f'export {line}' for line in trans]) | |
print(envs) | |
EOF | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment