Skip to content

Instantly share code, notes, and snippets.

@ammarnajjar
Created October 12, 2022 08:00
Show Gist options
  • Save ammarnajjar/5b060c939760ede703f485c2aaee9c4d to your computer and use it in GitHub Desktop.
Save ammarnajjar/5b060c939760ede703f485c2aaee9c4d to your computer and use it in GitHub Desktop.
parse yml to envs and source it in the running shell
# 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