Created
November 7, 2012 00:35
-
-
Save rafbm/4028734 to your computer and use it in GitHub Desktop.
Language/framework agnostic support for per-project environment variables
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 | |
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