Skip to content

Instantly share code, notes, and snippets.

Last active Jun 11, 2018
What would you like to do?
Some simple oneliners that make working with Heroku easier
# A collection of snippets for managing Heroku env vars
# It ain't pretty but it works
# Copy Heroku config to a local .env file
heroku config --app $HEROKU_APP | sed 's/: */=/' | tail -n +2 | tee $ENV_FILE
# Set a Heroku app's config from a local env file
# I got this oneliner from a blog somewhere, can't find it again
heroku config:set --app $HEROKU_APP $(cat .env | sed '/^$/d; /#[[:print:]]*$/d')
# Set a Heroku app's config from another Heroku app's config
heroku --app $HEROKU_APP config:set $(heroku config --app $HEROKU_APP_ORIGIN | sed 's/: */=/' | tail -n +2)
# Take a diff between two heroku configs (without messing around with temp files)
# Vimdiff is just what I prefer, any diff program which two files as input parameters will work
vimdiff <(heroku config --app $HEROKU_APP_ORIGIN) <(heroku config --app $HEROKU_APP)
# Locally run a process using a Heroku app's config (without copying to a temp file)
# If you wish to modify any of the config vars put them at the location of EXAMPLE_OVERRIDE=true
env $(heroku config --app $HEROKU_APP | sed 's/: */=/' | tail -n +2 | xargs) EXAMPLE_OVERRIDE=true node index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment