Switch .env environments
with one click.
EnvSwitcher is a macOS menu bar app. Enter your values one time. Choose local, test, or prod. The app writes all .env files in the project again.
$ curl -fsSL https://raw.githubusercontent.com/ahmetkorkmaz3/EnvSwitcher/main/install.sh | sh
Stop editing files by hand.
The app keeps the values of each environment. To change the environment, you click a menu item.
One-click switch
Choose an environment in the menu bar. The app writes the project files with the values of that environment.
Monorepo support
The app scans the folder and finds all .env files. The files change together or one at a time.
Secret values in the Keychain
Tokens, passwords, and keys stay in the macOS Keychain. They do not go into the settings file on disk.
Compare environments
See the values of a file side by side. Copy missing keys to the other environments with one click.
Paste from the clipboard
Copy KEY=value lines and paste them into an environment. Keys that look secret go to the Keychain.
Easy updates
When a new version is available, the menu shows a line. The install command is also the update command.
Start in three steps.
The first setup takes about 2 minutes.
-
Add the project
Choose Add Project… in the menu. Choose the folder or drag it into the window.
-
Import the values
Check the files that the app found. The app imports the current content into the
localenvironment. -
Choose the environment
Enter the
testvalues. In the menu, choose the project → All Files → test.
See a missing key before it goes live.
Each key has one row. The color of the row shows its status.
- Red: missing in an environmentType a value in the cell or copy it from a different environment.
- Orange: the values are differentCheck the values for each environment at a glance.
- Gray: the same in all environmentsUse the filter to hide these rows.
| Key | local | test | prod |
|---|---|---|---|
| APP_ENV | local | test | prod |
| API_URL | localhost:4000 | test.api.app | api.app |
| STRIPE_SECRET_KEY | •••• | •••• | missing |
| SENTRY_DSN | missing | •••• | •••• |
| LOG_LEVEL | info | info | info |
Your files stay safe.
The app checks the files before it writes them. If an error occurs, the files go back to their old contents.
Manual change check
If you changed a file in an editor, the app shows the difference. Save the change, discard it, or cancel.
All-or-nothing writes
If the app cannot write one file, the files it already wrote go back to their old contents.
Protected environments
Before you switch to a protected environment such as prod, the app asks for confirmation.
Empty environment warning
If the selected environment has no values for a file, the app asks first. Files do not become empty by accident.
Permissions stay the same
File permissions (for example 600) do not change. The app writes to the target of a symbolic link.
Git warning
If a .env file is not in .gitignore, the app shows a warning when you add the project.
Install with one command.
The command downloads the latest version, checks its SHA-256 value, installs it in /Applications, and opens the app.
# Install and update curl -fsSL https://raw.githubusercontent.com/ahmetkorkmaz3/EnvSwitcher/main/install.sh | sh # A specific version curl -fsSL https://raw.githubusercontent.com/ahmetkorkmaz3/EnvSwitcher/main/install.sh | ENVSWITCHER_VERSION=0.2.0 sh
Manual install
- Download
EnvSwitcher-X.Y.Z.zipfrom the Releases page. - Open the zip file. Move
EnvSwitcher.appinto/Applications. - Open the app. macOS shows the "Apple could not verify" warning. Click Done.
- Open System Settings → Privacy & Security. Click Open Anyway.
The app is not notarized, so a file from a browser download shows this warning. The install command does not show it.
Uninstall
osascript -e 'quit app "EnvSwitcher"' rm -rf /Applications/EnvSwitcher.app rm -rf ~/Library/Application\ Support/EnvSwitcher security delete-generic-password -s EnvSwitcher -a vault defaults delete com.ahmetkorkmaz.envswitcher
These commands do not change your .env files.