Tired of manually rewriting .env file just to change the enviroment? This little CLI app does the job for you!
Prepare a couple of .env.enviroment files like .env.dev or .env.prod and switch quickly between them with swenv sw <enviroment>.
Selected enviroment will be copied into the .env file.
brew install BasileosFelices/tap/swenvTo upgrade:
brew upgrade swenvscoop bucket add BasileosFelices https://github.com/BasileosFelices/scoop-bucket
scoop install swenvTo upgrade:
scoop update swenvgo install github.com/BasileosFelices/swenv@latestDownload the appropriate binary from the Releases page for your platform.
You can allways run swenv --help for all available commands. Currently however there are just two commands:
swenv list/ls- Lists currently available enviroment filesswenv switch/sw <enviroment>- Switches to desired enviroment
For simple use you can use swenv <enviroment> without the switch command. No argument acts like the list command.
The current .env file is always backed up to .env.swenv.envbackup
This happens because the binary isn't code-signed. To fix:
- Open System Settings → Privacy & Security
- Scroll down and click "Open Anyway" next to the swenv warning
Or run:
xattr -d com.apple.quarantine $(which swenv)I recommend adding the following into your project .gitignore file. It prevents all enviroment files from being commited while allowing the examples.
# env files
.env*
!.env*.example