Created
September 7, 2011 18:34
-
-
Save enthooz/1201334 to your computer and use it in GitHub Desktop.
Automatically Change Heroku Accounts for Different Projects
This file contains 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
heroku accounts:set ACCOUNT_NAME |
This file contains 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
__load_cdrc() # called from .rvm/scripts/cd | |
{ | |
local working_dir | |
working_dir="${1:-"$PWD"}" | |
if [[ -f "$working_dir/.cdrc" ]]; then | |
echo "Loading .cdrc..." | |
source "$working_dir/.cdrc" | |
fi | |
} |
This file contains 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
__rvm_after_cd() | |
{ | |
rvm_hook="after_cd" | |
source "${rvm_scripts_path:-"$rvm_path/scripts"}/hook" | |
#__rvm_unset_exports | |
if type -t __load_cdrc -eq 'function' > /dev/null; then | |
__load_cdrc | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires that you first install the Heroku Accounts plugin (https://github.com/ddollar/heroku-accounts) and add an account to the plugin (
heroku accounts:add ACCOUNT_NAME
). After setting this up, you can create a.cdrc
file in any directory which will be run as a shell script upon entering that directory. One pitfall is that the.cdrc
file also loaded after runningcd ..
which is often unnecessary..rvm/scripts/cd
to call a__load_cdrc
function if it has been defined. Find the__rvm_after_cd
function and add the last three lines in the function as shown above.__load_cdrc
function in~/.profile
to load a.cdrc
file in the current directory if it exists..cdrc
file including the following line.