Easy way to switch between Cloudflare wrangler profiles
Include wrangler-env in your bash profile config (~/.profile, ~/.bash_profile, or ~/.bashrc) by adding:
# Wrangler Profile Switcher
export CF_WRANGLER_PROFILES=~/.wrangler/profiles
. ~/bin/wrangler-env
Your profiles should look like the following (~/.wrangler/profiles/)
CF_ACCOUNT_ID=489357394578903450293482034
CLOUDFLARE_API_TOKEN=alisdfj8234rjasdlfija80234jr0asjf45rqR@#$RW
You can acquire these from your cloudflare dashboard under: dash.cloudflare.com/profile/api-tokens
Your account ID is likely under the Workers->Overview
After that you can use it with: wrangler-switch <profile name>
Note: If you have fzf installed you don't have to supply a profile name and it will get you a list of profiles to select
By default it will load the profile set in CF_WRANGLER_PROFILES/default at the shell initialization.
Other commands are:
wrangler-unsetwill unset the env variables being set to the defaultwrangler-listwill list all of the profiles in your profile directory (CF_WRANGLER_PROFILES)wrangler-whoshows the current profile being set