Last active
August 29, 2015 14:02
-
-
Save dmikusa/adf36c6fcc5c5b97bdc8 to your computer and use it in GitHub Desktop.
A handy function that you can add to your profile for managing connections to different CloudFoundry instances.
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
function cfenv () { | |
function curenv () { | |
if [ "$1" == "" ]; then | |
CURENV="default" | |
else | |
CURENV="$(echo "$1" | cut -d '-' -f 2)" | |
fi | |
} | |
function listenvs () { | |
echo "Listing available environments..." | |
for folder in $HOME/.cf*; do | |
environment=$(echo "$folder" | cut -d '-' -f 2) | |
if [ "$environment" == "$HOME/.cf" ]; then | |
environment="default" | |
fi | |
echo " $environment ($folder)" | |
done | |
} | |
function setenv () { | |
if [ "$1" == 'default' ]; then | |
export CF_HOME= | |
else | |
export CF_HOME="$HOME/.cf-$1" | |
fi | |
} | |
if [ "$1" == '' ]; then | |
listenvs | |
else | |
setenv "$1" | |
fi | |
curenv "$CF_HOME" | |
echo "Current environment is [$CURENV]" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment