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 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
| heroku accounts:set ACCOUNT_NAME |
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
| __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 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
| __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 | |
| } |
Author
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.cdrcfile in any directory which will be run as a shell script upon entering that directory. One pitfall is that the.cdrcfile also loaded after runningcd ..which is often unnecessary..rvm/scripts/cdto call a__load_cdrcfunction if it has been defined. Find the__rvm_after_cdfunction and add the last three lines in the function as shown above.__load_cdrcfunction in~/.profileto load a.cdrcfile in the current directory if it exists..cdrcfile including the following line.