capture
Capture all .env files from a repository and store them in the global envi store.
Usage
bash
envi captureDescription
The capture command traverses your repository to find all environment files (.env, .env.local, .env.production, etc.) and stores them in ~/.envi/store/.
What It Does
- Finds project root - Looks for version control markers (
.git,.jj,.hg,.svn), or prompts you to confirm the current directory - Discovers env files - Recursively searches for
.envand.env.*files - Respects .gitignore - Only uses directories from .gitignore if present, not file patterns
- Parses files - Extracts key-value pairs and preserves comments
- Stores configuration - Saves to
~/.envi/store/{package-name}.maml - Creates git commit (if GitHub integration is enabled)
File Matching
Envi finds files that match:
.env(exact match).env.*(anything with a dot separator, like.env.local,.env.production)
Files are discovered recursively in all subdirectories, except:
node_modules/.git/- Other directories ignored in your
.gitignore
Storage Organization
With package.json
If your repository has a package.json with a name field:
json
{
"name": "@myorg/myapp"
}Files are stored at: ~/.envi/store/@myorg/myapp.maml
Scoped packages create subdirectories for better organization.
Without package.json
If no package.json or no name field exists, Envi:
- Warns you about potential naming conflicts
- Prompts for confirmation (default: Yes)
- Uses the folder name:
~/.envi/store/foldername.maml
Change Detection
When you run capture multiple times:
- No changes: Shows info message, no file write, no commit
- Changes detected: Updates file and creates commit (if GitHub enabled)
Files are sorted by path before comparison to ensure consistent results.
Examples
Basic Capture
bash
$ envi capture
◐ Finding repository root...
ℹ Repository root: /Users/you/projects/myapp
ℹ Package name: @myorg/myapp
◐ Searching for .env files...
✔ Found 3 file(s):
- .env.local
- apps/web/.env.production
- packages/api/.env
◐ Parsing files...
◐ Saving to storage...
✔ Captured environment files for '@myorg/myapp'No Changes Detected
bash
$ envi capture
...
ℹ No changes detected - environment files are identical to stored version.
ℹ Stored at: ~/.envi/store/@myorg/myapp.mamlWith GitHub Integration
bash
$ envi capture
...
✔ Captured environment files for '@myorg/myapp'
◐ Committing to version control...
✔ Committed and pushed to GitHubRelated Commands
- restore - Restore env files from storage
- global github enable - Enable GitHub integration