An open API service indexing awesome lists of open source software.

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

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]
```