An environment manager for your shell.
.env file in your project with the environment variables you need.
$ cat .env RACK_ENV=development REDIS_URL=redis://127.0.0.1:6380
$ bs rackup -p 8080
This will run
rackup with your environment variables set.
If you want to drop to a new shell to work for a little while, just:
To restore the old environment, simply
Ctrl-D and go back to the parent
Sometimes you'll want to modify the environment of your current shell without
creating a new one (for instance, if your init scripts modify the environment
and overwrite what
bs is setting for you). That's easy to do:
$ source bs
Or the more cryptic:
$ . bs
We are long-time users of
gs. This small tool allows you to start a
shell (or run a command) within a specific gem set. And it does it beautifully
simply: by only setting a few environment variables which RubyGems will
honor. That's it.
Now Foreman is a gem, so it should be installed inside the application's gem
set. So, what if you need to run
irb inside a bare shell?
$ gs foreman run irb
We realized we could replace
gs by setting the appropriate variables in our
GEM_HOME=$(pwd)/.gs GEM_PATH=$(pwd)/.gs:$(gem env path) PATH=$(pwd)/.gs/bin:$PATH
Now we had everything in our
.env file and
foreman start would pick it
up. But there are a few problems:
We don't use Foreman in production (at least not yet), so our deploy scripts needed a simple way to also read
.envwithout needing the whole of Foreman.
Foreman itself is a gem, so you would need to install it in your global gem set.
Some people don't use Foreman at all.
We needed something simple, probably pure-shell, to read
.env and either run
a given command or drop to a new shell with the variables set (similar to how
bin/bs somewhere in your
$ brew tap educabilia/tooling $ brew install bs
All of the features are tested on Bash and Zsh. We'll happily take patches