Skip to content

Instantly share code, notes, and snippets.

@rafbm
Created November 7, 2012 00:35
Show Gist options
  • Save rafbm/4028734 to your computer and use it in GitHub Desktop.
Save rafbm/4028734 to your computer and use it in GitHub Desktop.
Language/framework agnostic support for per-project environment variables
#!/usr/bin/env ruby
command = ARGV.join(' ')
begin
env = File.read("#{Dir.pwd}/.env")
lines = env.strip.split("\n").reject{ |line| !line.match(/^\w+=/) }
variables = lines.join(' ')
exec "#{variables} #{command}"
rescue
exec command
end
__END__
Stick your environment variables in a “.env” file in your project root, like this:
FOO=bar
BAZ=qux
Prefix your usual command with “envy ”, like this:
envy bundle exec rails s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment