https://github.com/toilal/dotx
Bridge the gap between shell commands and .env files
https://github.com/toilal/dotx
Last synced: about 1 year ago
JSON representation
Bridge the gap between shell commands and .env files
- Host: GitHub
- URL: https://github.com/toilal/dotx
- Owner: Toilal
- License: mit
- Created: 2022-03-04T19:49:25.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2022-03-11T07:28:47.000Z (about 4 years ago)
- Last Synced: 2025-01-21T09:09:35.744Z (over 1 year ago)
- Language: TypeScript
- Size: 1.15 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# dotx
Bridge the gap between shell commands and [dotenv](https://www.npmjs.com/package/dotenv) `.env` files.
## Install
```bash
npm install --global @toilal/dotx
```
## Docs
`dotx` can be used to run any command with environment variable loaded from `.env` file.
```bash
dotx
```
A custom `.env` file can be given:
```bash
dotx -f .env.test
```
You may also set many `.env` files.
```bash
dotx -f .env -f .env.local
```
*later files have higher priority and will erase variables loaded from previous files*
`.env` files can be loaded into current shell using the following trick:
```bash
eval $(dotx -o export)
```
You can also grab a single value
```bash
MY_VAR=$(dotx -r MY_VAR)
```
## Usage
```bash
$ dotx --help
Options:
--help Show help [boolean]
--version Show version number [boolean]
-f, --files .env files to load [array]
-o, --output output environment variable
[string] [choices: "set", "export", "json", "json-pretty"]
-r, --read-value read value for one environment variable [string]
-s, --shell execute the command in shell [boolean]
```