Tuesday, December 22, 2020

Managing Multiple Heroku Accounts

Let's say you have multiple accounts on Heroku for whatever reason, maybe some personal, some business.

When using heroku-cli, it expects you to basically always be signed in to only one account, meaning you have to keep logging in and jumping back and forth between different accounts via heroku login. It's kind of annoying.

I took ten minutes today to write a shell script called herotate which manages your heroku-cli active login file, a hidden file called .netrc in your home directory.

The script will move this file into a configuration directory and create a symlink to it, so all your heroku stuff will work as it normally does. When you want to add a different account, simply herotate unlink, and sign into a new account. 

 To make things even faster, you can manage multiple configurations inside of herotate as long as they all have different file names and live in the same configuration directory, which the script will echo out to you if you run it. By default, your config is named main but you can rename it and the tool will automatically continue to populate the directory with any new .netrc files.

You can symlink a config of your choosing at any time using >herotate link <config> and list all of your configs using herotate list.

Hopefully this simple script helps you manage multiple heroku-cli logins just like it helped me!

Stay tuned!

========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?

Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com

Follow my Facebook Page
Check out my code on GitHub
=========================