Skip to content

Instantly share code, notes, and snippets.

@unixcharles
Created September 12, 2012 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unixcharles/3706062 to your computer and use it in GitHub Desktop.
Save unixcharles/3706062 to your computer and use it in GitHub Desktop.
Import heroku env
#!/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"
}
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