cfenv, inspired by cf shell helper

Skip to first unread message

Ben Hale

Jun 2, 2014, 11:57:24 AM6/2/14
After reading Dan's post about cf shell helper last Friday, I was inspired.  Actually, I became a bit obsessed by the idea of switching Cloud Foundry environments.  On a daily basis I work across 3 instances of Cloud Foundry, in at least 5 different spaces so running cf api, cf login, and cf target, is a way of life and not one I'm particularly fond of.  Immediately upon seeing his work, I recognized how similar it was to another tool I use on a daily basis, rbenv.  So this weekend I forked rbenv, created cfenv, and am happy to announce it today.

cfenv is a way of managing multiple Cloud Foundry environments simultaneously, using a series of CF_HOME directories. It allows you to choose the Cloud Foundry environment at a global level (using a ~/.cfenv/environment file), at a project level (using a .cf-environment file), or in a particular shell (using a CFENV_ENVIRONMENT environment variable).  An example of how I might use cfenv:
  1. Most of the day I spend pushing to my own development environment.  Therefore I've run cfenv global development to ensure that by default I use
  2. Whenever I work on the java-buildpack-system-tests I want to push to our system test environment.  Therefore, I've gone into that project's directory and run cfenv local system-test to ensure that I always push into
  3. Occasionally I need to push to a copy of Cloud Foundry installed using bosh-lite to test offline buildpack behavior.  When that happens I run cfenv shell bosh-lite to ensure that I push to without affecting any other shells.
Suffice it to say, if you're familiar with how rbenv works, you'll feel right at home with cfenv.  Please see the installation instructions for how to install it (and its close relative cf-build), but for OS X Homebrew users, TL;DR:

$ brew tap nebhale/personal
$ brew install cfenv cf
$ echo
'eval "$(cfenv init -)"' >> ~/.bash_profile
$ source ~/

$ cfenv create development
$ cfenv
global development
$ cf login

Please note that this project is not, in any way, associated with Pivotal or my day job working on the Cloud Foundry Java Experience; this is just something I've put together, and will be supporting, in my spare time.

Once again, a huge thanks goes out to Dan Mikusa for highlighting the issue and a possible path to solving it.  Hope you guys find cfenv as useful as I do.

-Ben Hale

Mike Youngstrom

Jun 2, 2014, 5:37:00 PM6/2/14
Nice!  I may make use of this.  Thanks Ben.


You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit

To unsubscribe from this group and stop receiving emails from it, send an email to

Christopher Ferris

Jun 4, 2014, 9:03:23 PM6/4/14

- Chris

Reply all
Reply to author
0 new messages