Created
September 12, 2012 11:29
Import heroku env
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
#!/usr/bin/env ruby -rubygems | |
reject_keys = %w(PATH STACK URL APP_NAME LOG_LEVEL) | |
reject_keys += %w(RACK_ENV RAILS_ENV NODE_ENV) | |
reject_keys += %w(COMMIT_HASH CONSOLE_AUTH LANG LAST_GIT_BY) | |
reject_keys += %w(REDISTOGO NEW_RELIC DATABASE MONGOHQ MEMCACHE SENDGRID) | |
reject_keys += (ENV['REJECT_ENV_KEYS'].nil? ? [] : ENV['REJECT_ENV_KEYS'].split(',')) | |
keys_regexp = %r/#{reject_keys.join('|')}/i | |
configuration = `heroku config`.split("\n").inject({}) do |hash, line| | |
match = line.match(/^([A-Z_0-1]+):\s+(.+)/) | |
hash[match[1]] = match[2] if match | |
hash | |
end | |
configuration.reject! { |key| key.match(keys_regexp) } | |
configuration.each { |key, value| | |
STDOUT << "#{key}=#{value}\n" | |
} |
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
function heroku_env() { | |
~/.dotfiles/heroku_env | | |
while read env ; do | |
export $env; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment